Skip to content

Commit

Permalink
Makes controlnetwork consistent (#131)
Browse files Browse the repository at this point in the history
* Fixing to_isis / from_isis process

* Removed merge conflict

* Fixed tests
  • Loading branch information
tthatcher95 authored and acpaquette committed Aug 21, 2019
1 parent 2af6ec5 commit 85945b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions plio/io/io_controlnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _set_pid(pointid):
# TODO: Rewrite using apply syntax for performance
point_sizes = []
point_messages = []
for i, g in df.groupby('point_id'):
for i, g in df.groupby('id'):

# Get the point specification from the protobuf
point_spec = cnf.ControlPointFileEntryV0002()
Expand All @@ -258,11 +258,12 @@ def _set_pid(pointid):
# set with the correct type
#point_spec.id = _set_pid(i)
point_spec.id = _set_pid(i)
point_spec.type = g.iloc[0].pointType
for attr, attrtype in self.point_attrs:
if attr in g.columns:
# As per protobuf docs for assigning to a repeated field.
if attr == 'aprioriCovar':
arr = g.iloc[0]['aprioriCovar']
if attr == 'aprioriCovar' or attr == 'adjustedCovar':
arr = g.iloc[0][attr]
if isinstance(arr, np.ndarray):
arr = arr.ravel().tolist()

Expand All @@ -282,9 +283,9 @@ def _set_pid(pointid):
setattr(measure_spec, attr, attrtype(m[attr]))
measure_spec.serialnumber = m.serialnumber
# ISIS pixels are centered on (0.5, 0.5). NDArrays are (0,0) based.
measure_spec.sample = m.x + 0.5
measure_spec.line = m.y + 0.5
measure_spec.type = m.measure_type
measure_spec.sample = m['sample'] + 0.5
measure_spec.line = m['line'] + 0.5
measure_spec.type = m.measureType
measure_iterable.append(measure_spec)
self.nmeasures += 1

Expand Down
4 changes: 2 additions & 2 deletions plio/io/tests/test_io_controlnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setUpClass(cls):
serial_times = {295: '1971-07-31T01:24:11.754',
296: '1971-07-31T01:24:36.970'}
cls.serials = {i:'APOLLO15/METRIC/{}'.format(j) for i, j in enumerate(serial_times.values())}
columns = ['point_id', 'type', 'serialnumber', 'measuretype', 'x', 'y', 'image_index']
columns = ['id', 'pointType', 'serialnumber', 'measureType', 'sample', 'line', 'image_index']

data = []
for i in range(cls.npts):
Expand All @@ -60,7 +60,7 @@ def test_create_buffer_header(self):
serial_times = {295: '1971-07-31T01:24:11.754',
296: '1971-07-31T01:24:36.970'}
serials = {i:'APOLLO15/METRIC/{}'.format(j) for i, j in enumerate(serial_times.values())}
columns = ['point_id', 'type', 'serialnumber', 'measuretype', 'x', 'y', 'image_index']
columns = ['id', 'pointType', 'serialnumber', 'measureType', 'sample', 'line', 'image_index']

data = []
for i in range(self.npts):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def setup_package():
setup(
name = "plio",
version = '1.2.1',
version = '1.2.2',
author = "Jay Laura",
author_email = "[email protected]",
description = ("I/O API to support planetary data formats."),
Expand Down

0 comments on commit 85945b3

Please sign in to comment.