-
Notifications
You must be signed in to change notification settings - Fork 303
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
Add support to Pyspectral NIRReflectance masking limit #1390
Add support to Pyspectral NIRReflectance masking limit #1390
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1390 +/- ##
=========================================
Coverage ? 90.57%
=========================================
Files ? 228
Lines ? 33430
Branches ? 0
=========================================
Hits ? 30278
Misses ? 3152
Partials ? 0
Continue to review full report at Codecov.
|
Before I forget. This test tested that the default keyword argument should not be |
@pnuu this is the reason for that test: 53620fd#diff-c3f713f166b7940f26ca41873bcd1890R650-R655 |
if self.sun_zenith_threshold is not None: | ||
reflectance_3x_calculator = Calculator(metadata['platform_name'], metadata['sensor'], metadata['name'], | ||
sunz_threshold=self.sun_zenith_threshold) | ||
else: | ||
reflectance_3x_calculator = Calculator(metadata['platform_name'], metadata['sensor'], metadata['name']) | ||
self.sun_zenith_threshold = reflectance_3x_calculator.sunz_threshold | ||
reflectance_3x_calculator = Calculator(metadata['platform_name'], metadata['sensor'], metadata['name'], | ||
sunz_threshold=self.sun_zenith_threshold, | ||
masking_limit=self.masking_limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is right. When self.sun_zenith_threshold
is None, we want to replace it with the default value from the calculator.
This was what #1319 was about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. That sounds wrong. I'd expect None
to mean "do not apply SZA correction in the Calculator". I'd just fix the documentation to say If not explicitly specified, the default value defined in Pyspectral will be used.
But anyway, the behaviour on the Satpy side doesn't change: the default value is used if the user doesn't override it. If the user decides to override the default with None
, they'll probably know what they are doing (which is, crash the code 😁).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, just change the __init__
docstring then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring updated. Good thing, as I didn't remember to add the new kwarg there before.
... which was because Satpy didn't respect the default and overrode it with |
Last question (maybe :) ): Should we use the pyspectral default or prevent potential problems if pyspectral is modified and hardcode a satpy-specific set of limits? |
I thought about that. Now that you raise the point again, I think that would make more sense than importing from Pyspectral. It would also make testing more explicit. I'll add Satpy-internal thresholds for these two arguments. Any suggestions what the default for |
ok, what if the masking limit is beyond the sunz_threshold, would that have the same effect as |
It behaves the same as long as there's overlap between the two composites. It seems the default blending in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one stylistic question
satpy/composites/__init__.py
Outdated
NIR_REFLECTANCE_TERMINATOR_LIMIT = 85.0 | ||
NIR_REFLECTANCE_MASKING_LIMIT = 88.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to keep things gathered in the same place, would it be worth have these at class attributes to NIRReflectance
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Update follows in a minute or three.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code and tests updated, tested with real data.
Just as a reminder: the Pyspectral PR pytroll/pyspectral#113 needs to be merged (and released) first for this to be usable. |
Probably one more thing to do here is to set the minimal version of pyspectral in setup.py |
Agreed. That'll need the new Pyspectral release to see the actual version number. |
Pyspectral version requirement updated to the release made yesterday. |
This PR isn't blocked anymore by the Pyspectral PR which has been merged and released. |
This is adds support to
masking_limit
keyword argument forNIRReflectance
modifier added in pytroll/pyspectral#113flake8 satpy
I'm not sure where to document this feature, but the usage shown below.
This disables the masking altogether. See pytroll/pyspectral#113 for an example image. This is the old default behaviour, which was changed in Pyspectral May (pytroll/pyspectral@e9a234f#diff-2a5232e6ece84bcd6cc7c97d82a7a574).
And definition of a specific masking limit:
The default is to mask with the default limit defined in
pyspectral.near_infrared_reflectance.TERMINATOR_LIMIT
, which is also the current behaviour.