Loading plio/io/io_controlnetwork.py +3 −3 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -364,5 +366,3 @@ class IsisStore(object): if self._handle is not None: self._handle.close() self._handle = None plio/io/io_spectral_profiler.py +20 −1 Original line number Diff line number Diff line 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): Loading Loading @@ -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") Loading Loading @@ -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) plio/io/tests/test_io_spectral_profiler.py +6 −1 Original line number Diff line number Diff line Loading @@ -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): Loading @@ -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() Loading
plio/io/io_controlnetwork.py +3 −3 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -364,5 +366,3 @@ class IsisStore(object): if self._handle is not None: self._handle.close() self._handle = None
plio/io/io_spectral_profiler.py +20 −1 Original line number Diff line number Diff line 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): Loading Loading @@ -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") Loading Loading @@ -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)
plio/io/tests/test_io_spectral_profiler.py +6 −1 Original line number Diff line number Diff line Loading @@ -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): Loading @@ -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()