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

Change the dimension of an array using aggregate functions (such as mean, median, min or max). More...

Inheritance diagram for fosanalysis.preprocessing.resizing.Aggregate:

Public Member Functions

 __init__ (self, str or callable method, module=np, str timespace="1d_space", *args, **kwargs)
 Construct an instance of the class.
 
np.array reduce (self, np.array data, int axis, *args, **kwargs)
 Reduce the given array using the kernel funcition.
 
np.array run (self, np.array x, np.array y, np.array z, str timespace=None, bool make_copy=True, *args, **kwargs)
 Reduce a 2D array to a 1D array using aggregate functions.
 
 setup (self, str or callable method, module=np)
 Set the kernel method for data processing, which can be either a string representing function name in a given namespace module or a custom callable function.
 
- 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

 kernel = method if callable(method) else getattr(module, method)
 Callable function used to aggregate the data.
 
 method = method
 Could be either a callable (function object) or a string representing a function name in the namespace of module.
 
 module = module
 A Python module or namespace in which method is looked up when method is not a callable.
 
 timespace = timespace
 Setting, how to compact the 2d array.
 

Detailed Description

Change the dimension of an array using aggregate functions (such as mean, median, min or max).

It can be used to reduce 2D to 1D strain data.

Definition at line 34 of file resizing.py.

Constructor & Destructor Documentation

◆ __init__()

fosanalysis.preprocessing.resizing.Aggregate.__init__ ( self,
str or callable method,
module = np,
str timespace = "1d_space",
* args,
** kwargs )

Construct an instance of the class.

Parameters
methodA string or callable representing the method.
moduleThe module (default is numpy).
timespaceSetting, how to compact the 2d array. For more, see timespace.
*argsAdditional positional arguments, will be passed to the superconstructor.
**kwargsAdditional keyword arguments, will be passed to the superconstructor.

Definition at line 40 of file resizing.py.

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

Member Function Documentation

◆ reduce()

np.array fosanalysis.preprocessing.resizing.Aggregate.reduce ( self,
np.array data,
int axis,
* args,
** kwargs )

Reduce the given array using the kernel funcition.

Parameters
dataArray of data with functional data according to data.
axisAxis in which the data should be consolidated. This is in accordance with the numpy axis definitions.
*argsAdditional positional arguments, passed to kernel.
**kwargsAdditional keyword arguments, passed to kernel.
Returns
Returns an array, where multiple readings are combined to one single array.

Definition at line 136 of file resizing.py.

Here is the caller graph for this function:

◆ run()

np.array fosanalysis.preprocessing.resizing.Aggregate.run ( self,
np.array x,
np.array y,
np.array z,
str timespace = None,
bool make_copy = True,
* args,
** kwargs )

Reduce a 2D array to a 1D array using aggregate functions.

The aggregate function is implemented in reduce(). The array of the crushed axis is set to np.array(None).

Parameters
xArray of measuring point positions.
yArray of time stamps.
zArray of strain data in accordance to x and y.
timespaceSetting, how to compact the 2d array. For more, see timespace.
make_copySwitch, whether a deepcopy of the passed data should be done. Defaults to True.
*argsAdditional positional arguments to customize the behaviour.
**kwargsAdditional keyword arguments to customize the behaviour.
Returns
Returns a tuple like (x, y, z). They correspond to the input variables of the same name. The resulting shape of the return values depending on timespace is as follows:
"timespace" x y z
"1d_space" x np.array(None) 1d array, same size as x
"1d_time" np.array(None) y 1d array, same size as y
"2d" np.array(None) np.array(None) np.array(float)

Reimplemented from fosanalysis.preprocessing.base.Base.

Definition at line 90 of file resizing.py.

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

◆ setup()

fosanalysis.preprocessing.resizing.Aggregate.setup ( self,
str or callable method,
module = np )

Set the kernel method for data processing, which can be either a string representing function name in a given namespace module or a custom callable function.

If "method" is a string, retrieve the corresponding function from the specified module. If "method" is a custom callable function, directly set it as the processing method.

Parameters
methodCould be either a callable (function object) or a string representing a function name in the namespace of module.
Parameters
moduleA Python module or namespace in which method is looked up when method is not a callable.

Defaults to Numpy (np).

Definition at line 69 of file resizing.py.

Member Data Documentation

◆ kernel

fosanalysis.preprocessing.resizing.Aggregate.kernel = method if callable(method) else getattr(module, method)

Callable function used to aggregate the data.

Use setup to set it.

Definition at line 89 of file resizing.py.

◆ method

fosanalysis.preprocessing.resizing.Aggregate.method = method

Could be either a callable (function object) or a string representing a function name in the namespace of module.

Definition at line 83 of file resizing.py.

◆ module

fosanalysis.preprocessing.resizing.Aggregate.module = module

A Python module or namespace in which method is looked up when method is not a callable.

Defaults to Numpy (np).

Definition at line 86 of file resizing.py.

◆ timespace

fosanalysis.preprocessing.resizing.Aggregate.timespace = timespace

Setting, how to compact the 2d array.

Available options:

  • "1d_space": (default): Reduce the temporal component and keep the spatial component by aggregating several readings into a single reading. Results in a 1D array of the same size as x.
  • "1d_time": Reduce the spatial component and keep the temporal component by aggregating several time series into a single time series. Results in a 1D array of the same size as y.
  • "2d": Compact data into a single value. Both spatial and temporal component are reduced. Results in a 0D array with a single element.

Definition at line 67 of file resizing.py.


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