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

Bugfix for Sentinel-2 radiance calculation #2896

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

simonrp84
Copy link
Member

@simonrp84 simonrp84 commented Sep 5, 2024

This PR fixes the radiance calculation for Sentinel-2 data. Currently, the code uses the method suitable for L1b counts -> radiance computation. However, L1b data is not (yet) available to users and the procedure is different for L1c data that's available via the Copernicus data ecosystem.

This PR switches to use the correct calculation.

In addition, I made some changes to the reader code in preparation for the upcoming availability of L1B data for Sentinel-2. This data isn't yet supported by the reader, though, so I have added an explicit error message / reader failure mode if the user tries to process L1B data.

  • Tests added
  • Fully documented

@simonrp84 simonrp84 marked this pull request as ready for review September 6, 2024 14:41
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 94.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.05%. Comparing base (5e27be4) to head (38a05d1).
Report is 92 commits behind head on main.

Files with missing lines Patch % Lines
satpy/readers/msi_safe.py 91.42% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2896   +/-   ##
=======================================
  Coverage   96.05%   96.05%           
=======================================
  Files         370      370           
  Lines       54320    54356   +36     
=======================================
+ Hits        52177    52212   +35     
- Misses       2143     2144    +1     
Flag Coverage Δ
behaviourtests 3.99% <0.00%> (-0.01%) ⬇️
unittests 96.15% <94.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10740356237

Details

  • 48 of 51 (94.12%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 96.152%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/readers/msi_safe.py 33 36 91.67%
Files with Coverage Reduction New Missed Lines %
satpy/readers/msi_safe.py 7 94.84%
Totals Coverage Status
Change from base Build 10704576446: -0.01%
Covered Lines: 52443
Relevant Lines: 54542

💛 - Coveralls

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

Thanks for this, some comments inline.

Comment on lines +112 to +114
#else:
# For L1B the radiances can be directly computed from the digital counts.
#return self._mda.calibrate_to_radiances_l1b(proj, self._channel)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to leave that there as a placeholder. Soon the L1b data will be made available to users, and this section of code will then become useful :-)

Copy link
Member

Choose a reason for hiding this comment

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

Can we uncomment it then?

if irrads is not None:
solar_irrad = {int(irr.attrib["bandId"]): float(irr.text) for irr in irrads}
else:
solar_irrad = {}
Copy link
Member

Choose a reason for hiding this comment

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

Can this be tested?

sed = self.root.find(".//U")
if sed is not None:
return float(sed.text)
return -1
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really found of this. Would it be possible to raise an error here and catch it downstream?

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.

3 participants