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 numpy.datetime64 array to epoch time (seconds since 1/1/1970 00:00:00) |
|
Convert from epoch time (seconds since 1/1/1970 00:00:00) to numpy.datetime64 array |
|
Convert numpy.datetime64 array to list of datetime objects |
|
Convert numpy.datetime64 array to list of datetime objects |
|
Convert from epoch time (seconds since 1/1/1970 00:00:00) to a list of datetime objects |
|
Convert list of datetime objects to epoch time |
|
Convert list of datetime objects to legible strings |
|
Convert list of datetime objects to MATLAB datenum |
|
Convert MATLAB datenum to list of datetime objects |
- dolfyn.time.epoch2dt64(ep_time)[source]
Convert from epoch time (seconds since 1/1/1970 00:00:00) to numpy.datetime64 array
- Parameters
ep_time (xarray.DataArray) – Time coordinate data-array or single time element
- Returns
time (numpy.datetime64) – The converted datetime64 array
- dolfyn.time.dt642epoch(dt64)[source]
Convert numpy.datetime64 array to epoch time (seconds since 1/1/1970 00:00:00)
- Parameters
dt64 (numpy.datetime64) – Single or array of datetime64 object(s)
- Returns
time (float) – Epoch time (seconds since 1/1/1970 00:00:00)
- dolfyn.time.date2dt64(dt)[source]
Convert numpy.datetime64 array to list of datetime objects
- Parameters
time (datetime.datetime) – The converted datetime object
- Returns
dt64 (numpy.datetime64) – Single or array of datetime64 object(s)
- dolfyn.time.dt642date(dt64)[source]
Convert numpy.datetime64 array to list of datetime objects
- Parameters
dt64 (numpy.datetime64) – Single or array of datetime64 object(s)
- Returns
time (datetime.datetime) – The converted datetime object
- dolfyn.time.epoch2date(ep_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
ep_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.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)