-
Notifications
You must be signed in to change notification settings - Fork 300
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
Fix seviri_l2_grib end_time property bug. #2943
Conversation
I have a feeling that either pytroll/trollimage#179 or pytroll/trollimage#181 cause the test failure, I created a new release today with these two included. Although there's no new |
Trollimage seems to be coming from PyPI: https://github.com/pytroll/satpy/blob/main/continuous_integration/environment.yaml#L64 @gerritholl could you perhaps have a look at the failing tests that seem to be handling paletted images and enhancement history?
|
I think it should be as simple as updating the expected results. |
Looks like the enhancement test function is used in many places other the two failing tests, so needs a bit more involved solution. I'll have a go. |
A fix attempted in #2944 |
@strandgren the fix to the failing tests has been merged, so please merge |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2943 +/- ##
=======================================
Coverage 96.09% 96.09%
=======================================
Files 377 377
Lines 55070 55074 +4
=======================================
+ Hits 52920 52924 +4
Misses 2150 2150
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 11438867601Details
💛 - Coveralls |
@pnuu Thanks, now the tests passed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can live with this solution :)
However, I want to point out that it feels strange to have a property return different results depending on whether the file has already been open or not. Ideally, the call to end_time
should trigger reading just what is needed in the file to give a sensible result.
But since I don't know the format, I think we can merge this.
Yes I kind of agree, but the metadata are provided for each grib message i.e. dataset meaning that at Scene initialization it would be ambiguous from which message/dataset to read the |
# Check that end_time is None for SEVIRI before the dataset has been loaded | ||
assert reader.end_time is None | ||
|
||
common_checks(ec_, reader, mock_file, dataset_id) | ||
|
||
# Check end_time | ||
# Check that end_time is now a valid datetime.datetime object after the dataset has been loaded | ||
assert reader.end_time == datetime.datetime(year=2020, month=10, day=20, | ||
hour=19, minute=50, second=0) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this test case be split into several specific tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I've been trying to refactor this into something better, but so far with no satisfying results. I have previously created an issue to work on removing the mocking #2932, do you think we could move this test optimization to the PR that will deal with the mocking (since it will anyway lead to quite some refactoring)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds good! Feel free to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Nah, you do it, you're the reviewer ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As described in #2942, the changes in #2717 lead to the
end_time
property not working for SEVIRI data, since we now use the sub-satellite point to determine the scanning mode and thus the temporal resolution used to determine theend_time
from thestart_time
(prior to #2717 it was always set to 15 minutes, which is incorrect for RSS data). However, theself._ssp_lon
attribute is only available after a dataset and its metadata have been loaded and thus anAttributeError
was raised duringScene
initialization. This was not covered by the unit test and a human error lead to the bug being unnoticed also when testing with real data.This PR adapts the
end_time
property to returnNone
if no dataset has been loaded, meaning that_ssp_lon
is not available. As soon as a dataset has been loaded, bothscn.end_time
andscn[dataset].attrs['end_time']
will have valid and correctdatetime.datetime
objects. The unit test has been adapted to cover this bug.seviri_l2_grib
-reader with 'EUML2GribFileHandler' object has no attribute '_ssp_lon' #2942