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

Adapt the SEVIRI native format reader in Satpy to support remote reading #2863

Merged
merged 22 commits into from
Aug 14, 2024

Conversation

pkhalaj
Copy link
Contributor

@pkhalaj pkhalaj commented Jul 26, 2024

This PR adds a feature to Satpy to allow for reading SEVIRI native format files remotely. It relies on the fsspec package.

  • Closes #xxxx
  • Tests added
  • Fully documented
  • Add your name to AUTHORS.md if not there already

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

Attention: Patch coverage is 96.72131% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.03%. Comparing base (b25107d) to head (d22d2b6).
Report is 1 commits behind head on main.

Files Patch % Lines
satpy/readers/seviri_l1b_native.py 81.81% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2863      +/-   ##
==========================================
+ Coverage   95.97%   96.03%   +0.05%     
==========================================
  Files         368      368              
  Lines       53973    54057      +84     
==========================================
+ Hits        51801    51914     +113     
+ Misses       2172     2143      -29     
Flag Coverage Δ
behaviourtests 4.01% <0.00%> (-0.01%) ⬇️
unittests 96.13% <96.72%> (+0.05%) ⬆️

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 26, 2024

Pull Request Test Coverage Report for Build 10382915666

Details

  • 118 of 122 (96.72%) changed or added relevant lines in 3 files are covered.
  • 8 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.05%) to 96.132%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/readers/seviri_l1b_native.py 18 22 81.82%
Files with Coverage Reduction New Missed Lines %
satpy/tests/utils.py 2 93.16%
satpy/tests/reader_tests/gms/test_gms5_vissr_l1b.py 3 98.67%
satpy/tests/reader_tests/gms/test_gms5_vissr_navigation.py 3 97.18%
Totals Coverage Status
Change from base Build 10303695673: 0.05%
Covered Lines: 52143
Relevant Lines: 54241

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

Very nice so far, it's really good to have an actual file to test the reader on now.

AUTHORS.md Show resolved Hide resolved
satpy/readers/seviri_l1b_native.py Outdated Show resolved Hide resolved
satpy/tests/reader_tests/test_seviri_l1b_native.py Outdated Show resolved Hide resolved
satpy/tests/reader_tests/test_seviri_l1b_native.py Outdated Show resolved Hide resolved
pkhalaj added a commit to pkhalaj/satpy that referenced this pull request Jul 29, 2024
pkhalaj added a commit to pkhalaj/satpy that referenced this pull request Jul 29, 2024
@pkhalaj pkhalaj force-pushed the feature/read_remote_seviri_native branch from ea8524e to 455d4a8 Compare July 29, 2024 08:43
@pkhalaj pkhalaj marked this pull request as ready for review July 29, 2024 08:44
@pkhalaj pkhalaj requested a review from mraspaud July 29, 2024 08:44
@mraspaud mraspaud requested a review from ameraner July 29, 2024 10:48
@pkhalaj pkhalaj marked this pull request as draft July 29, 2024 11:22
@pkhalaj pkhalaj marked this pull request as ready for review July 29, 2024 11:33
@sfinkens
Copy link
Member

Nice work, thanks a lot! Can you please update the fsspec support column for this reader in the reader table?

@pkhalaj
Copy link
Contributor Author

pkhalaj commented Jul 29, 2024

Nice work, thanks a lot! Can you please update the fsspec support column for this reader in the reader table?

Thanks. Yes, I just did that!

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.

LGTM, just a question on the lazyness when switching from memmap to frombuffer.

satpy/readers/seviri_l1b_native.py Outdated Show resolved Hide resolved
@pkhalaj pkhalaj force-pushed the feature/read_remote_seviri_native branch from 2b9eca8 to 9fc2a05 Compare July 31, 2024 14:06
This function uses `readers.utils.generic_open()` and `np.frombuffer()` to achieve this.
In particular, the following functions/methods have been modified:
- `has_archive_header()` now uses `readers.utils.generic_open()` instead of `open()`.
- `read_header()` now uses `readers.utils.fromfile()` instead of `np.formfile()`.
- `NativeMSGFileHandler._read_trailer()` now uses `readers.utils.fromfile()` instead of `np.formfile()`.
- `NativeMSGFileHandler._get_memmap()` has been renamed to `NativeMSGFileHandler._get_array()` and now uses `readers.utils.fromfile()` instead of `np.memmap()`.
Reason: since `NativeMSGFileHandler._get_memmap()` has been renamed to `NativeMSGFileHandler._get_array()`.
This includes generating an actual file on disk and attempt to read it.
This concerns `test_read_physical_seviri_nat_file()`.
This is to ensure that the remote reading tests can also run on Windows.
Note: `fsspec` expects a POSIX path.
…unknown marks

We do not need these marks anymore, as we decreased the size of the generated seviri native file. As a result, the tests now run fast enough.
This warning is totally benign. It is caused as a result of the seviri native file that we create which is essentially filled with zeros.
The issue was an unexpected indentation on the last line of the docstring!
This includes:
- Extracting the `_get_array()` method so that it is now a function in the module and not a class method.
- Introduction of `NativeMSGFileHandler_make_dask_array_with_map_blocks()` method to utilize the dask `map_blocks()`.
- Introduction of a new method, namely `NativeMSGFileHandler._number_of_visir_channels` to facilitate testing and mock patching.
- Adapting the mock patches in tests accordingly.
@pkhalaj pkhalaj force-pushed the feature/read_remote_seviri_native branch from 9fc2a05 to 80f3925 Compare August 12, 2024 07:21
@mraspaud
Copy link
Member

@ameraner @djhoese do you have time to have a quick look at this and tell us if you agree with the new map_blocks usage?

@djhoese djhoese added enhancement code enhancements, features, improvements component:readers labels Aug 12, 2024
satpy/readers/seviri_l1b_native.py Outdated Show resolved Hide resolved
satpy/readers/seviri_l1b_native.py Outdated Show resolved Hide resolved
satpy/readers/seviri_l1b_native.py Show resolved Hide resolved
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.

LGTM, thanks for the updates!

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

As much as I understand of this, it looks good enough to me. Thanks for putting all this work into it.

@djhoese
Copy link
Member

djhoese commented Aug 14, 2024

Oh CodeScene doesn't like how long the test module is. Any chance things can be refactored?

@mraspaud
Copy link
Member

Oh CodeScene doesn't like how long the test module is. Any chance things can be refactored?

Yes, we talked about this, and decided it was a job for another PR, as what would make the module smaller it so redo the mocking tests into tests using the actual file.
So I'm merging this.

@mraspaud mraspaud merged commit 82d8ef3 into pytroll:main Aug 14, 2024
16 of 18 checks passed
@pkhalaj pkhalaj deleted the feature/read_remote_seviri_native branch August 14, 2024 09:13
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
None yet
Development

Successfully merging this pull request may close these issues.

6 participants