pyacs.gts.lib.gts_dates module

This module gathers a few useful date functions, which can be used to read different time series formats. pyacs.pygts uses decimal year as time defaults. Seconds for High-Rate GPS solution can also be used.

pyacs.gts.lib.gts_dates.decyear2days(self, ref_date='', in_place=False)[source]

Convert time series dates from decimal year to days after a reference date.

Parameters:
  • ref_date (float or str, optional) – Reference date (decimal year or parseable by guess_date). Default first data date.

  • in_place (bool, optional) – If True, modify in place; otherwise return a new Gts.

Returns:

Time series with dates in days (or self if in_place).

Return type:

Gts

pyacs.gts.lib.gts_dates.np_datetime_2_eq_time(data, leap_sec=0.0, eq_time=0.0)[source]

Convert dict of datetime to seconds relative to eq_time.

If input is in GPS time, leap_sec corrects for GPS-UTC (e.g. 17 s on 2016-02-13).

Parameters:
  • data (dict) – Mapping index -> datetime.datetime.

  • leap_sec (float, optional) – GPS time minus UTC in seconds (e.g. 17).

  • eq_time (datetime, optional) – Earthquake time in UTC (reference for seconds).

Returns:

Seconds relative to eq_time (and leap_sec correction if applied).

Return type:

ndarray

pyacs.gts.lib.gts_dates.np_yyyy_mm_dd_hh_mm_ss_2_datetime(data)[source]

Convert numpy array [year, month, mday, hour, minute, sec] to datetime objects.

Parameters:

data (ndarray) – Array of shape (n, 6).

Returns:

Mapping index -> datetime.datetime.

Return type:

dict

pyacs.gts.lib.gts_dates.np_yyyy_mm_dd_hh_mm_ss_2_decyear(data)[source]

Convert numpy array [year, month, mday, hour, minute, sec] to decimal year.

Parameters:

data (ndarray) – Array of shape (n, 6) with year, month, day, hour, minute, sec.

Returns:

1D array of decimal years.

Return type:

ndarray