rednoisefit¶
-
rednoisefit(dt, a, /, nlag=None, nlag_fit=None, axis=0)[source]¶ Return the \(e\)-folding autocorrelation timescale for the input autocorrelation spectra along an arbitrary axis. Depending on the length of
axis, the timescale is obtained with either of the following two approaches:Find the \(e\)-folding timescale(s) for the pure red noise autocorrelation spectra \(\exp(-x\Delta t / \tau)\) with the least-squares best fit to the provided spectra.
Assume the process is pure red noise and invert the red noise autocorrelation spectrum at lag 1 to solve for \(\tau = \Delta t / \log a_1\).
Approach 2 is used if the length of the data along axis
axisis1, or the data is scalar. In these cases, the data is assumed to represent just the lag-1 autocorrelation(s).- Parameters
dt (float, optional) – The timestep. This is used to scale timescales into physical units.
a (array-like) – The autocorrelation spectra.
nlag (int, optional) – The number of lag timesteps to include in the curve fitting. Default is all the available lags.
nlag_fit (int, optional) – The number of lag timesteps to include in the reconstructed pure red noise autocorrelation spectrum. Default is 50 timesteps.
axis (int, optional) – The “lag” dimension. Each slice along this axis should represent an autocorrelation spectrum generated with
corr. If the length is1, the data are assumed to be lag-1 autocorrelations and the timescale is computed from the red noise equation. Otherwise, the timescale is estimated from a least-squares curve fit to a red noise spectrum.
- Returns
tau (array-like) – The autocorrelation timescales. The shape is the same as
databut withaxisreduced to length1.sigma (array-like) – The standard errors. If the timescale was inferred using the lag-1 equation, this is an array of zeros. The shape is the same as
tau.bestfit (array-like) – The best fit autocorrelation curves. The shape is the same as
databut withaxisof lengthnlag.
Example
>>> import climopy as climo auto = climo.autocorr(data, axis=0) taus, sigmas = climo.rednoise_fit(auto, axis=0)
See also
corr(),rednoise(),rednoise_spectrum()