-
Notifications
You must be signed in to change notification settings - Fork 288
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 Sun-Earth distance corrector utility and apply in SEVIRI readers #1341
Add Sun-Earth distance corrector utility and apply in SEVIRI readers #1341
Conversation
…is in the solar irradiance value.
…lculating reflectances in the solar channels.
…calculating the reflectance for a given band.
Codecov Report
@@ Coverage Diff @@
## master #1341 +/- ##
==========================================
+ Coverage 90.24% 90.37% +0.13%
==========================================
Files 222 228 +6
Lines 32719 33068 +349
==========================================
+ Hits 29526 29886 +360
+ Misses 3193 3182 -11
Continue to review full report at Codecov.
|
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.
Looks good so far, just a couple of programmatic corrections I'd like to see included here. Otherwise, I think you missed _vis_calibrate
usages in reader_tests
and in seviri_l1b_nc
.
…ime if included in the xarray data. Otherwise, fall back to value being passed or raise an error.
The preferred way to access dataarray attributes is |
Fixed :-) |
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.
Now that the code works, let's refactor to make it right :)
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.
Very nice feature, thanks! A couple of questions and comments.
Also pinging @ninahakansson here, as this might be relevant in level1c4pps |
Thanks @sfinkens for notifying me. At the moment in level1c4pps assume that sun-earth distance correction is not applied for SEVIRI, so this need to be updated when this is merged to satpy. |
I just pushed some changes that are not yet complete, as my git skills are low and I want to transfer my code changes between home and office :-) Will complete the updates after review ASAP. |
… function to retrieve UTC time. Also restructure appropriate tests into a class.
… correction is applied and, if so, what the Sun-Earth distance is.
…by the Sun-Earth distance correction.
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
utc_date = get_array_date(reflectance, utc_date) | ||
sun_earth_dist = sun_earth_distance_correction(utc_date) | ||
|
||
reflectance.attrs['sun_earth_distance_correction_applied'] = False |
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.
@ninahakansson You can use these attributes in level1c4pps
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
@simonrp84 one last thing: could you mention in the module docstrings of the seviri readers that earth-sun distance correction is now applied? |
…stance correction is taken into account when computing reflectances.
@mraspaud Ok, this is done now! |
Perfect. Merging this when the tests pass. |
The distance between the sun and the Earth varies slightly during the year due to the Earth's orbital eccentricity. This means that the incoming solar irradiance, and hence outgoing radiance measured by a satellite sensor, also varies throughout the year as a function of day.
Many sensors do not account for this in their L1 data products, so a correction must be applied.
As an example, for SEVIRI:
Where:
se_dist
is the Sun-Earth distance on a given day.radiance
is the satellite-measured pixel radiance.solar_irradiance
is the average solar irradiance for the band.solar_zenith
is the solar zenith angle (with nadir = 0) for a given pixel.Currently, the SEVIRI reader (and possibly others too) doesn't apply the
se_dist
factor, and therefore the reflectances given by satpy are slightly incorrect (by up to ~4%).This PR creates a utility function
apply_earthsun_distance_correction
that applies the correction. It also adds this function to the SEVIRI calibration code and adds the various test functions to ensure everything works.In addition, a
remove_earthsun_distance_correction
function is also supplied for the case that a user wishes to remove the correction.flake8 satpy