Commit bf8dcf92 authored by Tyler Thatcher's avatar Tyler Thatcher
Browse files

Modified io_controlnetwork to account for covariance matrix

parent 3477f2b2
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
from time import gmtime, strftime

import pandas as pd
import numpy as np
import pvl

from plio.io import ControlNetFileV0002_pb2 as cnf
@@ -267,24 +268,24 @@ class IsisStore(object):
                    # As per protobuf docs for assigning to a repeated field.
                    if attr == 'aprioriCovar':
                        arr = g.iloc[0]['aprioriCovar']
                        point_spec.aprioriCovar.extend(arr.ravel().tolist())
                        if isinstance(arr, np.ndarray):
                            arr = arr.ravel().tolist()

                        point_spec.aprioriCovar.extend(arr)
                    else:
                        setattr(point_spec, attr, attrtype(g.iloc[0][attr]))
            point_spec.type = 2  # Hardcoded to free
            point_spec.type = 2  # Hardcoded to free this is bad

            # The reference index should always be the image with the lowest index
            point_spec.referenceIndex = 0

            # A single extend call is cheaper than many add calls to pack points
            measure_iterable = []

            for node_id, m in g.iterrows():
                measure_spec = point_spec.Measure()
                # For all of the attributes, set if they are an dict accessible attr of the obj.
                for attr, attrtype in self.measure_attrs:
                    if attr in g.columns:
                        setattr(measure_spec, attr, attrtype(m[attr]))

                measure_spec.serialnumber = serials[m.image_index]
                measure_spec.sample = m.x
                measure_spec.line = m.y
@@ -298,7 +299,6 @@ class IsisStore(object):
            point_message = point_spec.SerializeToString()
            point_sizes.append(point_spec.ByteSize())
            point_messages.append(point_message)

        return point_messages, point_sizes

    def create_buffer_header(self, networkid, targetname,