pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.05k stars 289 forks source link

Incorrect error message when calibration key unknown #1252

Closed gerritholl closed 4 years ago

gerritholl commented 4 years ago

Describe the bug

Satpy gives a misleading error message when I'm trying to load a channel with a calibration (or other parameter) that is invalid.

To Reproduce

from satpy import Scene
from glob import glob
sc = Scene(filenames=glob("/data/gholl/cache/fogtools/abi/2020/04/12/01/C*/OR_ABI-L1b-RadM1-M6C*_G16_s20201030117217_e*_c*.nc"), reader="abi_l1b")
sc.load(["C08"], calibration="brightn")

Expected behavior

I would expect to be told that "brightn" is not a valid calibration. Or more generically and realistically, with #1088, I expect to be informed that there are no results for the DataQuery(name="C08", calibration="brightn"). I've also tested it with #1088. When I explicitly construct the DataQuery I get:

Traceback (most recent call last):
  File "mwe66.py", line 4, in <module>
    sc.load([DataQuery(name="C08", calibration="brightn")])
  File "/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/satpy/scene.py", line 975, in load
    raise KeyError("Unknown datasets: {}".format(unknown_str))
KeyError: "Unknown datasets: DataQuery(name='C08', calibration='brightn')"

Perhaps #1088 should turn every index, whether by string (name), number (wavelength) or otherwise into a DataQuery. That way the KeyError would turn into the one above and the error message would be more correct.

Actual results

I'm told that dataset 'C08' is unknown, which is simply not true.

Traceback (most recent call last):
  File "mwe66.py", line 4, in <module>
    sc.load(["C08"], calibration="brightn")
  File "/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/satpy/scene.py", line 975, in load
    raise KeyError("Unknown datasets: {}".format(unknown_str))
KeyError: 'Unknown datasets: C08'

Environment Info:

Tried with both Satpy master (0.22.1.dev14+gb909413f) as well as the latest commit on #1088 (0.21.1.dev398+gaa8c5e30).

djhoese commented 4 years ago

Duplicate of #1220