This page was created by the IDL library routine
mk_html_help2.
Last modified: Sun Apr 13 03:17:35 2025.
NAME:
cross_spec
PURPOSE:
This function estimates the power cross-spectrum of two vectors.
CATEGORY:
Time Series Analysis
CALLING SEQUENCE:
Result = cross_spec(Y1, Y2)
INPUTS:
Y1: A floating point vector of the same length as Y2.
Y2: A floating point vector of the same length as Y1.
OPTIONAL INPUTS:
-
DELTAT, WIDTH, WINDOW
KEYWORD PARAMETERS:
AMPLITUDE: Returns the amplitude component of the cross-spectrum.
AUTOSPEC1: Returns the auto-spectrum of Y1.
AUTOSPEC2: Returns the auto-spectrum of Y2.
COHERENCY: Returns the coherency of Y1 and Y2.
DELTAT: The time interval between values in the input vectors.
DOUBLE: If set the calculations are performed in double precision
arithmetic. The default is single precision.
FREQ: Returns the frequency values corresponding to the output
cross-spectrum.
PHASE: Returns the phase component of the cross-spectrum, in radians.
Positive values mean that Y1 is leading Y2 at that frequency.
WIDTH: The width, of type integer, of the smoothing window to be used
by FILTER.pro. If not given then no smoothing is performed.
WINDOW: A string containing the name of the smoothing window to be
used by FILTER.pro. Smoothing is only performed if WIDTH is
given.
OUTPUTS:
Result: Returns the cross-spectrum.
AMPLITUDE, AUTOSPEC1, AUTOSPEC2, COHERENCY, FREQ, PHASE
USES:
FILTER.pro
PROCEDURE:
This function uses the FFT function to estimate the spectra.
EXAMPLE:
Create two time series of a periodic signal of period 23 and phase
difference pi/2. Add a pinch of noise.
y1 = sin(6.28*findgen(1000)/23.)+0.1*randomn(1, 1000)
y2 = sin(6.28*(findgen(1000)/23.-0.25)) $
+0.1*randomn(2, 1000)
Estimate the cross-spectrum.
result = cross_spec(y1, y2, amplitude=amplitude, phase=phase, freq=freq)
The amplitude power spectrum should have a peak at freq=1./23., and
the phase at that frequency should be 0.5.
CODE:
A. Shinbori, 30/09/2011.
MODIFICATIONS:
A. Shinbori, 30/10/2011
ACKNOWLEDGEMENT:
$LastChangedBy: nikos $
$LastChangedDate: 2018-08-01 11:03:38 -0700 (Wed, 01 Aug 2018) $
$LastChangedRevision: 25538 $
$URL $
(See projects/iugonet/tools/statistical_package/coherence_analysis/cross_spectrum/cross_spec.pro)
NAME: dimension PURPOSE: This function returns the dimension of an array. It returns 0 if the input variable is scalar. CATEGORY: Array CALLING SEQUENCE: Result = DIMENSION(Inarray) INPUTS: Inarray: A scalar or array of any type. OUTPUTS: Result: The dimension of Inarray. Returns 0 if scalar. PROCEDURE: This function runs the IDL function SIZE. EXAMPLE: Define a 3*4-element array. x = findgen(3,4) Calculate the dimension of x. result = dimension(x) MODIFICATIONS: A. Shinbori, 30/10/2011 ACKNOWLEDGEMENT: $LastChangedBy: nikos $ $LastChangedDate: 2018-08-01 11:03:38 -0700 (Wed, 01 Aug 2018) $ $LastChangedRevision: 25538 $ $URL $
(See projects/iugonet/tools/statistical_package/coherence_analysis/cross_spectrum/dimension.pro)
NAME:
filter
PURPOSE:
This function returns a smoothed version of the input vector.
CATEGORY:
Time Series Analysis
CALLING SEQUENCE:
Result = FILTER( Vector, [Width], [Window] )
INPUTS:
Vector: An vector of type floating point and length N.
OPTIONAL INPUTS:
Width: The width, of type integer, of the smoothing window.
Window: A string containing the name of the smoothing window to
return. Options are 'boxcar', 'gaussian', 'hanning',
'triangle'. The default is a boxcar window.
KEYWORD PARAMETERS:
BOXCAR: Sets the smoothing window to a boxcar filter. This is
the default. If set to a value, it replaces Width.
EDGE_TRUNCATE: Set this keyword to apply the smoothing to all points.
If the neighbourhood around a point includes a point outside
the array, the nearest edge point is used to compute the
smoothed result. If EDGE_TRUNCATE is not set, the points near
the end are replaced with NaNs.
FILTER: A vector containing the filter window to use. This overrides
the window requested in the Window input. This also returns
the filter after use.
NAN: Set this keyword to ignore NaN values in the input array,
provided there is at least one defined value nearby. The
default is to return NaNs wherever they occur.
NO_NAN: Obsolete version of NAN keyword retained for compatibility
but no longer used.
START_INDEX: The location of the centre of the window for the first
averaged output value, in units of Vector indices. Values must
be greater than 0. The default is 0.
STEP: An integer defining the step size for window translation, in
units of Vector indices. The default is 1.
TRIANGLE: Sets the smoothing window to a triangle filter. The default
is a boxcar filter. If set to a value, it replaces Width.
WRAP_EDGES: If set, the vector is treated as being cyclic and the
ends are joined together when smoothing.
OUTPUTS:
Result: Returns the smoothed version of Vector.
USES:
dimension.pro
filter_window.pro
plus.pro
PROCEDURE:
This function manually convolves the input vector with the filter.
EXAMPLE:
Create a vector of daily data and a sinusoid for a year.
x = randomn( seed, 365 ) + sin( 6.28 * findgen( 365 ) / 365. )
Smooth x with a boxcar filter of 7 days, wrapping the edges together.
result = filter( x, 7, 'boxcar', /wrap_edges )
CODE:
A. Shinbori, 30/09/2011.
MODIFICATIONS:
A. Shinbori, 30/10/2011
ACKNOWLEDGEMENT:
$LastChangedBy: nikos $
$LastChangedDate: 2018-08-01 11:03:38 -0700 (Wed, 01 Aug 2018) $
$LastChangedRevision: 25538 $
$URL $
(See projects/iugonet/tools/statistical_package/coherence_analysis/cross_spectrum/filter.pro)
NAME: filter_window PURPOSE: This function returns a desired filter window of desired width. CATEGORY: Time Series Analysis CALLING SEQUENCE: Result = filter_window([Width],[Window]) OPTIONAL INPUTS: Width: The width of the filter window, of type integer. Window: A string containing the name of the smoothing window to return. Options are 'boxcar', 'gaussian', 'hanning', 'triangle'. The default is a boxcar window. KEYWORD PARAMETERS: BOXCAR: Sets the output to a boxcar window. This is the default. If set to a value, it replaces Width (obsolete option). DIMENSION: The dimension of the filter, of type integer. The default is 1. TRIANGLE: Sets the output to a triangle window. The default is a boxcar window. If set to a value, it replaces Width (obsolete option). OUTPUTS: Result: Returns the desired filter window. PROCEDURE: This function builds a filter of the desired shape and width, and then normalises it. EXAMPLE: Define a two dimensional boxcar window of width 5. result = filter_window( 5, 'boxcar', dimension=2 ) result should be a 5x5 matrix with 0.04 for all entries. CODE: A. Shinbori, 30/09/2011. MODIFICATIONS: A. Shinbori, 30/10/2011 ACKNOWLEDGEMENT: $LastChangedBy: nikos $ $LastChangedDate: 2018-08-01 11:03:38 -0700 (Wed, 01 Aug 2018) $ $LastChangedRevision: 25538 $ $URL $
(See projects/iugonet/tools/statistical_package/coherence_analysis/cross_spectrum/filter_window.pro)
NAME: plus PURPOSE: This function returns 1 if the input is positive, 0 otherwise. CATEGORY: Mathematics CALLING SEQUENCE: Result = PLUS( Y ) INPUTS: Y: A scalar or array of type integer or floating point. OUTPUTS: Result: Returns 1 if Y is positive, 0 otherwise. PROCEDURE: This function determines whether Y is greater than 0. EXAMPLE: Determine if 3 is positive. result = plus( 3 ) CODE: A. Shinbori, 30/09/2011. MODIFICATIONS: A. Shinbori, 30/10/2011 ACKNOWLEDGEMENT: $LastChangedBy: nikos $ $LastChangedDate: 2018-08-01 11:03:38 -0700 (Wed, 01 Aug 2018) $ $LastChangedRevision: 25538 $ $URL $
(See projects/iugonet/tools/statistical_package/coherence_analysis/cross_spectrum/plus.pro)
PROCEDURE: TEST_CROSS_SPEC.PRO
A sample crib sheet that explains how to use the "cross_spec.pro"
procedure. You can run this crib sheet.
Or alternatively compile and run using the command:
.run test_cross_spec
Written by: A. Shinbori, May 01, 2013
Last Updated: A. Shinbori, May 01, 2013
(See projects/iugonet/tools/statistical_package/coherence_analysis/cross_spectrum/test_cross_spec.pro)