|
fosanalysis
A framework to evaluate distributed fiber optic sensor data
|
Abstract base class for outlier detection by different kinds of z-scores. More...
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. | |
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.
| fosanalysis.preprocessing.masking.ZSOD.__init__ | ( | self, | |
| float | threshold = 3.5, | ||
| str | timespace = "1d_space", | ||
| * | args, | ||
| ** | kwargs ) |
Construct an instance of the class.
| threshold | Relative height threshold above which a pixel is flagged as SRA. |
Defaults to 3.5.
| timespace | |
| *args | Additional positional arguments, will be passed to the superconstructor. |
| **kwargs | Additional keyword arguments, will be passed to the superconstructor. |
Definition at line 588 of file masking.py.
|
protected |
Mask entries as SRA, whose z-scores exceed threshold.
| z_score | Array containing the z-score values. |
Definition at line 628 of file masking.py.
|
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.
|
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:
z is 1D or"1d_space" or "1d_time". | x | Array of coordinate positions. Dependent on timespace it may hold:
|
| z | Array of strain data in accordance to x and y. |
| *args | Additional positional arguments to customize the behaviour. |
| **kwargs | Additional keyword arguments to customize the behaviour. |
(x, z). They correspond to the input variables of the same name. Each of those might be changed. | SRA_array | Array 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.
|
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".
| x | Array of measuring point positions. |
| y | Array of time stamps. |
| z | Array of strain data in accordance to x and y. |
| *args | Additional positional arguments to customize the behaviour. |
| **kwargs | Additional keyword arguments to customize the behaviour. |
(x, y, z). They correspond to the input variables of the same name. Each of those might be changed. | SRA_array | Array 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.
| 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.