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

Abstract base class for outlier detection by different kinds of z-scores. More...

Inheritance diagram for fosanalysis.preprocessing.masking.ZSOD:

Public Member Functions

 __init__ (self, float threshold=3.5, str timespace="1d_space", *args, **kwargs)
 Construct an instance of the class.
 
- Public Member Functions inherited from fosanalysis.preprocessing.masking.AnomalyMasker
np.array run (self, np.array x, np.array y, np.array z, bool make_copy=True, str timespace=None, bool identify_only=False, *args, **kwargs)
 Mask strain reading anomalies with NaNs.
 
- 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

 threshold = threshold
 Relative height threshold above which a pixel is flagged as SRA.
 

Protected Member Functions

np.array _get_outlier_mask (self, np.array z_score)
 Mask entries as SRA, whose z-scores exceed threshold.
 
np.array _get_z_score (self, np.array z)
 Calculate the z-score for the given array.
 
tuple _run_1d (self, np.array x, np.array z, np.array SRA_array, *args, **kwargs)
 Estimate which entries are strain reading anomalies in 1D.
 
tuple _run_2d (self, np.array x, np.array y, np.array z, np.array SRA_array, *args, **kwargs)
 Estimate which entries are strain reading anomalies in 2D.
 
- Protected Member Functions inherited from fosanalysis.preprocessing.masking.AnomalyMasker
tuple _map_2d (self, np.array x, np.array y, np.array z, np.array SRA_array, str timespace=None, *args, **kwargs)
 Estimate, which entries are strain reading anomalies, in 2D.
 

Detailed Description

Abstract base class for outlier detection by different kinds of z-scores.

After calculating the z-score by the given _get_z_score(), SRAs are identified by comparing the strain increments to a threshold. The algorithms only make sense for sufficient measuring values (not NaN). An overview of all z-score calculations can be found at https://towardsdatascience.com/removing-spikes-from-raman-spectra-8a9fdda0ac22

Definition at line 579 of file masking.py.

Constructor & Destructor Documentation

◆ __init__()

fosanalysis.preprocessing.masking.ZSOD.__init__ ( self,
float threshold = 3.5,
str timespace = "1d_space",
* args,
** kwargs )

Construct an instance of the class.

Parameters
thresholdRelative height threshold above which a pixel is flagged as SRA.

Defaults to 3.5.

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

Definition at line 588 of file masking.py.

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

Member Function Documentation

◆ _get_outlier_mask()

np.array fosanalysis.preprocessing.masking.ZSOD._get_outlier_mask ( self,
np.array z_score )
protected

Mask entries as SRA, whose z-scores exceed threshold.

Parameters
z_scoreArray containing the z-score values.
Returns
Boolean array with values as outlier mask.

Definition at line 628 of file masking.py.

Here is the caller graph for this function:

◆ _get_z_score()

np.array fosanalysis.preprocessing.masking.ZSOD._get_z_score ( self,
np.array z )
protected

Calculate the z-score for the given array.

Sub-classes need to provide a meaningful implementation.

Reimplemented in fosanalysis.preprocessing.masking.ModifiedZscoreDetection, fosanalysis.preprocessing.masking.SlidingModifiedZscore, fosanalysis.preprocessing.masking.WhitakerAndHayes, and fosanalysis.preprocessing.masking.ZscoreOutlierDetection.

Definition at line 637 of file masking.py.

Here is the caller graph for this function:

◆ _run_1d()

tuple fosanalysis.preprocessing.masking.ZSOD._run_1d ( self,
np.array x,
np.array z,
np.array SRA_array,
* args,
** kwargs )
protected

Estimate which entries are strain reading anomalies in 1D.

This operation might be applied to on a 2D array by _map_2d(). This function is called, if:

  • the z is 1D or
  • timespace is set to "1d_space" or "1d_time".
    Parameters
    xArray of coordinate positions. Dependent on timespace it may hold:
    • x: sensor coordinates, (timespace = "1d_space")
    • y: time data (timespace = "1d_time")
    • indices, if none of both previous options match the z's shape.
    zArray of strain data in accordance to x and y.
    *argsAdditional positional arguments to customize the behaviour.
    **kwargsAdditional keyword arguments to customize the behaviour.
    Returns
    Returns a tuple like (x, z). They correspond to the input variables of the same name. Each of those might be changed.
    Parameters
    SRA_arrayArray of boolean values indicating SRAs by True and a valid entries by False. This function returns the SRA_array instead of the z array.

Reimplemented from fosanalysis.preprocessing.masking.AnomalyMasker.

Definition at line 603 of file masking.py.

Here is the call graph for this function:

◆ _run_2d()

tuple fosanalysis.preprocessing.masking.ZSOD._run_2d ( self,
np.array x,
np.array y,
np.array z,
np.array SRA_array,
* args,
** kwargs )
protected

Estimate which entries are strain reading anomalies in 2D.

Needs to be reimplemented by sub-classes. This function is only called, if z is 2D and timespace is "2D".

Parameters
xArray of measuring point positions.
yArray of time stamps.
zArray of strain data in accordance to x and y.
*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. Each of those might be changed.
Parameters
SRA_arrayArray of boolean values indicating SRAs by True and a valid entries by False. This function returns the SRA_array instead of the z array.

Reimplemented from fosanalysis.preprocessing.masking.AnomalyMasker.

Definition at line 615 of file masking.py.

Here is the call graph for this function:

Member Data Documentation

◆ threshold

fosanalysis.preprocessing.masking.ZSOD.threshold = threshold

Relative height threshold above which a pixel is flagged as SRA.

Defaults to 3.5.

Definition at line 602 of file masking.py.


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