diff --git a/CHANGELOG.md b/CHANGELOG.md index b811094e1..4fd1271e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ release. - Fixed LRO MiniRF drivers naif keywords focal to pixel and pixel to focal translations to be correct. [#569](https://github.com/DOI-USGS/ale/pull/569) - Bugfix for position and orientation for MSL cameras (driver MslMastcamPds3NaifSpiceDriver). Validated that Nav and Mast LBL files (for both left and right sensor) produce correctly positioned and oriented CSM cameras, that are self-consistent and consistent with a prior DEM for the site. [#580](https://github.com/DOI-USGS/ale/pull/580) - Bug fix for ray direction for MSL. [#589](https://github.com/DOI-USGS/ale/pull/589) +- Bug fix for pvl.loads() to allow the ingestion of PVLObjects into ale.loads() [#591](https://github.com/DOI-USGS/ale/pull/591) ### Changed - Removed the affine6p library and replaced affine6p's affine transformation with a numpy solution [#579](https://github.com/DOI-USGS/ale/pull/579) diff --git a/ale/base/label_isis.py b/ale/base/label_isis.py index 28d1642d2..a37ea945b 100644 --- a/ale/base/label_isis.py +++ b/ale/base/label_isis.py @@ -10,14 +10,15 @@ def label(self): if not hasattr(self, "_label"): if isinstance(self._file, pvl.PVLModule): self._label = self._file - grammar = pvl.grammar.ISISGrammar() - grammar.comments+=(("#", "\n"), ) - try: - self._label = pvl.loads(self._file, grammar=grammar) - except Exception: - self._label = pvl.load(self._file, grammar=grammar) - except: - raise ValueError("{} is not a valid label".format(self._file)) + else: + grammar = pvl.grammar.ISISGrammar() + grammar.comments+=(("#", "\n"), ) + try: + self._label = pvl.loads(self._file, grammar=grammar) + except Exception: + self._label = pvl.load(self._file, grammar=grammar) + except: + raise ValueError("{} is not a valid label".format(self._file)) return self._label @property diff --git a/ale/drivers/__init__.py b/ale/drivers/__init__.py index dbb2609c2..a62666b47 100644 --- a/ale/drivers/__init__.py +++ b/ale/drivers/__init__.py @@ -213,6 +213,8 @@ def parse_label(label, grammar=pvl.grammar.PVLGrammar()): load loads """ + if isinstance(label, pvl.PVLModule): + return label try: parsed_label = pvl.loads(label, grammar=grammar) except Exception: diff --git a/tests/pytests/test_pvl_load.py b/tests/pytests/test_pvl_load.py new file mode 100644 index 000000000..a28bba0e9 --- /dev/null +++ b/tests/pytests/test_pvl_load.py @@ -0,0 +1,21 @@ +import pytest +import pvl +import ale +import os +import json + +from conftest import get_image_kernels, convert_kernels, get_image_label + +@pytest.fixture +def test_load_kernels(): + kerns = get_image_kernels('LUA3107H.161') + updated_kerns, binary_kerns = convert_kernels(kerns) + yield updated_kerns + for kern in binary_kerns: + os.remove(kern) + +def test_pvl_load(test_load_kernels): + cube_label = get_image_label('LUA3107H.161', "isis3") + isd = ale.loads(cube_label, props={'kernels': test_load_kernels, 'exact_ck_times': False}, only_naif_spice=True, verbose=True) + isd_obj = json.loads(isd) + return isd_obj \ No newline at end of file