From 144f9433693345e6c74d6ac853ce1f274784a03e Mon Sep 17 00:00:00 2001
From: Jason R Laura <jlaura@igswzawglt-mjay.local>
Date: Tue, 1 Nov 2016 08:43:14 -0700
Subject: [PATCH] updates for CNET

---
 plio/io/io_controlnetwork.py               |  6 +++---
 plio/io/io_spectral_profiler.py            | 21 ++++++++++++++++++++-
 plio/io/tests/test_io_spectral_profiler.py |  7 ++++++-
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/plio/io/io_controlnetwork.py b/plio/io/io_controlnetwork.py
index afcf5a4..b120bd6 100644
--- a/plio/io/io_controlnetwork.py
+++ b/plio/io/io_controlnetwork.py
@@ -222,10 +222,12 @@ class IsisStore(object):
                     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.type = int(m.measure_type)
-
+                    measure_spec.line = m.y
+                    measure_spec.sample = m.x
                     measure_iterable.append(measure_spec)
                     self.nmeasures += 1
                 point_spec.measures.extend(measure_iterable)
@@ -364,5 +366,3 @@ class IsisStore(object):
         if self._handle is not None:
             self._handle.close()
         self._handle = None
-
-
diff --git a/plio/io/io_spectral_profiler.py b/plio/io/io_spectral_profiler.py
index 0619eb6..98cb989 100755
--- a/plio/io/io_spectral_profiler.py
+++ b/plio/io/io_spectral_profiler.py
@@ -1,9 +1,10 @@
+import os
 import pandas as pd
 import pvl
 import numpy as np
 
 from plio.utils.utils import find_in_dict
-
+from plio.io.io_gdal import GeoDataset
 
 class Spectral_Profiler(object):
 
@@ -52,6 +53,7 @@ class Spectral_Profiler(object):
 
         label = pvl.load(input_data)
         self.label = label
+        self.input_data = input_data
         with open(input_data, 'rb') as indata:
             # Extract and handle the ancillary data
             ancillary_data = find_in_dict(label, "ANCILLARY_AND_SUPPLEMENT_DATA")
@@ -128,3 +130,20 @@ class Spectral_Profiler(object):
                     self.spectra[i] = self.spectra[i][self.spectra[i]['QA'] < qa_threshold]
 
             self.spectra = pd.Panel(self.spectra)
+
+    def open_browse(self, extension='.jpg'):
+        """
+        Attempt to open the browse image corresponding to the spc file
+
+        Parameters
+        ----------
+        extension : str
+                    The file type extension to be added to the base name
+                    of the spc file.
+
+        Returns
+        -------
+
+        """
+        path, ext = os.path.splitext(self.input_data)
+        self.browse = GeoDataset(path + extension)
diff --git a/plio/io/tests/test_io_spectral_profiler.py b/plio/io/tests/test_io_spectral_profiler.py
index 61127a6..3d05e05 100644
--- a/plio/io/tests/test_io_spectral_profiler.py
+++ b/plio/io/tests/test_io_spectral_profiler.py
@@ -8,7 +8,7 @@ sys.path.insert(0, os.path.abspath('..'))
 
 from plio.examples import get_path
 from plio.io import io_spectral_profiler
-
+from plio.io.io_gdal import GeoDataset
 
 class Test_Spectral_Profiler_IO(unittest.TestCase):
     
@@ -21,6 +21,11 @@ class Test_Spectral_Profiler_IO(unittest.TestCase):
         self.assertIsInstance(ds.spectra, pd.Panel)
         self.assertEqual(ds.spectra[0].columns.tolist(), ['RAW', 'REF1', 'REF2', 'QA'])
 
+    def test_read_browse(self):
+        ds = io_spectral_profiler.Spectral_Profiler(self.examplefile)
+        ds.open_browse()
+        self.assertIsInstance(ds.browse, GeoDataset)
+        self.assertEqual(ds.browse.read_array().shape, (512, 456))
 
 if __name__ == '__main__':
     unittest.main()
-- 
GitLab