Commit 94442eaf authored by jlaura's avatar jlaura Committed by Jesse Mapel
Browse files

Updates control network IO to convert to 0 based pixels (#127)

* Updates to_isis to use the 0.5 offset

* inverse correction on from_isis
parent decb3b6e
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ class IsisStore(object):
            self._handle.seek(point_start_byte)
            cp = cnp5.ControlPointFileEntryV0005()
            pts = []
            byte_count = 0;
            byte_count = 0
            while byte_count < find_in_dict(pvl_header, 'PointsBytes'):
                message_size = struct.unpack('I', self._handle.read(4))[0]
                cp.ParseFromString(self._handle.read(message_size))
@@ -185,6 +185,9 @@ class IsisStore(object):

        cols = self.point_attrs + self.measure_attrs
        df = IsisControlNetwork(pts, columns=cols)
        # Convert the (0.5, 0.5) origin pixels back to (0,0) pixels
        df['line'] -= 0.5
        df['sample'] -= 0.5
        df.header = pvl_header
        return df

@@ -259,8 +262,9 @@ class IsisStore(object):
                    if attr in g.columns:
                        setattr(measure_spec, attr, attrtype(m[attr]))
                measure_spec.serialnumber = m.serialnumber
                measure_spec.sample = m.x
                measure_spec.line = m.y
                # 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.measuretype
                measure_iterable.append(measure_spec)
                self.nmeasures += 1