Filter: Filter frequency peaks from an array

View source: R/Filter.R

FilterR Documentation

Filter frequency peaks from an array

Description

Filter out the selected frequency from a time series. The filtering is performed by dichotomy, seeking for a frequency around the parameter 'freq' and the phase that maximizes the signal to subtract from the time series. The maximization of the signal to subtract relies on a minimization of the mean square differences between the time series ('data') and the cosine of the specified frequency and phase.

Usage

Filter(data, freq, time_dim = "ftime", ncores = NULL)

Arguments

data

A numeric vector or array of the data to be filtered. If it's a vector, it should be a time series. If it's an array, the dimensions must have at least 'time_dim'.

freq

A number of the frequency to filter.

time_dim

A character string indicating the dimension along which to compute the filtering. The default value is 'ftime'.

ncores

An integer indicating the number of cores to use for parallel computation. The default value is NULL.

Value

A numeric vector or array of the filtered data with the dimensions the same as 'data'.

Examples

# Load sample data as in Load() example:
example(Load)
ensmod <- MeanDims(sampleData$mod, 2)
spectrum <- Spectrum(ensmod)

for (jsdate in 1:dim(spectrum)['sdate']) {
 for (jlen in 1:dim(spectrum)['ftime']) {
   if (spectrum[jlen, 2, 1, jsdate] > spectrum[jlen, 3, 1, jsdate]) {
     ensmod[1, jsdate, ] <- Filter(ensmod[1, jsdate, ], spectrum[jlen, 1, 1, jsdate])
   }
 }
}
 
PlotAno(InsertDim(ensmod, 2, 1), sdates = startDates)
 


s2dv documentation built on Oct. 13, 2024, 9:07 a.m.