Skip to content
Snippets Groups Projects
Commit 144f9433 authored by Jason R Laura's avatar Jason R Laura
Browse files

updates for CNET

parent 8338be77
No related branches found
No related tags found
No related merge requests found
......@@ -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
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)
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment