Skip to content
Snippets Groups Projects
Commit 2af6ec5b authored by Jesse Mapel's avatar Jesse Mapel Committed by jlaura
Browse files

Fixed shared field names between measures and points (#122)

* First pass at shared field names

* Removed write changes

* Removed print

* Added better testing. Fixed weird choosername problem
parent af0dc54a
Branches
No related tags found
No related merge requests found
...@@ -89,6 +89,25 @@ class IsisStore(object): ...@@ -89,6 +89,25 @@ class IsisStore(object):
The current index to be assigned to newly added points The current index to be assigned to newly added points
""" """
point_field_map = {
'type' : 'pointType',
'chooserName' : 'pointChoosername',
'datetime' : 'pointDatetime',
'editLock' : 'pointEditLock',
'ignore' : 'pointIgnore',
'jigsawRejected' : 'pointJigsawRejected',
'log' : 'pointLog'
}
measure_field_map = {
'type' : 'measureType',
'choosername' : 'measureChoosername',
'datetime' : 'measureDatetime',
'editLock' : 'measureEditLock',
'ignore' : 'measureIgnore',
'jigsawRejected' : 'measureJigsawRejected',
'log' : 'measureLog'
}
def __init__(self, path, mode=None, **kwargs): def __init__(self, path, mode=None, **kwargs):
self.nmeasures = 0 self.nmeasures = 0
self.npoints = 0 self.npoints = 0
...@@ -180,10 +199,11 @@ class IsisStore(object): ...@@ -180,10 +199,11 @@ class IsisStore(object):
pts.append(meas) pts.append(meas)
byte_count += 4 + message_size byte_count += 4 + message_size
self.point_attrs = [i if i != 'jigsawRejected' else 'pointJigsawRejected' for i in self.point_attrs]
cols = self.point_attrs + self.measure_attrs
cols = self.point_attrs + self.measure_attrs # Some point and measure fields have the same name, so mangle them as point_ and measure_
point_cols = [self.point_field_map[attr] if attr in self.point_field_map else attr for attr in self.point_attrs]
measure_cols = [self.measure_field_map[attr] if attr in self.measure_field_map else attr for attr in self.measure_attrs]
cols = point_cols + measure_cols
df = IsisControlNetwork(pts, columns=cols) df = IsisControlNetwork(pts, columns=cols)
# Convert the (0.5, 0.5) origin pixels back to (0,0) pixels # Convert the (0.5, 0.5) origin pixels back to (0,0) pixels
df['line'] -= 0.5 df['line'] -= 0.5
...@@ -249,7 +269,6 @@ class IsisStore(object): ...@@ -249,7 +269,6 @@ class IsisStore(object):
point_spec.aprioriCovar.extend(arr) point_spec.aprioriCovar.extend(arr)
else: else:
setattr(point_spec, attr, attrtype(g.iloc[0][attr])) setattr(point_spec, attr, attrtype(g.iloc[0][attr]))
# point_spec.type = 2 # Hardcoded to free this is bad
# The reference index should always be the image with the lowest index # The reference index should always be the image with the lowest index
point_spec.referenceIndex = 0 point_spec.referenceIndex = 0
...@@ -265,7 +284,7 @@ class IsisStore(object): ...@@ -265,7 +284,7 @@ class IsisStore(object):
# ISIS pixels are centered on (0.5, 0.5). NDArrays are (0,0) based. # ISIS pixels are centered on (0.5, 0.5). NDArrays are (0,0) based.
measure_spec.sample = m.x + 0.5 measure_spec.sample = m.x + 0.5
measure_spec.line = m.y + 0.5 measure_spec.line = m.y + 0.5
measure_spec.type = m.measuretype measure_spec.type = m.measure_type
measure_iterable.append(measure_spec) measure_iterable.append(measure_spec)
self.nmeasures += 1 self.nmeasures += 1
......
...@@ -24,6 +24,12 @@ def test_cnet_read(cnet_file): ...@@ -24,6 +24,12 @@ def test_cnet_read(cnet_file):
assert len(df) == find_in_dict(df.header, 'NumberOfMeasures') assert len(df) == find_in_dict(df.header, 'NumberOfMeasures')
assert isinstance(df, io_controlnetwork.IsisControlNetwork) assert isinstance(df, io_controlnetwork.IsisControlNetwork)
assert len(df.groupby('id')) == find_in_dict(df.header, 'NumberOfPoints') assert len(df.groupby('id')) == find_in_dict(df.header, 'NumberOfPoints')
for proto_field, mangled_field in io_controlnetwork.IsisStore.point_field_map.items():
assert proto_field not in df.columns
assert mangled_field in df.columns
for proto_field, mangled_field in io_controlnetwork.IsisStore.measure_field_map.items():
assert proto_field not in df.columns
assert mangled_field in df.columns
class TestWriteIsisControlNetwork(unittest.TestCase): class TestWriteIsisControlNetwork(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment