Loading ale/base/base.py +61 −0 Original line number Diff line number Diff line import pvl import json import tempfile import os class Driver(): """ Base class for all Drivers. Loading Loading @@ -323,3 +326,61 @@ class Driver(): @property def short_mission_name(self): return self.__module__.split('.')[-1].split('_')[0] @property def projection(self): if not hasattr(self, "_projection"): try: from osgeo import gdal except: self._projection = "" return self._projection 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: self._projection = "" return self._projection @property def geotransform(self): if not hasattr(self, "_geotransform"): try: from osgeo import gdal except: self._geotransform = (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) return self._geotransform 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._geotransform = geodata.GetGeoTransform() else: # should be a path if not os.path.exists(self._file): self._geotransform = (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) else: geodata = gdal.Open(self._file) self._geotransform = geodata.GetGeoTransform() return self._geotransform No newline at end of file ale/formatters/formatter.py +2 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,8 @@ def to_isd(driver): meta_data['sun_position'] = sun_position meta_data["projection"] = driver.projection meta_data["geotransform"] = driver.geotransform # check that there is a valid sensor model name if 'name_model' not in meta_data: Loading ale/formatters/usgscsm_formatter.py +3 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ def to_usgscsm(driver): 'unit' : 'm' } isd_data["projection"] = driver.projection isd_data["geotransform"] = driver.geotransform # shared isd keywords for Framer and Linescanner if isinstance(driver, LineScanner) or isinstance(driver, Framer): # exterior orientation for just Framer and LineScanner Loading environment.yml +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ dependencies: - cmake>=3.15 - pytest - eigen - gdal - jupyter - nlohmann_json - numpy Loading include/ale/Util.h +3 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ namespace ale { std::string getPlatformName(nlohmann::json isd); std::string getLogFile(nlohmann::json isd); std::string getIsisCameraVersion(nlohmann::json isd); std::string getProjection(nlohmann::json isd); int getTotalLines(nlohmann::json isd); int getTotalSamples(nlohmann::json isd); double getStartingTime(nlohmann::json isd); Loading @@ -45,6 +47,7 @@ namespace ale { double getFocalLengthUncertainty(nlohmann::json isd); std::vector<double> getFocal2PixelLines(nlohmann::json isd); std::vector<double> getFocal2PixelSamples(nlohmann::json isd); std::vector<double> getGeoTransform(nlohmann::json isd); double getDetectorCenterLine(nlohmann::json isd); double getDetectorCenterSample(nlohmann::json isd); double getDetectorStartingLine(nlohmann::json isd); Loading Loading
ale/base/base.py +61 −0 Original line number Diff line number Diff line import pvl import json import tempfile import os class Driver(): """ Base class for all Drivers. Loading Loading @@ -323,3 +326,61 @@ class Driver(): @property def short_mission_name(self): return self.__module__.split('.')[-1].split('_')[0] @property def projection(self): if not hasattr(self, "_projection"): try: from osgeo import gdal except: self._projection = "" return self._projection 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: self._projection = "" return self._projection @property def geotransform(self): if not hasattr(self, "_geotransform"): try: from osgeo import gdal except: self._geotransform = (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) return self._geotransform 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._geotransform = geodata.GetGeoTransform() else: # should be a path if not os.path.exists(self._file): self._geotransform = (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) else: geodata = gdal.Open(self._file) self._geotransform = geodata.GetGeoTransform() return self._geotransform No newline at end of file
ale/formatters/formatter.py +2 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,8 @@ def to_isd(driver): meta_data['sun_position'] = sun_position meta_data["projection"] = driver.projection meta_data["geotransform"] = driver.geotransform # check that there is a valid sensor model name if 'name_model' not in meta_data: Loading
ale/formatters/usgscsm_formatter.py +3 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ def to_usgscsm(driver): 'unit' : 'm' } isd_data["projection"] = driver.projection isd_data["geotransform"] = driver.geotransform # shared isd keywords for Framer and Linescanner if isinstance(driver, LineScanner) or isinstance(driver, Framer): # exterior orientation for just Framer and LineScanner Loading
environment.yml +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ dependencies: - cmake>=3.15 - pytest - eigen - gdal - jupyter - nlohmann_json - numpy Loading
include/ale/Util.h +3 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ namespace ale { std::string getPlatformName(nlohmann::json isd); std::string getLogFile(nlohmann::json isd); std::string getIsisCameraVersion(nlohmann::json isd); std::string getProjection(nlohmann::json isd); int getTotalLines(nlohmann::json isd); int getTotalSamples(nlohmann::json isd); double getStartingTime(nlohmann::json isd); Loading @@ -45,6 +47,7 @@ namespace ale { double getFocalLengthUncertainty(nlohmann::json isd); std::vector<double> getFocal2PixelLines(nlohmann::json isd); std::vector<double> getFocal2PixelSamples(nlohmann::json isd); std::vector<double> getGeoTransform(nlohmann::json isd); double getDetectorCenterLine(nlohmann::json isd); double getDetectorCenterSample(nlohmann::json isd); double getDetectorStartingLine(nlohmann::json isd); Loading