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

Add combined GRIB reader for both SEVIRI and FCI L2 products #2717

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

Conversation

dnaviap
Copy link

@dnaviap dnaviap commented Jan 11, 2024

Add combined GRIB reader that can be used for both SEVIRI and FCI L2 products.

  • Tests added
  • Fully documented
  • Add @dnaviap to AUTHORS.md

@strandgren
Copy link
Collaborator

Thanks for working on this @dnaviap :) Before reviewing in more detail, I think we need some refactoring of the files:

  1. Instead of having a eum_l2_grib.yaml files I suggest to keep the seviri_l2_grib.yaml file (which is still there) and add the FCI cloud mask dataset in a new fci_l2_grib.yaml file. That way we don't change the user interface to the reader. That's also how it's being done for the BUFR reader (Changes to Eumetsat L2 BUFR reader #2603)
  2. eum_l2_grib.py should be compatible with both FCI and SEVIRI data, meaning that seviri_l2_grib.py should become obsolete and should therefore be removed.
  3. Similarly, the new test file test_eum_l2_grib.py should make test_seviri_l2_grib.py obsolete, meaning it can be removed as well.

@dnaviap
Copy link
Author

dnaviap commented Jan 12, 2024

The refactoring is complete and tested.

Copy link
Collaborator

@strandgren strandgren 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 the refactoring! :) See a couple of comments inline.

Can you please also modify the doc-string of the _scale_earth_axis method to read:

    def _scale_earth_axis(data):
        """Scale Earth axis data to make sure the value matched the expected unit [m].
        
        The earthMinorAxis value stored in the MPEF aerosol over sea product prior to December 12, 2022 has the wrong unit and this method provides a flexible work-around by making sure that all earth axis values are scaled such
        that they are on the order of millions of meters as expected by the reader. 
        
        """

That was a fix implemented by me a while ago when we noticed some issues in one of the products, and although it has been fixed in the product, the archived files will still have the issue meaning that the fix is still useful to have in the reader.

satpy/readers/eum_l2_grib.py Outdated Show resolved Hide resolved
satpy/readers/fci_base.py Outdated Show resolved Hide resolved
satpy/tests/reader_tests/test_eum_l2_grib.py Outdated Show resolved Hide resolved
@dnaviap
Copy link
Author

dnaviap commented May 13, 2024

Thanks for the refactoring! :) See a couple of comments inline.

Can you please also modify the doc-string of the _scale_earth_axis method to read:

    def _scale_earth_axis(data):
        """Scale Earth axis data to make sure the value matched the expected unit [m].
        
        The earthMinorAxis value stored in the MPEF aerosol over sea product prior to December 12, 2022 has the wrong unit and this method provides a flexible work-around by making sure that all earth axis values are scaled such
        that they are on the order of millions of meters as expected by the reader. 
        
        """

That was a fix implemented by me a while ago when we noticed some issues in one of the products, and although it has been fixed in the product, the archived files will still have the issue meaning that the fix is still useful to have in the reader.

@dnaviap dnaviap closed this May 13, 2024
@dnaviap dnaviap reopened this May 13, 2024
Copy link
Collaborator

@strandgren strandgren 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 the fixes and the refactoring @dnaviap!

I left a couple of minor comments in-line. Could you please also merge the main branch into this branch and resolve the merge conflict such that all unit tests etc. run?

satpy/readers/eum_l2_grib.py Outdated Show resolved Hide resolved
satpy/readers/eum_l2_grib.py Outdated Show resolved Hide resolved
satpy/tests/reader_tests/test_eum_l2_grib.py Outdated Show resolved Hide resolved
strandgren and others added 4 commits June 13, 2024 14:05
@dnaviap dnaviap requested a review from sjoro as a code owner June 24, 2024 08:43
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.95%. Comparing base (fc95ee1) to head (12f1860).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2717      +/-   ##
==========================================
+ Coverage   95.94%   95.95%   +0.01%     
==========================================
  Files         366      368       +2     
  Lines       53584    53671      +87     
==========================================
+ Hits        51412    51501      +89     
+ Misses       2172     2170       -2     
Flag Coverage Δ
behaviourtests 4.03% <0.00%> (-0.01%) ⬇️
unittests 96.05% <100.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

coveralls commented Jul 1, 2024

Pull Request Test Coverage Report for Build 9743868855

Details

  • 168 of 168 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 96.056%

Totals Coverage Status
Change from base Build 9702977764: 0.01%
Covered Lines: 51732
Relevant Lines: 53856

💛 - 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.

Nice work, just a couple of comments and questions

from satpy.tests.utils import make_dataid


class TestCalculateAreaExtent(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

We try to go over to pytest nowadays, rather that using unittest...

Suggested change
class TestCalculateAreaExtent(unittest.TestCase):
class TestCalculateAreaExtent:

Comment on lines +63 to +71
class TestEUML2GribFileHandler(unittest.TestCase):
"""Test the EUML2GribFileHandler reader."""

@mock.patch("satpy.readers.eum_l2_grib.ec")
def setUp(self, ec_):
"""Set up the test by creating a mocked eccodes library."""
fake_gid_generator = (i for i in FAKE_GID)
ec_.codes_grib_new_from_file.side_effect = lambda fh: next(fake_gid_generator)
self.ec_ = ec_
Copy link
Member

Choose a reason for hiding this comment

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

We try to go over to pytest nowadays, rather that using unittest. Could you convert this to pytest style instead?

Comment on lines +109 to +110
@mock.patch("satpy.readers.eum_l2_grib.xr")
@mock.patch("satpy.readers.eum_l2_grib.da")
Copy link
Member

Choose a reason for hiding this comment

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

I see a bit of mocking. In our experience this can lead to problems down the road, and nowadays, we prefer to write a synthetic testing file to tmp_path and work with that instead. Do you think this would be doable for this format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants