Skip to content

gravitools.timeseries

Utilities for time series

TimeSeries(obj, **kwargs)

A wrapper of pandas.Series for time series

Parameters:

  • obj ((Series, DataFrame)) –

    Input data object with a time index. When passing a pandas.DataFrame, it is expected to have a data column y and optional columns y_err. When passing a 1-dim. series, it is converted to a pandas.DataFrame with one column named y.

  • **kwargs (dict, default: {} ) –

    Optional keyword arguments to be used for plotting.

meta property

Dict of meta attibutes

y property

Main value column

y_err property

Error value column

y0 property

Plot y-axis offset

has_error property

True, if column of error values exists

mean()

Mean, standard deviation and standard error of the mean

Mean, standard deviation and SEM are weighted, if the time series has an error column. See weighted_mean.

Returns:

  • mean ( float ) –

    Mean value.

  • std ( float ) –

    Standard deviation.

  • sem ( float ) –

    Standard error of the mean.

std()

Standard deviation

resample(interval, min_count=None, err='sem', **kwargs)

Resample time series to new interval duration

See interval_means().

Parameters:

  • interval (str) –

    Resampling interval, e.g. "1h".

  • min_count (int | float, default: None ) –

    Minimum number of samples required in interval. Intervals with fewer samples are evaluated as NaN.

  • err (str, default: 'sem' ) –

    Statistical function to use for error column. Options are "sem" (standard error of the mean) and "std" (standard deviation).

  • kwargs (dict, default: {} ) –

    Keyword arguments to be updated on resulting TimeSeries. Unspecified keywords are inherited.

Returns:

mask(*args, **kwargs)

Mask samples by a condition and return as new TimeSeries

adev(taus='auto', mrate=None)

Calculate the Allan deviation

Parameters:

  • taus (str | array, default: 'auto' ) –

    Time interval values tau to calculate the Allan deviation at.

  • mrate (float | str, default: None ) –

    Measurement rate, in Hz.

Returns:

  • Series

    Allan deviation

plot(fmt=None, ax=None, y0=None, errorbars=True, min_count=None, **kwargs)

Plot

Parameters:

  • fmt (str, default: None ) –

    Plot style

  • ax (Axes, default: None ) –

    Plot axes

  • y0 (float, default: None ) –

    Y-axis offset to be applied to data. Acquired from y0 property, if unspecified.

  • errorbars (bool, default: True ) –

    Plot errorbars, if possible.

  • min_count (int | float, default: None ) –

    Minimum number of samples in an interval, given by column y_count, for a point to be plotted. Fractional values are considered relative to maximum count. Ignored, if there is no column y_count.

  • kwargs (dict, default: {} ) –

    Arguments to be passed to Matplotlib.

plot_mean(sem=False, std=False, y0=None, ax=None, **kwargs)

Plot mean, standard deviation and standard error of the mean (SEM)

chunks(freq='1D')

Itervate over time series by intervals

Parameters:

  • freq (str, default: '1D' ) –

    Duration of time intervals, e. g. "1D" for day intervals.

Yields:

plot_chunks(freq='1D', ylim=None, **kwargs)

Plot time series in chunks

plot_adev(mrate=None, ax=None, **kwargs)

Plot the Allan deviation

GravityTimeSeries(obj, height=None, vgg=None, **kwargs)

Bases: TimeSeries

A time series of gravity values

Parameters:

  • obj (Series | DataFrame) –

    Input data, see :class:TimeSeries.

  • height (float, default: None ) –

    Measurement height, in meters.

  • vgg (float, default: None ) –

    Vertical gravity gradient, in nm/s² per meter.

transfer(h)

Transfer to another height using VGG

Parameters:

  • h (float) –

    New height, in meters.

Returns:

mean_std()

Mean gravity value with standard deviation as error

Returns:

plot(fmt=None, ax=None, y0=None, **kwargs)

Plot gravity time series

to_csv(path, float_format='%.2f', **kwargs)

Save to a CSV file