Loading plio/examples/SpectralProfiler/SP_2C_03_04184_N187_E0053.lbl 0 → 100644 +553 −0 File added.Preview size limit exceeded, changes collapsed. Show changes plio/examples/SpectralProfiler/SP_2C_03_04184_N187_E0053.spc 0 → 100644 +117 KiB File added.No diff preview for this file type. View file plio/io/io_spectral_profiler.py +16 −5 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ class Spectral_Profiler(object): with key as the spectra index and value as the start byte offset with key as the spectra index and value as the start byte offset """ """ def __init__(self, input_data, cleaned=True, qa_threshold=2000): def __init__(self, input_data, label=None, cleaned=True, qa_threshold=2000): """ """ Read the .spc file, parse the label, and extract the spectra Read the .spc file, parse the label, and extract the spectra Loading @@ -34,6 +34,9 @@ class Spectral_Profiler(object): input_data : string input_data : string The PATH to the input .spc file The PATH to the input .spc file label : string The PATH to an optional detached label associated with the .spc cleaned : boolean cleaned : boolean If True, mask the data based on the QA array. If True, mask the data based on the QA array. Loading @@ -49,7 +52,9 @@ class Spectral_Profiler(object): 'MSB_INTEGER':'i', 'MSB_INTEGER':'i', 'MSB_UNSIGNED_INTEGER':'u'} 'MSB_UNSIGNED_INTEGER':'u'} if label: label = pvl.load(label) else: label = pvl.load(input_data) label = pvl.load(input_data) self.label = label self.label = label self.input_data = input_data self.input_data = input_data Loading @@ -63,7 +68,10 @@ class Spectral_Profiler(object): columns = [] columns = [] bytelengths = [] bytelengths = [] datatypes = [] datatypes = [] ancillary_data_offset = find_in_dict(label, "^ANCILLARY_AND_SUPPLEMENT_DATA").value try: ancillary_data_offset = find_in_dict(self.label, "^ANCILLARY_AND_SUPPLEMENT_DATA").value except: ancillary_data_offset = find_in_dict(self.label, "^ANCILLARY_AND_SUPPLEMENT_DATA")[1].value indata.seek(ancillary_data_offset - 1) indata.seek(ancillary_data_offset - 1) for i in ancillary_data.items(): for i in ancillary_data.items(): if i[0] == 'COLUMN': if i[0] == 'COLUMN': Loading Loading @@ -109,7 +117,10 @@ class Spectral_Profiler(object): search_key = '^SP_SPECTRUM_{}'.format(d) search_key = '^SP_SPECTRUM_{}'.format(d) result = find_in_dict(label, search_key) result = find_in_dict(label, search_key) if result: if result: try: array_offsets.append(result.value) array_offsets.append(result.value) except: array_offsets.append(result[1].value) # 2C V3.0 keys.append('SP_SPECTRUM_{}'.format(d)) keys.append('SP_SPECTRUM_{}'.format(d)) offsets = dict(zip(keys, array_offsets)) offsets = dict(zip(keys, array_offsets)) Loading plio/io/tests/test_io_spectral_profiler.py +11 −0 Original line number Original line Diff line number Diff line Loading @@ -30,5 +30,16 @@ class Test_Spectral_Profiler_IO(unittest.TestCase): self.assertIsInstance(ds.browse, GeoDataset) self.assertIsInstance(ds.browse, GeoDataset) self.assertEqual(ds.browse.read_array().shape, (512, 456)) self.assertEqual(ds.browse.read_array().shape, (512, 456)) class Test_Spectral_Profiler_IO_Detached(unittest.TestCase): def setUp(self): self.examplefile = get_path('SP_2C_03_04184_N187_E0053.spc') self.examplelabel = get_path('SP_2C_03_04184_N187_E0053.lbl') def test_openspc(self): ds = io_spectral_profiler.Spectral_Profiler(self.examplefile, self.examplelabel) self.assertEqual(ds.nspectra, 38) self.assertEqual(ds.spectra[0].columns.tolist(), ['RAW', 'REF1', 'REF2', 'QA', 'RAD']) if __name__ == '__main__': if __name__ == '__main__': unittest.main() unittest.main() setup.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,7 @@ with open('README.md', 'r') as f: def setup_package(): def setup_package(): setup( setup( name = "plio", name = "plio", version = '1.1.0', version = '1.2.0', author = "Jay Laura", author = "Jay Laura", author_email = "jlaura@usgs.gov", author_email = "jlaura@usgs.gov", description = ("I/O API to support planetary data formats."), description = ("I/O API to support planetary data formats."), Loading Loading
plio/examples/SpectralProfiler/SP_2C_03_04184_N187_E0053.lbl 0 → 100644 +553 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
plio/examples/SpectralProfiler/SP_2C_03_04184_N187_E0053.spc 0 → 100644 +117 KiB File added.No diff preview for this file type. View file
plio/io/io_spectral_profiler.py +16 −5 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ class Spectral_Profiler(object): with key as the spectra index and value as the start byte offset with key as the spectra index and value as the start byte offset """ """ def __init__(self, input_data, cleaned=True, qa_threshold=2000): def __init__(self, input_data, label=None, cleaned=True, qa_threshold=2000): """ """ Read the .spc file, parse the label, and extract the spectra Read the .spc file, parse the label, and extract the spectra Loading @@ -34,6 +34,9 @@ class Spectral_Profiler(object): input_data : string input_data : string The PATH to the input .spc file The PATH to the input .spc file label : string The PATH to an optional detached label associated with the .spc cleaned : boolean cleaned : boolean If True, mask the data based on the QA array. If True, mask the data based on the QA array. Loading @@ -49,7 +52,9 @@ class Spectral_Profiler(object): 'MSB_INTEGER':'i', 'MSB_INTEGER':'i', 'MSB_UNSIGNED_INTEGER':'u'} 'MSB_UNSIGNED_INTEGER':'u'} if label: label = pvl.load(label) else: label = pvl.load(input_data) label = pvl.load(input_data) self.label = label self.label = label self.input_data = input_data self.input_data = input_data Loading @@ -63,7 +68,10 @@ class Spectral_Profiler(object): columns = [] columns = [] bytelengths = [] bytelengths = [] datatypes = [] datatypes = [] ancillary_data_offset = find_in_dict(label, "^ANCILLARY_AND_SUPPLEMENT_DATA").value try: ancillary_data_offset = find_in_dict(self.label, "^ANCILLARY_AND_SUPPLEMENT_DATA").value except: ancillary_data_offset = find_in_dict(self.label, "^ANCILLARY_AND_SUPPLEMENT_DATA")[1].value indata.seek(ancillary_data_offset - 1) indata.seek(ancillary_data_offset - 1) for i in ancillary_data.items(): for i in ancillary_data.items(): if i[0] == 'COLUMN': if i[0] == 'COLUMN': Loading Loading @@ -109,7 +117,10 @@ class Spectral_Profiler(object): search_key = '^SP_SPECTRUM_{}'.format(d) search_key = '^SP_SPECTRUM_{}'.format(d) result = find_in_dict(label, search_key) result = find_in_dict(label, search_key) if result: if result: try: array_offsets.append(result.value) array_offsets.append(result.value) except: array_offsets.append(result[1].value) # 2C V3.0 keys.append('SP_SPECTRUM_{}'.format(d)) keys.append('SP_SPECTRUM_{}'.format(d)) offsets = dict(zip(keys, array_offsets)) offsets = dict(zip(keys, array_offsets)) Loading
plio/io/tests/test_io_spectral_profiler.py +11 −0 Original line number Original line Diff line number Diff line Loading @@ -30,5 +30,16 @@ class Test_Spectral_Profiler_IO(unittest.TestCase): self.assertIsInstance(ds.browse, GeoDataset) self.assertIsInstance(ds.browse, GeoDataset) self.assertEqual(ds.browse.read_array().shape, (512, 456)) self.assertEqual(ds.browse.read_array().shape, (512, 456)) class Test_Spectral_Profiler_IO_Detached(unittest.TestCase): def setUp(self): self.examplefile = get_path('SP_2C_03_04184_N187_E0053.spc') self.examplelabel = get_path('SP_2C_03_04184_N187_E0053.lbl') def test_openspc(self): ds = io_spectral_profiler.Spectral_Profiler(self.examplefile, self.examplelabel) self.assertEqual(ds.nspectra, 38) self.assertEqual(ds.spectra[0].columns.tolist(), ['RAW', 'REF1', 'REF2', 'QA', 'RAD']) if __name__ == '__main__': if __name__ == '__main__': unittest.main() unittest.main()
setup.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,7 @@ with open('README.md', 'r') as f: def setup_package(): def setup_package(): setup( setup( name = "plio", name = "plio", version = '1.1.0', version = '1.2.0', author = "Jay Laura", author = "Jay Laura", author_email = "jlaura@usgs.gov", author_email = "jlaura@usgs.gov", description = ("I/O API to support planetary data formats."), description = ("I/O API to support planetary data formats."), Loading