Skip to content
Snippets Groups Projects
Unverified Commit d397cd05 authored by acpaquette's avatar acpaquette Committed by GitHub
Browse files

Projection Addition Fixes (#528)

* Attached the projection to isd if it is a non-empty dtring

* Fixed projected image tests

* Added all change log entries up to current ALE

* Added changelog entry for current PR

* Removed leftover debug prints
parent 0acc3233
No related branches found
No related tags found
No related merge requests found
......@@ -35,3 +35,14 @@ release.
## [Unreleased]
### Fixed
- Kaguya IsisLabelIsisSpice now calculates the right exposure_duration and focal2pixel_lines [#487](https://github.com/DOI-USGS/ale/pull/487)
- Logging from generate_isd now correctly limits logging information [#487](https://github.com/DOI-USGS/ale/pull/487)
### Changed
- Projection information is only written to the ISD if a projection is present instead of writing an empty projection [#528](https://github.com/DOI-USGS/ale/pull/528/)
### Added
- Projection information (through GDAL) will be attached to the ISD if a projected product is processed through ALE [#524](https://github.com/DOI-USGS/ale/pull/524)
- Kaguya IsisLabelNaifSpice driver, tests, and test data [#487](https://github.com/DOI-USGS/ale/pull/487)
- Hayabusa Amica IsisLabelNaifSpice driver, tests and test data [#521](https://github.com/DOI-USGS/ale/pull/521)
\ No newline at end of file
......@@ -336,25 +336,26 @@ class Driver():
self._projection = ""
return self._projection
geodata = None
if isinstance(self._file, pvl.PVLModule):
# save it to a temp folder
with tempfile.NamedTemporaryFile() as tmp:
tmp.write(pvl.dumps(self._file))
geodata = gdal.Open(tempfile.name)
self._projection = geodata.GetSpatialRef()
else:
# should be a path
if not os.path.exists(self._file):
self._projection = ""
else:
geodata = gdal.Open(self._file)
self._projection = geodata.GetSpatialRef()
# is None if not projected
if self._projection:
self._projection = self._projection.ExportToProj4()
else:
# Try to get the projection, if we are unsuccessful set it
# to empty
try:
self._projection = geodata.GetSpatialRef().ExportToProj4()
except:
self._projection = ""
return self._projection
......
......@@ -196,6 +196,7 @@ def to_isd(driver):
meta_data['sun_position'] = sun_position
if (driver.projection != ""):
meta_data["projection"] = driver.projection
meta_data["geotransform"] = driver.geotransform
......
......@@ -51,6 +51,7 @@ def to_usgscsm(driver):
'unit' : 'm'
}
if (driver.projection != ""):
isd_data["projection"] = driver.projection
isd_data["geotransform"] = driver.geotransform
......
......@@ -9,6 +9,8 @@ from ale.transformation import FrameChain
from ale.base.data_naif import NaifSpice
from ale.rotation import ConstantRotation, TimeDependentRotation
from conftest import get_image_label
class DummyNaifSpiceDriver(Driver, NaifSpice):
"""
Test Driver implementation with dummy values
......@@ -169,7 +171,6 @@ class DummyLineScannerDriver(LineScanner, DummyNaifSpiceDriver):
def exposure_duration(self):
return .01
@pytest.fixture
def driver():
return DummyFramerDriver('')
......@@ -348,3 +349,18 @@ def test_naif_keywords(driver):
'keyword_1' : 0,
'keyword_2' : 'test'
}
def test_no_projection(test_frame_driver):
isd = formatter.to_isd(test_frame_driver)
# isn't using real projection so it should be None
assert isd.get("projection", None) == None
def test_isis_projection():
isd = formatter.to_isd(DummyLineScannerDriver(get_image_label('B10_013341_1010_XN_79S172W', "isis3")))
assert isd.get("projection", None) == "+proj=sinu +lon_0=148.36859083039 +x_0=0 +y_0=0 +R=3396190 +units=m +no_defs"
def test_isis_geotransform():
isd = formatter.to_isd(DummyLineScannerDriver(get_image_label('B10_013341_1010_XN_79S172W', "isis3")))
expected = (-219771.1526456, 1455.4380969907, 0.0, 5175537.8728989, 0.0, -1455.4380969907)
for value, truth in zip(isd.get("geotransform", None), expected):
pytest.approx(value, truth)
......@@ -202,9 +202,7 @@ def usgscsm_compare_dict():
"t0_ephemeris": -101.83713859319687,
"dt_ephemeris": 40.734855437278746,
"t0_quaternion": -101.83713859319687,
"dt_quaternion": 40.734855437278746,
"projection" : "",
"geotransform" : (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
"dt_quaternion": 40.734855437278746
},
"isis" :
......
......@@ -59,6 +59,8 @@ def test_mro_ctx_load(test_ctx_kernels, label_type, kernel_type):
if label_type == 'isis3' and kernel_type == 'naif':
compare_isd['image_samples'] = 5000
compare_isd["projection"] = '+proj=sinu +lon_0=148.36859083039 +x_0=0 +y_0=0 +R=3396190 +units=m +no_defs'
compare_isd["geotransform"] = [-219771.1526456, 1455.4380969907, 0.0, 5175537.8728989, 0.0, -1455.4380969907]
comparison = compare_dicts(isd_obj, compare_isd)
assert comparison == []
......
......@@ -348,16 +348,16 @@ def test_line_scan_sun_position(test_line_scan_driver):
def test_no_projection(test_frame_driver):
isd = usgscsm_formatter.to_usgscsm(test_frame_driver)
# isn't using real projection so it should be None
assert isd['projection'] == None
assert isd.get("projection", None) == None
def test_isis_projection():
isd = usgscsm_formatter.to_usgscsm(TestLineScanner(get_image_label('B10_013341_1010_XN_79S172W', "isis3")))
assert isd["projection"] == "+proj=sinu +lon_0=148.36859083039 +x_0=0 +y_0=0 +R=3396190 +units=m +no_defs"
assert isd.get("projection", None) == "+proj=sinu +lon_0=148.36859083039 +x_0=0 +y_0=0 +R=3396190 +units=m +no_defs"
def test_isis_geotransform():
isd = usgscsm_formatter.to_usgscsm(TestLineScanner(get_image_label('B10_013341_1010_XN_79S172W', "isis3")))
expected = (-219771.1526456, 1455.4380969907, 0.0, 5175537.8728989, 0.0, -1455.4380969907)
for value, truth in zip(isd["geotransform"], expected):
for value, truth in zip(isd.get("geotransform", None), expected):
pytest.approx(value, truth)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment