-
Notifications
You must be signed in to change notification settings - Fork 297
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
Add scanline timestamps to seviri_l1b_hrit #752
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ | |
"""Utilities and eventually also base classes for MSG HRIT/Native data reading | ||
""" | ||
|
||
from datetime import datetime, timedelta | ||
import numpy as np | ||
from numpy.polynomial.chebyshev import Chebyshev | ||
import dask.array as da | ||
|
@@ -193,11 +192,30 @@ | |
|
||
|
||
def get_cds_time(days, msecs): | ||
"""Get the datetime object of the time since epoch given in days and | ||
milliseconds of day | ||
"""Compute timestamp given the days since epoch and milliseconds of the day | ||
1958-01-01 00:00 is interpreted as fill value and will be replaced by NaT (Not a Time). | ||
Args: | ||
days (int, either scalar or numpy.ndarray): | ||
Days since 1958-01-01 | ||
msecs (int, either scalar or numpy.ndarray): | ||
Milliseconds of the day | ||
Returns: | ||
numpy.datetime64: Timestamp(s) | ||
""" | ||
return datetime(1958, 1, 1) + timedelta(days=float(days), | ||
milliseconds=float(msecs)) | ||
if np.isscalar(days): | ||
days = np.array([days], dtype='int64') | ||
msecs = np.array([msecs], dtype='int64') | ||
|
||
time = np.datetime64('1958-01-01').astype('datetime64[ms]') + \ | ||
days.astype('timedelta64[D]') + msecs.astype('timedelta64[ms]') | ||
time[time == np.datetime64('1958-01-01 00:00')] = np.datetime64("NaT") | ||
|
||
if len(time) == 1: | ||
return time[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed ? Don't we always have the time as an array with multiple values .? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. the scanline timestamps are always multiple values. The use case I had in mind are attributes which contain a single timestamp |
||
return time | ||
|
||
|
||
def dec10216(inbuf): | ||
|
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.
What if days is a float ? Shouldn't something go over to msecs ?
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.
Right, that doesn't make sense. Both days and msecs are expected to be integer, so the check for float should be removed. It was meant to check whether the input is scalar. But maybe
np.isscalar
is a better option