wradlib.classify.ClassifyMethods#
- class wradlib.classify.ClassifyMethods(obj)[source]#
Bases:
XarrayMethods
wradlib xarray SubAccessor methods for Classify.
- filter_gabella(**kwargs)[source]#
Clutter identification filter developed by [Gabella et al., 2002].
This is a two-part identification algorithm using echo continuity and minimum echo area to distinguish between meteorological (rain) and non- meteorological echos (ground clutter etc.)
- Parameters
obj (
xarray.DataArray
)- Keyword Arguments
wsize (
int
) – Size of the window surrounding the central pixelthrsnorain (
float
) –tr1 (
float
) –n_p (
int
) –tr2 (
float
) –rm_nans (
bool
) – True replaces nans with Inf False takes nans into acountradial (
bool
) – True to use radial information only infilter_gabella_a
.cartesian (
bool
) – True if cartesian data are used, polar assumed if False.
- Returns
output (
xarray.DataArray
) – boolean array with pixels identified as clutter set to True.
See also
Examples
- filter_gabella_a(**kwargs)[source]#
First part of the Gabella filter looking for large reflectivity gradients.
This function checks for each pixel in
img
how many pixels surrounding it in a window ofwsize
are bytr1
smaller than the central pixel.- Parameters
obj (
xarray.DataArray
) – radar image to which the filter is to be applied- Keyword Arguments
- Returns
out (
xarray.DataArray
) – an array with the same shape asimg
, containing the filter’s results.
See also
Examples
- filter_gabella_b(**kwargs)[source]#
Second part of the Gabella filter comparing area to circumference of contiguous echo regions.
- Parameters
obj (
xarray.DataArray
)- Keyword Arguments
thrs (
float
) – Threshold below which the field values will be considered as no rain- Returns
out (
xarray.DataArray
) – contains in each pixel the ratio between area and circumference of the meteorological echo it is assigned to or 0 for non precipitation pixels.
See also
Examples
- histo_cut(**kwargs)[source]#
Histogram based clutter identification.
This identification algorithm uses the histogram of temporal accumulated rainfall. It iteratively detects classes whose frequency falls below a specified percentage (1% by default) of the frequency of the class with the biggest frequency and remove the values from the dataset until the changes from iteration to iteration falls below a threshold. This algorithm is able to detect static clutter as well as shadings.
The tresholds for the upper frequency (clutter) and the lower frequency (shading) can be parameterized by the respective kwargs, upper_frequency/lower_frequency.
It is suggested to choose a representative time periode for the input precipitation accumulation. The recommended time period should cover one year.
- Parameters
obj (
xarray.DataArray
) – spatial array containing rain accumulation- Keyword Arguments
- Returns
output (
xarray.DataArray
) – uint8 array with pixels identified as clutter set to 1 and shadings set to 2. Remaining pixels set to 0. Users strictly relying on a boolean mask might have to explicitely cast to boolean (adding .astype(np.bool) on the return).
Examples
See Heuristic clutter detection based on distribution properties ("histo cut").
- classify_echo_fuzzy(dat, **kwargs)[source]#
Fuzzy echo classification and clutter identification based on polarimetric moments.
The implementation is based on [Vulpiani et al., 2012]. At the moment, it only distinguishes between meteorological and non-meteorological echos.
For Clutter Phase Alignment (CPA) see [Hubbert et al., 2009a] and [Hubbert et al., 2009b]
For each decision variable and radar bin, the algorithm uses trapezoidal functions in order to define the membership to the non-meteorological echo class. Based on pre-defined weights, a linear combination of the different degrees of membership is computed. The echo is assumed to be non-meteorological in case the linear combination exceeds a threshold.
- At the moment, the following decision variables are considered:
Texture of differential reflectivity (zdr) (mandatory)
Texture of correlation coefficient (rho) (mandatory)
Texture of differential propagation phase (phidp) (mandatory)
Doppler velocity (dop) (mandatory)
Static clutter map (map) (mandatory)
Correlation coefficient (rho2) (additional)
Depolarization Ratio (dr), computed from correlation coefficient & differential reflectivity (additional)
clutter phase alignment (cpa) (additional)
- Parameters
obj (
xarray.Dataset
)dat (
dict
) – Mapping of moment names.
- Keyword Arguments
weights (
dict
) – dictionary of floats. Defines the weights of the decision variables. Default is: zdr: 0.4, rho: 0.4, phi: 0.1, dop: 0.1, map: 0.5, rho2: 0.4, dr: 0.4, cpa: 0.4.trpz (
dict
) – dictionary of lists of floats. Contains the arguments of the trapezoidal membership functions for each decision variable. Default is: zdr: [0.7, 1.0, 9999, 9999], rho: [0.1, 0.15, 9999, 9999], phi: [15, 20, 10000, 10000], dop: [-0.2, -0.1, 0.1, 0.2], map: [1, 1, 9999, 9999], rho2: [-9999, -9999, 0.95, 0.98], dr: [-20, -12, 9999, 9999], cpa: [0.6, 0.9, 9999, 9999].
- Returns
prob (
xarray.DataArray
) – DataArray indicating probability of meteorological echos based on the fuzzy classification.mask (
xarray.DataArray
) – DataArray indicating where all the polarimetric moments had missing values which could be used as an additional information criterion.
See also
- filter_window_distance(**kwargs)[source]#
2d filter looking for large reflectivity gradients.
This function counts for each bin in
img
the percentage of surrounding bins in a window of half sizefsize
which are nottr1
smaller than the central bin. The window is defined using geometrical distance.- Parameters
obj (
xarray.DataArray
|xarray.Dataset
) – 2d polar data to which the filter is to be applied- Keyword Arguments
- Returns
output (
xarray.DataArray
|xarray.Dataset
) – an array with the same shape asimg
, containing the filter’s results.
See also
- probability(weights)[source]#
Calculate probability of hmc-class for every data bin.
- Parameters
data (
xarray.Dataset
) – Dataset containing the membership probability values.weights (
numpy.ndarray
) – Array of length (observables) containing the weights for each observable.
- Returns
out (
xarray.DataArray
) – Array containing weighted hmc-membership probabilities.
- classify(threshold=0.0)[source]#
Calculate probability of hmc-class for every data bin.
- Parameters
data (
np.ndarray
) – Array which is of size (hmc-class, data.shape), containing the weighted hmc-membership probability values.- Keyword Arguments
threshold (
float
) – Threshold value where probability is considered no precip, defaults to 0- Returns
out (
xr.DataArray
) – DataArray containing probability scores. No precip is added on the top.
|
Calculate probability of hmc-class for every data bin. |
|
Fuzzy echo classification and clutter identification based on polarimetric moments. |
|
Clutter identification filter developed by [Gabella et al., 2002]. |
|
First part of the Gabella filter looking for large reflectivity gradients. |
|
Second part of the Gabella filter comparing area to circumference of contiguous echo regions. |
|
2d filter looking for large reflectivity gradients. |
|
|
|
Histogram based clutter identification. |
|
|
|
Calculate probability of hmc-class for every data bin. |