Stats_util

Docstrings for the Stats_util class

Objects

quadratic_spline_roots()
find_maxima()
doodson_x0_filter()

Python definitions used to aid with statistical calculations.

Methods Overview -> normal_distribution(): Create values for a normal distribution -> cumulative_distribution(): Integration udner a PDF -> empirical_distribution(): Estimates CDF empirically

quadratic_spline_roots()


def quadratic_spline_roots(spl):

A custom function for the roots of a quadratic spline. Cleverness found at
https://stackoverflow.com/questions/50371298/find-maximum-minimum-of-a-1d-interpolated-function
Used in find_maxima().

Example usage:
see example_scripts/tidegauge_tutorial.py

find_maxima()


def find_maxima(x, y, method=comp, **kwargs):

Finds maxima of a time series y. Returns maximum values of y (e.g heights)
and corresponding values of x (e.g. times).
**kwargs are dependent on method.

                Methods:
                'comp' :: Find maxima by comparison with neighbouring values.
                                                Uses scipy.signal.find_peaks. **kwargs passed to this routine
                                                will be passed to scipy.signal.find_peaks.
                'cubic' :: Find the maxima and minima by fitting a cubic spline and
                                                                finding the roots of its derivative.
                                                                Expect input as xr.DataArrays
                DB NOTE: Currently only the 'comp' and 'cubic' method are implemented.
                                                Future methods include linear interpolation.

                JP NOTE: Cubic method:
                                i) has intelligent fix for NaNs,

Example usage:
see example_scripts/tidegauge_tutorial.py

doodson_x0_filter()


def doodson_x0_filter(elevation, ax=0):

The Doodson X0 filter is a simple filter designed to damp out the main
tidal frequencies. It takes hourly values, 19 values either side of the
central one and applies a weighted average using:
                                (1010010110201102112 0 2112011020110100101)/30.
( http://www.ntslf.org/files/acclaimdata/gloup/doodson_X0.html )

In "Data Analaysis and Methods in Oceanography":

"The cosine-Lanczos filter, the transform filter, and the
Butterworth filter are often preferred to the Godin filter,
to earlier Doodson filter, because of their superior ability
to remove tidal period variability from oceanic signals."

This routine can be used for any dimension input array.

Parameters
----------
                elevation (ndarray) : Array of hourly elevation values.
                axis (int) : Time axis of input array. This axis must have >= 39
                elements

Returns
-------
                Filtered array of same rank as elevation.


Last modified November 23, 2022: Updated docstrings from coast repo. (9daee18)