Empty FileNotFoundError in case no DEM is provided by the user.

from enpt.execution.controller import EnPT_Controller
CTR = EnPT_Controller(path_l1b_enmap_image='/path/to/'
                                           'ENMAP01-____L1B-DT000000987_20130205T105307Z_001_V000003_20181214T160003Z__rows0-99.zip',
                     is_test=True,
                     is_dlr_dataformat=True
                     )
CTR.run_all_processors()
2019/07/18 16:52:49:   Reading metadata for VNIR detector...
2019/07/18 16:52:49:   DLR test data provide multiple cloud masks. Added only *QUALITY_CLOUD.GEOTIFF!
2019/07/18 16:52:50:   Reading metadata for SWIR detector...
2019/07/18 16:52:50:   DLR test data provide multiple cloud masks. Added only *QUALITY_CLOUD.GEOTIFF!
Unexpected dimensions of dead pixel mask: %s. Setting all pixels to 'normal'.
2019/07/18 16:52:50:   Converting DN values to radiance [mW/m^2/sr/nm] for VNIR detector...
2019/07/18 16:52:50:   Converting DN values to radiance [mW/m^2/sr/nm] for SWIR detector...
2019/07/18 16:52:51:   Computing SNR for VNIR using /tmp/tmpt22w4gzq/SNR_D1.bsq
2019/07/18 16:52:52:   Computing SNR for SWIR using /tmp/tmpt22w4gzq/SNR_D2.bsq
2019/07/18 16:52:52:   Computing VNIR geolayer...
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-10-847ee6083e06> in <module>
      5                      is_dlr_dataformat=True
      6                      )
----> 7 CTR.run_all_processors()

~/scheffler/python_deployed/EnPT/enpt/execution/controller.py in run_all_processors(self)
    116         """Run all processors at once."""
    117         try:
--> 118             self.read_L1B_data()
    119             if self.cfg.run_deadpix_P:
    120                 self.L1_obj.correct_dead_pixels()

~/scheffler/python_deployed/EnPT/enpt/execution/controller.py in read_L1B_data(self)
     78         RD = L1B_Reader(config=self.cfg)
     79         self.L1_obj = RD.read_inputdata(root_dir_main=path_enmap_image, root_dir_ext=path_enmap_image_gapfill,
---> 80                                         n_line_ext=self.cfg.n_lines_to_append)
     81 
     82     def run_toaRad2toaRef(self):

~/scheffler/python_deployed/EnPT/enpt/io/reader.py in read_inputdata(self, root_dir_main, root_dir_ext, n_line_ext, compute_snr)
    120         if l1b_main_obj.meta.vnir.lons is None or l1b_main_obj.meta.vnir.lats is None:
    121             l1b_main_obj.meta.vnir.lons, l1b_main_obj.meta.vnir.lats = \
--> 122                 l1b_main_obj.meta.vnir.compute_geolayer_for_cube()
    123 
    124         if l1b_main_obj.meta.swir.lons is None or l1b_main_obj.meta.swir.lats is None:

~/scheffler/python_deployed/EnPT/enpt/model/metadata.py in compute_geolayer_for_cube(self)
    385                                                                               self.lat_UL_UR_LL_LR)),
    386                                                enmapIm_dims_sensorgeo=(self.nrows, self.ncols),
--> 387                                                CPUs=self.cfg.CPUs)\
    388             .compute_geolayer()
    389 

~/scheffler/python_deployed/EnPT/enpt/processors/spatial_transform/spatial_transform.py in __init__(self, rpc_coeffs_per_band, dem, enmapIm_cornerCoords, enmapIm_dims_sensorgeo, CPUs)
    427         from ..dem_preprocessing import DEM_Processor
    428         self.dem = DEM_Processor(dem_path_geoarray=dem,
--> 429                                  enmapIm_cornerCoords=enmapIm_cornerCoords).dem
    430         # TODO clip DEM to needed area
    431         self.dem.to_mem()

~/scheffler/python_deployed/EnPT/enpt/processors/dem_preprocessing/dem_preprocessing.py in __init__(self, dem_path_geoarray, enmapIm_cornerCoords, CPUs)
     18                  enmapIm_cornerCoords: Tuple[Tuple[float, float]],
     19                  CPUs: int = None):
---> 20         self.dem = GeoArray(dem_path_geoarray)
     21         self.enmapIm_cornerCoords = enmapIm_cornerCoords
     22         self.CPUs = CPUs or cpu_count()

~/scheffler/python_deployed/geoarray/geoarray/baseclasses.py in __init__(self, path_or_array, geotransform, projection, bandnames, nodata, progress, q)
     89 
     90             if not os.path.exists(path_or_array):
---> 91                 raise FileNotFoundError(path_or_array)
     92 
     93         if isinstance(path_or_array, GeoArray) or issubclass(getattr(path_or_array, '__class__'), GeoArray):

FileNotFoundError: 

Proposed solution:

  • Don´t return an empty FileNotFoundError. Check for the empty path and return a useful error message.
  • Accept a static elevation set by the config parameter 'average_elevation'.
Edited by Daniel Scheffler