API
PreciseDateTime
Precise date-time object with picosecond timing accuracy.
Attributes
Classes
PreciseDateTime
Precise Date Time format specification.
| Field | Value / Format | Description |
|---|---|---|
| Precision | 1e-12 s | Picosecond precision |
| Standard format | "DD-MMM-YYYY hh:mm:ss.pppppppppppp" |
Default string representation |
| Standard reference date | PRECISEDATETIME_REFERENCE_TIME |
Reference epoch |
| DD | — | Day |
| MMM | JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC |
Month (three-letter uppercase abbreviation) |
| YYYY | — | Year (4 digits) |
| hh | 00-23 | Hours (24-hour format) |
| mm | 00-59 | Minutes |
| ss | 00-59 | Seconds |
| pppppppppppp | 12 digits | Picoseconds |
Attributes
day_of_the_month
property
Day of the month associated to the current time point.
minute_of_hour
property
Minute of the hour associated to the current time point.
second_of_minute
property
Second of the minute associated to the current time point.
picosecond_of_second
property
Picosecond of the second associated to the current time point.
fraction_of_day
property
Fraction of the day associated to the current time point.
day_of_the_year
property
Day from the first day of the year associated to the current time point.
sec85
property
Time distance in seconds from PRECISEDATETIME_1985 to the current time point.
Methods:
__init__
Initialize the PreciseDateTime object with the specified time point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
number of seconds since reference date, by default 0.0 |
0.0
|
picoseconds
|
float
|
number of picoseconds since reference date, by default 0.0 |
0.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when negative values are passed as arguments |
__iadd__
Add the input seconds to the current time point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
number of seconds to add to the current time point |
required |
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
self |
__isub__
Subtract the input seconds from the current time point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
number of seconds to subtract from the current time point |
required |
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
self |
__add__
Return the sum between the current time point and the specified input seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
number of seconds to add to the current time point |
required |
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
a new PreciseDateTime object initialized to the resulting time point |
__sub__
Return the difference between the current time point and a float or a PreciseDateTime object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
float | PreciseDateTime
|
number of seconds or PreciseDateTime object to subtract from the current time point |
required |
Returns:
| Type | Description |
|---|---|
float | PreciseDateTime:
|
if the input parameter is a PreciseDateTime object, the difference in seconds between the two time points; otherwise, a new PreciseDateTime object initialized to the resulting time point |
__eq__
Compare the current time point with another PreciseDateTime object for equality.
__lt__
Compare the current time point with another PreciseDateTime object.
get_precision
classmethod
Date-time representation precision.
Returns:
| Type | Description |
|---|---|
float
|
precision of the date-time representation in seconds |
get_reference_datetime
classmethod
Get reference date-time.
Returns:
| Type | Description |
|---|---|
datetime
|
reference date-time as a datetime object |
now
classmethod
Create an object with the current time (local timezone).
from_sec85
classmethod
Create an object with the time point defined by adding the specified input seconds to PRECISEDATETIME_1985.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
number of seconds from PRECISEDATETIME_1985 |
required |
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
the time point |
from_utc_string
classmethod
Create an object with the time point specified by the input UTC string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_str
|
str
|
UTC string |
required |
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
the time point |
from_numeric_datetime
classmethod
from_numeric_datetime(year: int, month: int = 1, day: int = 1, hours: int = 0, minutes: int = 0, seconds: int = 0, picoseconds: float = 0.0) -> PreciseDateTime
Create an object with the time point specified by the input date and time parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
year |
required |
month
|
int
|
from 1 to 12, by default 1 |
1
|
day
|
int
|
from 1 to 28-31 (depending on month), by default 1 |
1
|
hours
|
int
|
from 0 to 23, by default 0 |
0
|
minutes
|
int
|
from 0 to 59, by default 0 |
0
|
seconds
|
int
|
from 0 to 59, by default 0 |
0
|
picoseconds
|
float
|
non-negative and less than 1e12, by default 0.0 |
0.0
|
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
the time point |
Raises:
| Type | Description |
|---|---|
ValueError
|
in case of invalid picoseconds |
fromisoformat
classmethod
Create an object with the time specified by the input ISO string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datetime_string
|
str
|
time specified as ISO string |
required |
sep
|
str
|
separator between date and time, by default "T" |
'T'
|
Returns:
| Type | Description |
|---|---|
PreciseDateTime
|
the time point |
Raises:
| Type | Description |
|---|---|
ValueError
|
in case of an invalid input datetime string |
isoformat
ISO formatting of the time point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sep
|
str
|
separator between date and time, by default "T" |
'T'
|
timespec
|
str
|
number of extra terms to include in the string, by default Valid options are: |
'auto'
|
Returns:
| Type | Description |
|---|---|
str
|
time formatted according to ISO |
Timing conversions
Timing conversion utilities.
Attributes
Classes
Functions:
date_to_gps_week
Convert input date to GPS week.
GPS weeks are counted since 06-January-1980.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
PreciseDateTime | datetime
|
date to be converted to GPS week, in PreciseDateTime or datetime format |
required |
Returns:
| Type | Description |
|---|---|
int
|
GPS week |
int
|
GPS day of the week |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input date is before 06-January-1980 |
precise_datetime_to_numpy
Convert PreciseDateTime to numpy.datetime64 data type truncated to nanoseconds precision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
PreciseDateTime | ndarray
|
times to be converted from PreciseDateTime format to numpy.datetime64[ns] |
required |
Returns:
| Type | Description |
|---|---|
datetime64 | ndarray
|
numpy.datetime64[ns] at nanoseconds precision corresponding to the input times |