Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed pvl loads #591

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 9 additions & 8 deletions ale/base/label_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ale/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions tests/pytests/test_pvl_load.py
Original file line number Diff line number Diff line change
@@ -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
Loading