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

Abstract class for anomaly identification. More...

Inheritance diagram for fosanalysis.preprocessing.masking.AnomalyMasker:

Public Member Functions

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.
 

Protected Member Functions

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.
 
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)
 Native two-dimensional operation implementation.
 

Detailed Description

Abstract class for anomaly identification.

Strain reading anomalies (SRAs) are implausible data points. SRAs are replaced by NaN values, effectively marking them as dropouts.

Definition at line 19 of file masking.py.

Member Function Documentation

◆ _map_2d()

tuple fosanalysis.preprocessing.masking.AnomalyMasker._map_2d ( self,
np.array x,
np.array y,
np.array z,
np.array SRA_array,
str timespace = None,
* args,
** kwargs )
protected

Estimate, which entries are strain reading anomalies, in 2D.

Apply the 1D operation along either the space or time timespace.

Used for carrying out 1D-only algorithms on a 2D array row- or column-wise.

Parameters
xArray of measuring point positions.
yArray of time stamps.
zArray of strain data in accordance to x and y.
timespaceFor more, see timespace. Defaults to timespace.
*argsAdditional positional arguments to customize the behaviour. Will be passed to the chosen method to call.
**kwargsAdditional keyword arguments to customize the behaviour. Will be passed to the chosen method to call.
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.

Definition at line 80 of file masking.py.

Here is the call graph for this function:

◆ _run_1d()

tuple fosanalysis.preprocessing.masking.AnomalyMasker._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 in fosanalysis.preprocessing.masking.GTM, fosanalysis.preprocessing.masking.OSCP, and fosanalysis.preprocessing.masking.ZSOD.

Definition at line 55 of file masking.py.

Here is the caller graph for this function:

◆ _run_2d()

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

Native two-dimensional operation implementation.

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 in fosanalysis.preprocessing.masking.GTM, fosanalysis.preprocessing.masking.OSCP, and fosanalysis.preprocessing.masking.ZSOD.

Definition at line 68 of file masking.py.

◆ run()

np.array fosanalysis.preprocessing.masking.AnomalyMasker.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.

The strain data is replaced by NaN for all entries in the returned array being True.

Parameters
identify_onlyIf set to true, the array contains boolean values, indicating a SRA by True and a valid entry by False.

The actual operations are reimplemented in _run_1d() and _run_2d(). This method decides based on the argument, how is operated over the data. If z is a 1D array, the array to pass to _run_1d() is determined:

  1. Use x as the coordinate data, if it matches the shape of z.
  2. Use y as the coordinate data, if it matches the shape of z.
  3. Generate an array with indices of the shape of z.

If z is a 2D array, three option are available, based on timespace:

Parameters
xArray of measuring point positions.
yArray of time stamps.
zArray of strain data in accordance to x and y.
timespaceFor more, see timespace. Defaults to timespace.
make_copySwitch, whether a deepcopy of the passed data should be done. Defaults to True.
*argsAdditional positional arguments to customize the behaviour. Will be passed to the chosen method to call.
**kwargsAdditional keyword arguments to customize the behaviour. Will be passed to the chosen method to call.
Returns
Returns a tuple like (x, y, z). They correspond to the input variables of the same name. Each of those might be changed.

Definition at line 25 of file masking.py.

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

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