subsampling

Module: missions.nodes.preprocessing.subsampling

Reduce sampling rate of the TimeSeries by a specified fraction

Here different combinations with filters are possible.

Inheritance diagram for pySPACE.missions.nodes.preprocessing.subsampling:

Inheritance diagram of pySPACE.missions.nodes.preprocessing.subsampling

Class Summary

SubsamplingNode(target_frequency, \*\*kwargs) Downsampling with a simple low pass filter
FFTResamplingNode(target_frequency[, ...]) Downsampling with a FFT filter
DownsamplingNode(target_frequency, \*\*kwargs) Pure downsampling without filter
DecimationBase(target_frequency[, ...]) Decimate the signal to a given sampling frequency
DecimationIIRNode(\*\*kwargs) Downsampling with a preceding IIR filter
DecimationFIRNode([comp_type, skipping, ...]) Downsampling with a preceding FIR filter

Function Summary

gcd(a, b) Return the greatest common divisor of a and b.

Classes

SubsamplingNode

class pySPACE.missions.nodes.preprocessing.subsampling.SubsamplingNode(target_frequency, **kwargs)[source]

Bases: pySPACE.missions.nodes.base_node.BaseNode

Downsampling with a simple low pass filter

This is done by upsampling with a linear interpolation and downsampling with a corresponding low pass filter.

Exemplary Call

-
    node : Subsampling
    parameters :
        target_frequency : 1.0
Author:

Jan Hendrik Metzen (jhm@informatik.uni-bremen.de)

Created:

2008/08/25

Revised:

2010/02/25 by Mario Krell

POSSIBLE NODE NAMES:
 
  • Subsampling
  • SubsamplingNode
POSSIBLE INPUT TYPES:
 
  • TimeSeries

Class Components Summary

_execute(x) Subsample the given data x and return a new time series
input_types
__init__(target_frequency, **kwargs)[source]
_execute(x)[source]

Subsample the given data x and return a new time series

input_types = ['TimeSeries']

FFTResamplingNode

class pySPACE.missions.nodes.preprocessing.subsampling.FFTResamplingNode(target_frequency, window=None, mirror=False, **kwargs)[source]

Bases: pySPACE.missions.nodes.base_node.BaseNode

Downsampling with a FFT filter

Exemplary Call

- 
    node : Resampling
    parameters :
        target_frequency : 25.0
        window : "nut" # optional, window to apply before downsampling
        mirror : True #  optional, to make the data periodic before applying the FFT

possible windows are: ‘flattop’ - ‘flat’, ‘flt’ ‘boxcar’ - ‘ones’, ‘box’ ‘triang’ - ‘traing’, ‘tri’ ‘parzen’ - ‘parz’, ‘par’ ‘bohman’ - ‘bman’, ‘bmn’ ‘blackmanharris’ - ‘blackharr’, ‘bkh’, ‘nuttall’ - ‘nutl’, ‘nut’ ‘barthann’ - ‘brthan’, ‘bth’ ‘blackman’ - ‘black’, ‘blk’ ‘hamming’ - ‘hamm’, ‘ham’ ‘bartlett’ - ‘bart’, ‘brt’ ‘hanning’ - ‘hann’, ‘han’ (‘kaiser’, beta) - ‘ksr’ (‘gaussian’, std) - ‘gauss’, ‘gss’ (‘general gauss’, power, width) - ‘general’, ‘ggs’ (‘slepian’, width) - ‘slep’, ‘optimal’, ‘dss’

Author:

Mario Krell (Mario.Krell@dfki.de)

Created:

2010/02/25

POSSIBLE NODE NAMES:
 
  • Resampling
  • FFTResampling
  • FFTResamplingNode
POSSIBLE INPUT TYPES:
 
  • TimeSeries

Class Components Summary

_execute(data) Subsample the given data and return a new time series
input_types
__init__(target_frequency, window=None, mirror=False, **kwargs)[source]
_execute(data)[source]

Subsample the given data and return a new time series

input_types = ['TimeSeries']

DownsamplingNode

class pySPACE.missions.nodes.preprocessing.subsampling.DownsamplingNode(target_frequency, **kwargs)[source]

Bases: pySPACE.missions.nodes.base_node.BaseNode

Pure downsampling without filter

Reduce sampling rate by picking the values according to the downsampling factor. No low pass filter is used as needed for a proper decimation.

Exemplary Call

- 
    node : Downsampling
    parameters :
        target_frequency : 2.5
        phase_shift : 1
Author:

Hendrik Woehrle (Hendrik.Woehrle@dfki.de)

POSSIBLE NODE NAMES:
 
  • Downsampling
  • DownsamplingNode
POSSIBLE INPUT TYPES:
 
  • TimeSeries

Class Components Summary

_execute(data) Subsample the given data data and return a new time series
input_types
__init__(target_frequency, **kwargs)[source]
_execute(data)[source]

Subsample the given data data and return a new time series

input_types = ['TimeSeries']

DecimationBase

class pySPACE.missions.nodes.preprocessing.subsampling.DecimationBase(target_frequency, multi_step=True, comp_type='normal', norm_cutoff_freq=0.3333333333333333, norm_trans_region_width=0.16666666666666666, filter_frequency=None, **kwargs)[source]

Bases: pySPACE.missions.nodes.base_node.BaseNode

Decimate the signal to a given sampling frequency

This class is the base class for the other decimation nodes and can not be used directly.

The decimation is performed by doing a downsampling with a preceding filtering by a corresponding low pass filter beforehand. According to Shannon-Nyquist’s sampling theorem, only frequencies below 1/2*target_frequency should be retained.

For the decimation, one should use the FIR decimation (preferred) or IIR decimation, see below.

Parameters
target_frequency:
 

The frequency after the decimation.

(required)

multi_step:

The decimation is done in multiple sets, if the downsampling factor is high. The steps are chosen by the node.

(optional, default: True)

comp_type:

Type of computation for the filtering. One of the following Strings: ‘normal’, ‘parallel’, ‘gpu’....

(optional, default: ‘normal’)

norm_cutoff_freq:
 

Cutoff frequency for the low pass filter. Normalized to the target frequency.

(optional, default: ‘norm_cutoff_freq’)

norm_trans_region_width:
 

Width of transition region for the low pass filter. Normalized to the target frequency.

(optional, default: ‘norm_trans_region_width’)

filter_frequency:
 

Optional frequency of the filter, if the value should not be chosen automatically.

(optional, default: None)

Author:Hendrik Woehrle (Hendrik.Woehrle@dfki.de)

Class Components Summary

__hyperparameters
_execute(data) Subsample the given data data and return a new time series
compute_filter_factors()
create_filter(target_frequency, ...)
initialize_filters(data)
store_state(result_dir[, index]) Stores this node in the given directory result_dir
__init__(target_frequency, multi_step=True, comp_type='normal', norm_cutoff_freq=0.3333333333333333, norm_trans_region_width=0.16666666666666666, filter_frequency=None, **kwargs)[source]
compute_filter_factors()[source]
initialize_filters(data)[source]
create_filter(target_frequency, downsampling_factor, transition_region_width)[source]
_execute(data)[source]

Subsample the given data data and return a new time series

store_state(result_dir, index=None)[source]

Stores this node in the given directory result_dir

__hyperparameters = set([NoOptimizationParameter<kwargs_warning>, NoOptimizationParameter<dtype>, NoOptimizationParameter<output_dim>, BooleanParameter<Multi_step>, NoOptimizationParameter<retrain>, NoOptimizationParameter<input_dim>, ChoiceParameter<comp_type>, NoOptimizationParameter<store>])

DecimationIIRNode

class pySPACE.missions.nodes.preprocessing.subsampling.DecimationIIRNode(**kwargs)[source]

Bases: pySPACE.missions.nodes.preprocessing.subsampling.DecimationBase

Downsampling with a preceding IIR filter

The decimation is performed by doing a downsampling with a preceding filtering by a corresponding low pass filter beforehand. According to Shannon-Nyquist’s sampling theorem, only frequencies below 1/2*target_frequency should be retained.

The decimation is applied in multiple steps, if the sampling factor is too big.

The Filering is done using a IIR filter.

Exemplary Call

-
    node : DecimationIIR
    parameters :
        target_frequency : 25 
Author:

Hendrik Woehrle (Hendrik.Woehrle@dfki.de)

POSSIBLE NODE NAMES:
 
  • DecimationIIRNode
  • DecimationIIR
POSSIBLE INPUT TYPES:
 
  • TimeSeries

Class Components Summary

create_filter(target_frequency, ...)
input_types
__init__(**kwargs)[source]
create_filter(target_frequency, downsampling_factor, transition_region_width)[source]
input_types = ['TimeSeries']

DecimationFIRNode

class pySPACE.missions.nodes.preprocessing.subsampling.DecimationFIRNode(comp_type='normal', skipping=False, time_shift='middle', **kwargs)[source]

Bases: pySPACE.missions.nodes.preprocessing.subsampling.DecimationBase

Downsampling with a preceding FIR filter

The decimation is performed by doing a downsampling with a preceding filtering by a corresponding low pass filter beforehand. According to Shannon-Nyquist’s sampling theorem, only frequencies below 1/2*target_frequency should be retained.

The decimation is applied in multiple steps, if the sampling factor is too big.

The filtering procedure is applied by an FIR filter, and only for values that are significant due to the downsampling procedure.

Parameters
comp_type:

Computation type of the filter, see FIRFilterNode for further information.

(optional, default: ‘normal’)

skipping:

If output samples should be skipped in the filtering process, because they are discarded in the downsampling process.

(optional, default: True)

time_shift:

Parameter time_shift of the filter, see FIRFilterNode for further information.

(optional, default: ‘middle’)

Exemplary Call

-
    node : DecimationFIR
    parameters :
        target_frequency : 25 
Author:

Hendrik Woehrle (Hendrik.Woehrle@dfki.de)

POSSIBLE NODE NAMES:
 
  • Decimation
  • DecimationFIRNode
  • DecimationFIR
POSSIBLE INPUT TYPES:
 
  • TimeSeries

Class Components Summary

__hyperparameters
create_filter(target_frequency, ...)
input_types
input_types = ['TimeSeries']
__init__(comp_type='normal', skipping=False, time_shift='middle', **kwargs)[source]
create_filter(target_frequency, downsampling_factor, transition_region_width)[source]
__hyperparameters = set([ChoiceParameter<time_shift>, NoOptimizationParameter<kwargs_warning>, NoOptimizationParameter<dtype>, NoOptimizationParameter<output_dim>, BooleanParameter<Multi_step>, NoOptimizationParameter<retrain>, BooleanParameter<skipping>, NoOptimizationParameter<input_dim>, ChoiceParameter<comp_type>, NoOptimizationParameter<store>])

Function

gcd()

pySPACE.missions.nodes.preprocessing.subsampling.gcd(a, b)[source]

Return the greatest common divisor of a and b.

Input:
  • a – an integer
  • b – an integer
Output:
  • an integer – the gcd of a and b

Examples:

>>> gcd(97,100)
1
>>> gcd(97 * 10**15, 19**20 * 97**2)
97L

© William Stein, 2004

http://modular.math.washington.edu/ent/ent_py