Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RSR band name retrieval for unconfigured sensors #158

Merged
merged 4 commits into from
Sep 28, 2022

Conversation

djhoese
Copy link
Member

@djhoese djhoese commented Sep 28, 2022

This adds the missing configuration for mapping MERSI-2 band names to the names used in the RSR files. It is basically "ruined" by the generic mapping mapping numeric band names to ch{:d}. This isn't the case for MERSI-2 which uses the same band name.

It turns out MERSI-2 does use the chN names in the RSR HDF5 files, but since it wasn't configured an if statement in the RSR Reader was failing with a KeyError before it was supposed to. This PR should fix this so that the "generic" band names are used as a fallback.

  • Closes #xxxx
  • Tests added
  • Tests passed: Passes pytest pyspectral
  • Passes flake8 pyspectral
  • Fully documented

@djhoese djhoese added the bug label Sep 28, 2022
@djhoese djhoese self-assigned this Sep 28, 2022
@codecov
Copy link

codecov bot commented Sep 28, 2022

Codecov Report

Merging #158 (7152c17) into main (4224191) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #158      +/-   ##
==========================================
+ Coverage   88.00%   88.02%   +0.01%     
==========================================
  Files          22       22              
  Lines        2468     2472       +4     
==========================================
+ Hits         2172     2176       +4     
  Misses        296      296              
Flag Coverage Δ
unittests 88.02% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pyspectral/rsr_reader.py 77.99% <100.00%> (ø)
pyspectral/tests/test_rsr_reader.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@djhoese
Copy link
Member Author

djhoese commented Sep 28, 2022

I manually checked the HDF5 file and it seems like it is using the chN format of variable names, but with or without this PR I'm still getting these warnings:

WARNING  : Could not get the reflectance correction using band name: 1
WARNING  : Will try use the wavelength, however, this may be ambiguous!
WARNING  : A wavelength is provided instead of band name - disregard the relative spectral responses and assume it is the effective wavelength: 0.470000 (micro meter)

@djhoese djhoese changed the title Add missing MERSI-2 band name conversions Fix RSR band name retrieval for unconfigured sensors Sep 28, 2022
@adybbroe
Copy link
Collaborator

I manually checked the HDF5 file and it seems like it is using the chN format of variable names, but with or without this PR I'm still getting these warnings:

WARNING  : Could not get the reflectance correction using band name: 1
WARNING  : Will try use the wavelength, however, this may be ambiguous!
WARNING  : A wavelength is provided instead of band name - disregard the relative spectral responses and assume it is the effective wavelength: 0.470000 (micro meter)

@djhoese
This is from Satpy right? Just to be clear. We should change a logger.warningto a logger.exception instead I think!
That would help quite a bit in debugging Pyspectral. wouldn't it?

Copy link
Collaborator

@adybbroe adybbroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@djhoese
Copy link
Member Author

djhoese commented Sep 28, 2022

Yes, from Satpy. I don't think changing that logger is a good long term idea. I did actually add exc_info=True to the existing warning to find the exact exception location in pyspectral. I see that as a one time thing, especially considering this error is semi-expected for any sensors that aren't configured and don't have conversions in the generic dictionary.

Thanks for reviewing.

@djhoese djhoese merged commit 28b322c into pytroll:main Sep 28, 2022
@djhoese djhoese deleted the bugfix-mersi2-bandnames branch September 28, 2022 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants