Time Conversion
Time is handled primary in epoch time, or seconds since 1/1/1970, and includes conversion to Unix timestamps, datetime objects, and MATLAB datenum.
Convert from epoch time (seconds since 1/1/1970 00:00:00) to a list of datetime objects |
|
Convert list of datetime objects to legible strings |
|
Convert list of datetime objects to epoch time |
|
Convert list of datetime objects to MATLAB datenum |
|
Convert MATLAB datenum to list of datetime objects |
- dolfyn.time.epoch2date(ds_time, offset_hr=0, to_str=False)[source]
Convert from epoch time (seconds since 1/1/1970 00:00:00) to a list of datetime objects
- Parameters
ds_time (xarray.DataArray) – Time coordinate data-array or single time element
offset_hr (int) – Number of hours to offset time by (e.g. UTC -7 hours = PDT)
to_str (logical) – Converts datetime object to a readable string
- Returns
time (datetime) – The converted datetime object or list(strings)
Notes
The specific time instance is set during deployment, usually sync’d to the deployment computer. The time seen by DOLfYN is in the timezone of the deployment computer, which is unknown to DOLfYN.
- dolfyn.time.date2str(dt, format_str=None)[source]
Convert list of datetime objects to legible strings
- Parameters
dt (datetime.datetime) – Single or list of datetime object(s)
format_str (string) – Timestamp string formatting, default: ‘%Y-%m-%d %H:%M:%S.%f’. See datetime.strftime documentation for timestamp string formatting
- Returns
time (string) – Converted timestamps
- dolfyn.time.date2epoch(dt)[source]
Convert list of datetime objects to epoch time
- Parameters
dt (datetime.datetime) – Single or list of datetime object(s)
- Returns
time (float) – Datetime converted to epoch time (seconds since 1/1/1970 00:00:00)