Raise useful error if user-provided sensor is not supported.
Providing satellite='Sentinel-2'
instead of satellite='Sentinel-2A'
like this:
from pyrsr import RelativeSpectralResponse
LBA = ['1', '2', '3', '4', '5', '6', '7', '8', '8A', '11', '12']
rsr_s2 = RelativeSpectralResponse(satellite='Sentinel-2',
sensor='MSI',
LayerBandsAssignment=LBA)
raises:
Traceback (most recent call last):
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
yield
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/unittest/case.py", line 592, in run
self._callTestMethod(testMethod)
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
method()
File "/home/gfz-fe/scheffler/python/findr_homo/tests/test_homogenizer.py", line 64, in test_homogenize_landsat8
fh.homogenize_landsat8(path_l8, paths_ref_ims=paths_ref_ims, path_outdir=path_outdir)
File "/home/gfz-fe/scheffler/python/findr_homo/findr_homo/homogenization/homogenizer.py", line 54, in homogenize_landsat8
l8.data = SpecH.run(l8.data)
File "/home/gfz-fe/scheffler/python/findr_homo/findr_homo/homogenization/spectral.py", line 51, in run
image_s2 = self._update_band_metadata(image_s2=image_s2)
File "/home/gfz-fe/scheffler/python/findr_homo/findr_homo/homogenization/spectral.py", line 57, in _update_band_metadata
rsr_s2 = RelativeSpectralResponse(satellite='Sentinel-2',
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/pyrsr/rsr.py", line 143, in __init__
self.from_satellite_sensor(satellite, sensor, subsystem,
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/pyrsr/rsr.py", line 148, in from_satellite_sensor
rsr_dict = RSR_reader(satellite, sensor, subsystem, **kwargs) # (ordered according to LBA)
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/pyrsr/rsr.py", line 75, in RSR_reader
RSR_dict[band] = np.loadtxt(RSR_path, skiprows=1)
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/numpy/lib/npyio.py", line 1067, in loadtxt
fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/numpy/lib/_datasource.py", line 193, in open
return ds.open(path, mode, encoding=encoding, newline=newline)
File "/home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/numpy/lib/_datasource.py", line 533, in open
raise IOError("%s not found." % path)
Exception: /home/gfz-fe/mambaforge/envs/findr/lib/python3.9/site-packages/pyrsr/data/Sentinel-2/MSI/band_1 not found.
Instead, the error message should include something like 'Sentinel-2' is not supported. Choose a satellite out of ...