pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.04k stars 287 forks source link

Add option to choose start time to MSI SAFE reader #2776

Closed simonrp84 closed 1 month ago

simonrp84 commented 2 months ago

Currently, the msi_safe reader uses the filename_info to get the start_time for a Scene. This can be problematic as multiple tiles can have the same start_time and will hence overwrite each other:

for files in [[tile1_files], [tile2_files]]:
   scn = Scene(files, reader='msi_safe')
   scn.load(['true_color'])
   scn.save_dataset('true_color')

The user would expect that two images are produced from this, one from each set of files. However, in many cases the second tile will overwrite the image saved by the first.

This PR attempts to fix the problem by allowing an optional reader_kwarg that allows the user to specify that the start_time should be read from the tile metadata rather than the filename:

for files in [[tile1_files], [tile2_files]]:
   scn = Scene(files, reader='msi_safe', reader_kwargs={'use_tile_time': True})
   scn.load(['true_color'])
   scn.save_dataset('true_color')

This will generate two output images as expected.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.57%. Comparing base (1742616) to head (3aea6ea). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2776 +/- ## ========================================== - Coverage 95.95% 94.57% -1.38% ========================================== Files 379 379 Lines 53861 53876 +15 ========================================== - Hits 51680 50952 -728 - Misses 2181 2924 +743 ``` | [Flag](https://app.codecov.io/gh/pytroll/satpy/pull/2776/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | Coverage Δ | | |---|---|---| | [behaviourtests](https://app.codecov.io/gh/pytroll/satpy/pull/2776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `4.09% <0.00%> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/pytroll/satpy/pull/2776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `95.16% <100.00%> (-0.89%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 9020466876

Details


Totals Coverage Status
Change from base Build 9020304102: 0.003%
Covered Lines: 51568
Relevant Lines: 53699

💛 - Coveralls