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

Harmonize calibration in SEVIRI readers #1457

Merged
merged 27 commits into from Dec 16, 2020

Conversation

sfinkens
Copy link
Member

@sfinkens sfinkens commented Nov 27, 2020

Harmonize calibration in the SEVIRI HRIT, Native and netCDF format readers:

  • All readers now accept an ext_calib_coefs kwarg for external calibration coefficients. Switching between nominal and GSICS calibration mode is possible for HRIT and Native. netCDF files only provides one set of coefficients.
  • Move calibration to independent classes
    1. SEVIRICalibrationAlgorithm which provides the fundamental calibration algorithms
    2. SEVIRICalibrationHandler which handles selection of calibration coefficients and calls the appropriate
      calibration algorithm.
  • Move calibration from get_dataset to a dedicated calibrate method, which uses _get_calib_coefs to read coefficients from the file and passes them to the calibration handler. The file handlers do not inherit from the calibration class anymore. That resolves the problem of the calibration class expecting the file handler to set certain attributes (for example Standardise self.mda for SEVIRI attributes #722).

In order to ensure code integrity, comprehensive calibration tests have been added before refactoring.

TODO:

  • Fix/Remove old calibration tests
  • Add tests for coefficient selection
  • Update documentation

  • Tests added
  • Passes flake8 satpy
  • Fully documented

@sfinkens sfinkens added this to To Do in PCW Autumn 2020 Nov 30, 2020
@sfinkens sfinkens changed the title Harmonize SEVIRI HRIT and Native format readers Harmonize SEVIRI HRIT/Native/NC readers Nov 30, 2020
@sfinkens sfinkens moved this from To Do to In Progress in PCW Autumn 2020 Nov 30, 2020
@sfinkens sfinkens changed the title Harmonize SEVIRI HRIT/Native/NC readers Harmonize calibration in SEVIRI HRIT/Native/NC readers Nov 30, 2020
@sfinkens sfinkens changed the title Harmonize calibration in SEVIRI HRIT/Native/NC readers Harmonize calibration in SEVIRI readers Nov 30, 2020
@ghost
Copy link

ghost commented Dec 1, 2020

Congratulations 🎉. DeepCode analyzed your code in 7.357 seconds and we found no issues. Enjoy a moment of no bugs ☀️.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

@codecov
Copy link

codecov bot commented Dec 1, 2020

Codecov Report

Merging #1457 (1f7d05b) into master (64fc4ef) will increase coverage by 0.08%.
The diff coverage is 96.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1457      +/-   ##
==========================================
+ Coverage   90.78%   90.87%   +0.08%     
==========================================
  Files         241      241              
  Lines       35111    35113       +2     
==========================================
+ Hits        31876    31908      +32     
+ Misses       3235     3205      -30     
Flag Coverage Δ
behaviourtests 4.49% <0.00%> (-0.01%) ⬇️
unittests 91.34% <96.41%> (+0.08%) ⬆️

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

Impacted Files Coverage Δ
satpy/tests/reader_tests/test_seviri_base.py 100.00% <ø> (ø)
satpy/readers/seviri_l1b_hrit.py 90.87% <72.72%> (-1.03%) ⬇️
satpy/readers/seviri_base.py 95.26% <100.00%> (+1.61%) ⬆️
satpy/readers/seviri_l1b_native.py 79.31% <100.00%> (+0.93%) ⬆️
satpy/readers/seviri_l1b_nc.py 50.00% <100.00%> (+6.89%) ⬆️
.../tests/reader_tests/test_seviri_l1b_calibration.py 100.00% <100.00%> (+3.27%) ⬆️
satpy/tests/reader_tests/test_seviri_l1b_hrit.py 100.00% <100.00%> (ø)
satpy/tests/reader_tests/test_seviri_l1b_native.py 99.41% <100.00%> (+4.33%) ⬆️
satpy/tests/reader_tests/test_seviri_l1b_nc.py 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64fc4ef...1f7d05b. Read the comment docs.

@sfinkens sfinkens marked this pull request as ready for review December 1, 2020 14:00
@sfinkens sfinkens self-assigned this Dec 1, 2020
@sfinkens sfinkens added component:readers enhancement code enhancements, features, improvements labels Dec 1, 2020
satpy/readers/seviri_base.py Outdated Show resolved Hide resolved
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.

Very good work on refactoring all the calibration and tests into a common ground for the various seviri reader! I have a few style comment, but otherwise LGTM!

satpy/readers/seviri_base.py Outdated Show resolved Hide resolved
satpy/readers/seviri_l1b_hrit.py Outdated Show resolved Hide resolved
satpy/readers/seviri_l1b_native.py Outdated Show resolved Hide resolved
satpy/readers/seviri_base.py Outdated Show resolved Hide resolved
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.

LGTM, thanks for the comprehensive overhaul of the tests!

PCW Autumn 2020 automation moved this from Needs Review to Approved Dec 8, 2020
Copy link
Member

@ameraner ameraner left a comment

Choose a reason for hiding this comment

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

Looks very good to me! Thanks for sorting this out.

PS: first time I see np.choose being used, nice!

Copy link
Collaborator

@sjoro sjoro left a comment

Choose a reason for hiding this comment

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

looks good to me! very nice restructuring, the logic is a lot easier to follow now. thanks a lot for putting in the effort on sorting this out!

Copy link
Member

@simonrp84 simonrp84 left a comment

Choose a reason for hiding this comment

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

Nice work, @sfinkens! I have two relatively minor comments, otherwise all looks good.

satpy/readers/seviri_base.py Outdated Show resolved Hide resolved
satpy/readers/seviri_l1b_hrit.py Show resolved Hide resolved
Furthermore, add HRV calibration tests
Check if they are zero instead of checking the channel name.
@sfinkens
Copy link
Member Author

Looks like the undefined loop variable warning from CodeFactor was already there in #1438 (https://github.com/pytroll/satpy/pull/1438/checks?check_run_id=1525081771). @strandgren Was that intended?

@strandgren
Copy link
Collaborator

Looks like the undefined loop variable warning from CodeFactor was already there in #1438 (https://github.com/pytroll/satpy/pull/1438/checks?check_run_id=1525081771). @strandgren Was that intended?

Yes, because there is a check in the ImageBoundaries class to make sure that the image boundaries are valid. So there should be no risk that these variables are undefined. We agreed on that this solves the problem, but that the bots cannot follow the solution.

This is also a good place for the common documentation.
- Move common documentation to seviri_base module

Main documentation:
- Create separate section for SEVIRI L1.5 readers
- Include seviri_base as well as all L1.5 readers
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.

Looks great, thanks for adding the docstrings to the main documentation.

@mraspaud mraspaud merged commit 45843de into pytroll:master Dec 16, 2020
PCW Autumn 2020 automation moved this from Approved to Done Dec 16, 2020
@sfinkens sfinkens deleted the feature-align-seviri-readers branch December 16, 2020 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:readers enhancement code enhancements, features, improvements
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants