pylawr.transform.filter#
Abstract base class for clutter filters |
|
|
Class to transform/filter the RadarField on basis of a clutter map, calculated with calc_cluttermap of ClutterFilter |
Calculates gradients of consecutive range gates for clutter detection. |
|
|
Calculates the Signal-to-Noise ratio. |
The speckle filter checks the number of rain pixels in a neighborhood. |
|
Calculates gradients of consecutive radar beams for clutter detection. |
|
Calculate SPIN change of the reflectivity for clutter detection according to Hubbert et al. (2009). |
|
Calculate texture of reflectivity (TDBZ) for clutter detection according to Hubbert et al. (2009). |
|
The temporal clutter filter compares current radar image with n-saved radar images. |
pylawr.transform.filter.clutterfilter.ClutterFilter#
- class pylawr.transform.filter.clutterfilter.ClutterFilter(threshold)[source]#
Bases:
ABCAbstract base class for clutter filters
- _abc_impl = <_abc._abc_data object>#
- abstract calc_map(refl)[source]#
Computes field for detecting clutter based on the filter.
- Parameters
refl (
xarray.DataArray) – The reflectivity array to operate on.
- abstract create_cluttermap(refl=None)[source]#
Creates clutter map based on the field and threshold.
- Returns
cmap (
ClutterMap) – The cluttermap of_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).refl (
xarray.DataArray) – The reflectivity array to operate on.
pylawr.transform.filter.ClutterMap#
- class pylawr.transform.filter.ClutterMap(name=None, cmap=None, fuzzy_threshold=1)[source]#
Bases:
TransformerClass to transform/filter the RadarField on basis of a clutter map, calculated with calc_cluttermap of ClutterFilter
- Parameters
name (string) – The name of used clutter filter.
cmap (
numpy.ndarray) – Probability of clutter for each grid point.fuzzy_threshold (float) – Relative value to the number of clutter maps, which indicate clutter, to fulfill clutter condition. The interval of this fuzzy threshold is [0, 1]. A value of 1 describes that every cluttermap has to detect clutter so that this value is filtered out.
- layers#
Dictionary with zero to many clutter maps
- weights#
Dictionary with the weights to corresponding clutter maps.
- fuzzy_threshold#
Relative value to the number of clutter maps, which indicate clutter, to fulfill clutter condition. The interval of this fuzzy threshold is [0, 1]. A value of 1 describes that every cluttermap has to detect clutter so that this value is filtered out.
- Type
- _abc_impl = <_abc._abc_data object>#
- append(other_clutter)[source]#
Appends an other instance of
pylawr.filter.cluttermap.ClutterMapto this instance.- Parameters
other_clutter (
pylawr.filter.cluttermap.ClutterMap) – Some instance of this class. The layers of this class are used to update the layers of this cluttermap.
- property array#
Get the values of the cluttermaps as array.
- Returns
layer_array – The concatenated values of the different cluttermaps in preserved order. The cluttermaps are concatenated over a new first dimension.
- Return type
- mean()[source]#
Get the weighted mean of this cluttermap. The cluttermap is weighted with set weights.
- Returns
mean_values – The weighted mean values with the same shape as a single cluttermap.
- Return type
py:class:numpy.ndarray
- transform(array, *args, **kwargs)[source]#
Transform a given
arraywith a polar grid according to theClutterMapobject. The clutter maps in the layers attribute are applied on the radar field. If the number of clutter maps are greater or equal to the fuzzy threshold at a specific grid point, clutter is detected.- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.- Returns
transformed_array – The array with removed clutter as NaN-values
- Return type
pylawr.transform.filter.RINGFilter#
- class pylawr.transform.filter.RINGFilter(threshold=3.0, window_size=11, window_criterion=0.5, ring_width=1)[source]#
Bases:
ClutterFilterCalculates gradients of consecutive range gates for clutter detection. If the difference between consecutive range gates exceeds a threshold for percentage (window_criterion) of consecutive beams within a window, the gate is identified as clutter. This filter is similar to the SPKFilter, only the axis is changed.
With the default parameters a ring of six consecutive beams is identified as clutter.
- _abc_impl = <_abc._abc_data object>#
- calc_map(array)[source]#
Computes ring field for detecting clutter. The procedure deals also with arrays containing NaN values. The map is the number of threshold exceeds within the window for this gate.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.
- create_cluttermap(array=None, addname='')[source]#
Creates clutter map based on the field and threshold.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.addname (str) – Supplement to the name of the created
ClutterMap(should be unique), otherwise appended cluttermaps overwrite the results.
- Returns
cmap – The cluttermap of
_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).- Return type
pylawr.transform.filter.SNR#
- class pylawr.transform.filter.SNR(threshold=0)[source]#
Bases:
ClutterFilterCalculates the Signal-to-Noise ratio.
- _abc_impl = <_abc._abc_data object>#
- calc_map(array, noise_remover)[source]#
Computes Signal-to-Noise ratio. The array should not corrected for beam expansion.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.noise_remover (
NoiseRemoverobject) – ActualNoiseRemoverwhich operates on RadarField
- create_cluttermap(array=None, noise_remover=None)[source]#
Creates clutter map based on the field and threshold.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.noise_remover (
NoiseRemover) – ActualNoiseRemoverwhich operates on RadarField
- Returns
cmap – The Cluttermap of
_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).- Return type
pylawr.transform.filter.SpeckleFilter#
- class pylawr.transform.filter.SpeckleFilter(threshold=2, window_size=(3, 3))[source]#
Bases:
ClutterFilterThe speckle filter checks the number of rain pixels in a neighborhood. If this number of rain pixels is lower than a given threshold, this pixel is declared as clutter. The boundary is zero-padded.
- _abc_impl = <_abc._abc_data object>#
- calc_map(array)[source]#
This method estimates the number of rain pixels in the neighborhood and if the center pixel is also a rain pixel.
- Parameters
array (
xarray.DataArray) – This data array is used to determine the number of rain pixels and is used to estimate the raw cluttermap without threshold.
- create_cluttermap(array=None, addname='')[source]#
Creates clutter map based on field, set neighborhood size and set threshold. If the number of rain pixels in the neighborhood is lower than given threshold, the center pixel is declared as clutter.
- Parameters
array (
xarray.DataArrayor None, optional) – This data array is used to determine the number of rain pixels and is used to estimate the cluttermap. If this is None (default), the stored clutter map is used.addname (str) – Supplement to the name of the created
ClutterMap(should be unique), otherwise appended ClutterMaps overwrite the results.
- Returns
cmap – The Cluttermap of
_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).- Return type
pylawr.transform.filter.clutter.ClutterMap
- property window_product#
pylawr.transform.filter.SPKFilter#
- class pylawr.transform.filter.SPKFilter(threshold=3.0, window_size=11, window_criterion=0.5, spike_width=1)[source]#
Bases:
ClutterFilterCalculates gradients of consecutive radar beams for clutter detection. If the difference between consecutive radar beams exceed a threshold for percentage (window_criterion) of consecutive range gates within a window, the gate is identified as clutter. This filter is similar to the RINGFilter, only the axis is changed.
With the default parameters a spike if six consecutive range gates is identified as clutter.
- _abc_impl = <_abc._abc_data object>#
- calc_map(array)[source]#
Computes spike field for detecting clutter. The procedure deals also with arrays containing NaN values. The map is the number of threshold exceeds within the window for this gate.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.
- create_cluttermap(array=None, addname='')[source]#
Creates clutter map based on the field and threshold.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.addname (str) – Supplement to the name of the created
ClutterMap(should be unique), otherwise appended cluttermaps overwrite the results.
- Returns
cmap – The cluttermap of
_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).- Return type
pylawr.transform.filter.SPINFilter#
- class pylawr.transform.filter.SPINFilter(threshold=3, window_size=11, window_criterion=0.1)[source]#
Bases:
ClutterFilterCalculate SPIN change of the reflectivity for clutter detection according to Hubbert et al. (2009).
- _abc_impl = <_abc._abc_data object>#
- calc_map(array)[source]#
Computes SPIN field for detecting clutter. The SPIN feature field is a measure of how often the reflectivity gradient changes sign along the distance. The procedure deals also with arrays containing NaN values.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.
- create_cluttermap(array=None, addname='')[source]#
Creates clutter map based on the field and window criteria. If both criteria of the SPIN filter are fulfilled in more than self._wc percent of the consecutive range gates, the centre range gate is flagged as clutter.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.addname (str) – Supplement to the name of the created
ClutterMap(should be unique), otherwise appended cluttermaps overwrite the results.
- Returns
cmap – The cluttermap of
_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).- Return type
pylawr.transform.filter.TDBZFilter#
- class pylawr.transform.filter.TDBZFilter(threshold=3.0, window_size=5)[source]#
Bases:
ClutterFilterCalculate texture of reflectivity (TDBZ) for clutter detection according to Hubbert et al. (2009).
- _abc_impl = <_abc._abc_data object>#
- calc_map(array)[source]#
Computes TDBZ field for detecting clutter. The TDBZ field is computed as the average of the squared logarithmic reflectivity difference between adjacent range gates. The procedure deals also with arrays containing NaN values.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.
- create_cluttermap(array=None, addname='')[source]#
Creates clutter map based on the field and threshold.
- Parameters
array (
xarray.DataArray) – The reflectivity array to operate on.addname (str) – Supplement to the name of the created
ClutterMap(should be unique), otherwise appended cluttermaps overwrite the results.
- Returns
cmap – The cluttermap of
_mapto transform the reflectivity, contains probabilities of clutter (between one and zero).- Return type
pylawr.transform.filter.TemporalFilter#
- class pylawr.transform.filter.TemporalFilter(store_n_images=3, threshold=3)[source]#
Bases:
MemoryMixin,ClutterFilterThe temporal clutter filter compares current radar image with n-saved radar images. If the number of rain pixels within the last n-images is below a given threshold, then the pixel is identified as clutter. In this implementation
fitandcalc_mapare split, because they are applied at different times: fit is normally applied before any clutter is removed and calc map is only used to identify current rain pixels and can be applied at any time, also after removing some clutter.- Parameters
store_n_images (int, optional) – This number of images (default=3) is stored within this clutter filter.
threshold (int, optional) – This threshold (default=3) is used to decide if a rain pixel is clutter or not. If the number of rain pixels within the stored images is below this threshold, the rain pixel is identified as clutter.
Notes
fit()should be normally applied before any other clutter filter was applied, whilecalc_map()can be used anywhere.- _abc_impl = <_abc._abc_data object>#
- calc_map(array)[source]#
This converts given array to rain pixels and sets this rain array as current map. This method set current map independent from
fit().- Parameters
array (
xarray.DataArray) – This array is converted into rain pixels.
- create_cluttermap(array=None, addname='')[source]#
This method creates the cluttermap based on historic rain maps, current rain map and set threshold.
- Parameters
array (
xarray.DataArrayor None, optional) – If this array is given, then this will be converted into rain pixels and set as current map.addname (str) – Supplement to the name of the created ClutterMap (should be unique), otherwise appended ClutterMaps overwrite the results.
- Returns
clutter_map – This is the cluttermap of this filter, dependent on stored images.
- Return type
Notes
If the number of stored images is lower than the set attribute
store_n_images, an empty clutter map will be returned.
- fit(array)[source]#
This fit method sets the history maps, which are used to determine clutter. Also the maps are constrained to the last n-maps. This method is independent from
calc_map().- Parameters
array (
xarray.DataArray) – This array is concatenated to the historic maps.
- property fitted#
If the number of stored images equals the set number of stored images.
- Returns
fitted – If the number of stored images equals the set number of stored images.
- Return type
- to_xarray()[source]#
Serialize this filter’s parameters to an
xarray.Dataset- Returns
the filter’s parameters as dataset
- Return type