8000 Updated the grid size to read claas3 data by jequierz · Pull Request #3084 · pytroll/satpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updated the grid size to read claas3 data #3084

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jequierz
Copy link
I have updated the cmsaf_claas2 reader so that it handles now the larger grid of the claas3 (changed from 3636x3636 to 3712x3712).
  • Closes #xxxx
  • Tests added
  • Fully documented
  • Add your name to AUTHORS.md if not there already

@sfinkens
Copy link
Member

Tests fail, because the dummy file we use for testing doesn't have coordinates. That's actually a valuable feedback, because we can make the check a little simpler:

self.grid_size = self.file_content["/dimension/y"]

Then the tests will fail again, because the area definition from the (2x2) test file doesn't match the (3636x3636) expectation any more. Let me know when you are at this point, then we can continue together.

@sfinkens
Copy link
Member

Here's a proposal for an updated test that runs for two time stamps and two grid sizes

class TestAreaDef:
    @pytest.fixture(params=[3636, 3712])
    def grid_size(self, request):
        return request.param

    @pytest.fixture
    def fake_file(self, fake_dataset, encoding, tmp_path, start_time, grid_size):
        """Write a fake dataset to file.

        Only add y dimension, so that the file is small but we can still check the
        real-life area definition.
        """
        filename = tmp_path / "CPPin20140101001500305SVMSG01MD.nc"
        ds = netCDF4.Dataset(filename, mode="w")
        ds.createDimension("y", grid_size)
        ds.setncattr("time_coverage_start", start_time.strftime("%Y%m%dT%H%MZ"))
        ds.close()
        return filename

    @pytest.fixture
    def file_handler(self, fake_file):
        """Return a CLAAS-2 file handler."""
        from satpy.readers.cmsaf_claas2 import CLAAS2
        return CLAAS2(fake_file, {}, {})

    @pytest.fixture
    def area_extent_exp(self, start_time, grid_size):
        """Get expected area extent."""
        if start_time < datetime.datetime(2017, 12, 6):
            extents = {
                3636: (-5454733.160460291, -5454733.160460292, 5454733.160460292, 5454733.160460291),
                3712: (-5568748.485046371, -5568748.485046371, 5568748.485046371, 5568748.485046371)
            }
        else:
            extents = {
                3636: (-5456233.362099582, -5453232.958821001, 5453232.958821001, 5456233.362099582),
                3712: (-5570248.686685662, -5567248.28340708, 5567248.28340708, 5570248.686685662)
            }
        return extents[grid_size]

    @pytest.fixture
    def area_exp(self, area_extent_exp, grid_size):
        """Get expected area definition."""
        proj_dict = {
            "a": 6378169.0,
            "b": 6356583.8,
            "h": 35785831.0,
            "lon_0": 0.0,
            "proj": "geos",
            "units": "m",
        }
        return AreaDefinition(
            area_id="msg_seviri_fes_3km",
            description="MSG SEVIRI Full Earth Scanning service area definition with 3 km resolution",
            proj_id="geos",
            projection=proj_dict,
            area_extent=area_extent_exp,
            width=grid_size,
            height=grid_size,
        )

    def test_get_area_def(self, file_handler, area_exp):
        """Test area definition."""
        area = file_handler.get_area_def(make_dataid(name="foo"))
        assert area == area_exp

"""Test end time property."""
assert file_handler.end_time == datetime.datetime(2085, 8, 13, 13, 15)

class TestAreaDef:
Copy link
Member

Choose a reason for hiding this comment

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

I think you just need to add a docstring for this class to make ruff happy, see

https://results.pre-commit.ci/run/github/51397392/1744803645.EteACOctTJiZK_OgSV2njA

Copy link
Member

Choose a reason for hiding this comment

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

Ok, more docstring problems reported by ruff. Try installing pre-commit hooks in your working copy

pip install ruff pre-commit
pre-commit install
ruff check test_cmsaf_claas.py

Copy link
codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.17%. Comparing base (21d1739) to head (5a1cd87).
Report is 184 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3084      +/-   ##
==========================================
+ Coverage   96.14%   96.17%   +0.02%     
==========================================
  Files         383      391       +8     
  Lines       55800    56653     +853     
==========================================
+ Hits        53651    54486     +835     
- Misses       2149     2167      +18     
Flag Coverage Δ
behaviourtests 3.82% <0.00%> (-0.07%) ⬇️
unittests 96.26% <100.00%> (+0.02%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

2 participants
0