fosanalysis
A framework to evaluate distributed fiber optic sensor data
Loading...
Searching...
No Matches
fosanalysis.preprocessing.resizing.Downsampler Class Reference

Class for reducing strain data size while keeping the data loss small by combining several values into one value. More...

Inheritance diagram for fosanalysis.preprocessing.resizing.Downsampler:

Public Member Functions

 __init__ (self, Aggregate aggregator, int radius=None, int start_pixel=None, int step_size=None, *args, **kwargs)
 Initialize the down sampler.
 
tuple run (self, np.array x, np.array y, np.array z, tuple radius=None, tuple start_pixel=None, tuple step_size=None)
 This method downsamples 2D and 1D Strain data using specified parameters.
 
- Public Member Functions inherited from fosanalysis.preprocessing.base.Base
 __init__ (self, *args, **kwargs)
 Construct an instance of the class.
 
- Public Member Functions inherited from fosanalysis.utils.base.Task
 __init__ (self, *args, **kwargs)
 
- Public Member Functions inherited from fosanalysis.utils.base.Base
 __init__ (self, *args, **kwargs)
 Construct the object and warn about unused/unknown arguments.
 

Public Attributes

 aggregator = aggregator
 Aggregator to use, see Aggregate.
 
 radius = radius
 Inradius of the window's rectangle.
 
 start_pixel = start_pixel
 Index of the first window's central pixel.
 
 step_size = step_size
 Step size how far the window moves in one step.
 

Detailed Description

Class for reducing strain data size while keeping the data loss small by combining several values into one value.

To achieve this, windows with a specified size (see radius) are placed on the original data in a regular grid of fixed step_size and a fixed start_pixel. Each window is then aggregated to one value, see Aggregate. In contrast to Resampler, the grid is specified by array indices.

Definition at line 221 of file resizing.py.

Constructor & Destructor Documentation

◆ __init__()

fosanalysis.preprocessing.resizing.Downsampler.__init__ ( self,
Aggregate aggregator,
int radius = None,
int start_pixel = None,
int step_size = None,
* args,
** kwargs )

Initialize the down sampler.

This method can be extended for any necessary initialization logic.

Parameters
aggregatorAn instance of Aggregate used for aggregation.
radiusInradius of the window's rectangle.

If radius is an int, all axes will use this radius and the window is a square. For non-square windows, pass a tuple with a radius for each dimension of data_array. Along an axis, the window has a width of \(2r + 1\) for each element \(r\) of radius.

Parameters
start_pixelIndex of the first window's central pixel.

If start_pixel is an int, it is used for all dimensions of data_array. To specify a custom starting element, pass a tuple with a step size for each dimension of data_array. If None, it defaults to radius, the moving window starts with a full slice.

Parameters
step_sizeStep size how far the window moves in one step.

If step_size is an int, it is used for all dimensions of data_array. If None, it defaults to \(2r + 1\) for each element \(r\) of radius, which is equivalent to a rolling window.

Parameters
*argsAdditional positional arguments, will be passed to the superconstructor.
**kwargsAdditional keyword arguments, will be passed to the superconstructor.

Definition at line 231 of file resizing.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ run()

tuple fosanalysis.preprocessing.resizing.Downsampler.run ( self,
np.array x,
np.array y,
np.array z,
tuple radius = None,
tuple start_pixel = None,
tuple step_size = None )

This method downsamples 2D and 1D Strain data using specified parameters.

Parameters
xArray of x-axis values.
yArray of time-axis values.
z2D array of strain data.
radiusInradius of the window's rectangle.

If radius is an int, all axes will use this radius and the window is a square. For non-square windows, pass a tuple with a radius for each dimension of data_array. Along an axis, the window has a width of \(2r + 1\) for each element \(r\) of radius.

Parameters
start_pixelIndex of the first window's central pixel.

If start_pixel is an int, it is used for all dimensions of data_array. To specify a custom starting element, pass a tuple with a step size for each dimension of data_array. If None, it defaults to radius, the moving window starts with a full slice.

Parameters
step_sizeStep size how far the window moves in one step.

If step_size is an int, it is used for all dimensions of data_array. If None, it defaults to \(2r + 1\) for each element \(r\) of radius, which is equivalent to a rolling window.

Returns
Tuple containing (target_x_points, target_time_points, new_z).
Return values
target_x_pointsThe x-axis values after downsampling.
target_time_pointsThe time-axis values after downsampling.
new_zArray of downsampled strain data.

Reimplemented from fosanalysis.preprocessing.base.Base.

Definition at line 270 of file resizing.py.

Member Data Documentation

◆ aggregator

fosanalysis.preprocessing.resizing.Downsampler.aggregator = aggregator

Aggregator to use, see Aggregate.

Definition at line 249 of file resizing.py.

◆ radius

fosanalysis.preprocessing.resizing.Downsampler.radius = radius

Inradius of the window's rectangle.

If radius is an int, all axes will use this radius and the window is a square. For non-square windows, pass a tuple with a radius for each dimension of data_array. Along an axis, the window has a width of \(2r + 1\) for each element \(r\) of radius.

Definition at line 257 of file resizing.py.

◆ start_pixel

fosanalysis.preprocessing.resizing.Downsampler.start_pixel = start_pixel

Index of the first window's central pixel.

If start_pixel is an int, it is used for all dimensions of data_array. To specify a custom starting element, pass a tuple with a step size for each dimension of data_array. If None, it defaults to radius, the moving window starts with a full slice.

Definition at line 264 of file resizing.py.

◆ step_size

fosanalysis.preprocessing.resizing.Downsampler.step_size = step_size

Step size how far the window moves in one step.

If step_size is an int, it is used for all dimensions of data_array. If None, it defaults to \(2r + 1\) for each element \(r\) of radius, which is equivalent to a rolling window.

Definition at line 269 of file resizing.py.


The documentation for this class was generated from the following file: