solarspatialtools.signalproc.xcorr_delay
- solarspatialtools.signalproc.xcorr_delay(ts_in, ts_out, scaling='coeff')
Compute the delay between two timeseries using cross correlation.
Parameters
- ts_inpd.Series
The input timeseries. Requires that the index operate as datetime.
- ts_outpd.Series
The output timeseries
- scalingstr
Type of scaling to use for cross correlation.
- Options are:
- energy:
scales by the energy of the autocorrelation of the input
- coeff:
scales the output to the correlation coefficient (always removes the mean from both signals)
- unbiased_energy:
similar to energy, but normalizes based on lag to account for the fewer points used in the convolution. Removes bias towards small lags.
- unbiased_coeff:
similar to coeff, but normalizes based on lag to account for the fewer points used in the convolution. Removes bias towards small lags.
Returns
- delayfloat
Time lag between the two timeseries at the maximum value of the cross correlation. Values are always integer multiples of the sampling period as the max correlation values are limited to the discrete time steps.
- corrfloat
The peak value of the cross correlation at the identified delay.