-
Notifications
You must be signed in to change notification settings - Fork 303
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
Change combine_metadata to average any 'time' fields #473
Conversation
Observation time, which was used previously, varies between bands and can make compositing difficult (no resulting start_time). This uses the scheduled time of the image which should be the same for all bands for a particular region/sector.
I just realized that the This makes me think we need to modify the metadata merging functions so that they are semi-aware of |
Codecov Report
@@ Coverage Diff @@
## master #473 +/- ##
==========================================
+ Coverage 73.57% 73.96% +0.38%
==========================================
Files 135 136 +1
Lines 17833 17954 +121
==========================================
+ Hits 13121 13280 +159
+ Misses 4712 4674 -38
Continue to review full report at Codecov.
|
satpy/dataset.py
Outdated
if sys.version_info < (3, 3): | ||
# timestamp added in python 3.3 | ||
import time | ||
timestamp_func = lambda x: time.mktime(x.timetuple()) |
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.
E731 do not assign a lambda expression, use a def
satpy/dataset.py
Outdated
import time | ||
timestamp_func = lambda x: time.mktime(x.timetuple()) | ||
else: | ||
timestamp_func = lambda x: x.timestamp() |
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.
E731 do not assign a lambda expression, use a def
satpy/dataset.py
Outdated
return datetime.fromtimestamp(sum(total) / len(total)) | ||
|
||
|
||
def combine_metadata(*metadata_objects, average_times=True): |
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.
E999 SyntaxError: invalid syntax
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.
Looks good to me. Just a comment and a question: did you check that it doesn't break the time attributes in the aggregation of eg viirs granules ?
return datetime.fromtimestamp(sum(total) / len(total)) | ||
|
||
|
||
def combine_metadata(*metadata_objects, **kwargs): |
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.
why not def combine_metadata(*metadata_objects, average_times=True):
?
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.
Read the comment below. That syntax isn't valid in python 2. I had it that way first and the tests failed. Unless you're saying I should drop python 2 support now... 😜
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'm happy with that :)
Which time attributes specifically? The yaml_reader always overwrites start and end time with the first and last times of the file handlers. |
Edit: As discussed below and on slack, this PR has been modified from its original purpose. It now does as the title states by modifying
combine_metadata
instead of modifying theahi_hsd
reader with a workaround (using scheduled time for start time). The original PR description is below:Observation time, which was used previously, varies between bands and
can make compositing difficult (no resulting start_time). This uses the
scheduled time of the image which should be the same for all bands for
a particular region/sector.
I'm still going to add some documentation to the top of the reader module to mention this time difference.
git diff origin/master -- "*py" | flake8 --diff