diff --git a/plio/io/io_controlnetwork.py b/plio/io/io_controlnetwork.py index afcf5a48b6f197788a7458c7af11af3356371974..b120bd6a89923e3a09e710c430cf6f280605689c 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 0619eb649ac18b59758e01ad399d3d22ba1dcdf6..98cb989130fb5d871f4547528f7266b6f78dbdd3 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 61127a6053936d90212d0841b4948b7cf489897a..3d05e05c4241e3fbc900aa9579072238a3bb06d6 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()