Estimate the parameters of an exponential distribution given histogram data.
Parameters:
counts (array-like) – The counts for each bin in the histogram.
Lambda (float) – The initial guess of the scale parameter.
scale = 1 / lambda correspond to the scale parameter of the scipy.stats.expon distribution.
A good default value is 1.
bin_edges (array-like) – The edges of the bins.
probability_method (str, optional) – The method to compute probabilities, either "cdf" or "pdf". The default value is "cdf".
likelihood (str, optional) – The likelihood function to use, either "multinomial" or "poisson".
The default value is "multinomial".
truncated_likelihood (bool, optional) – Whether to use truncated likelihood. The default value is True.
output_dictionary (bool, optional) – Whether to return the output as a dictionary.
If False, returns a numpy array. The default value is True
optimizer (str, optional) – The optimization method to use. Default is "Nelder-Mead".
Returns:
The estimated parameters of the exponential distribution.
If output_dictionary is True, returns a dictionary with keys N0 and Lambda.
If output_dictionary is False, returns a numpy array with [N0, Lambda].
Estimate the parameters of a gamma distribution given histogram data.
Parameters:
counts (array-like) – The counts for each bin in the histogram.
mu (float) – The initial guess of the shape parameter.
a = mu + 1 correspond to the shape parameter of the scipy.stats.gamma distribution.
A good default value is 0.
lambda (float) – The initial guess of the scale parameter.
scale = 1 / lambda correspond to the scale parameter of the scipy.stats.gamma distribution.
A good default value is 1.
bin_edges (array-like) – The edges of the bins.
probability_method (str, optional) – The method to compute probabilities, either "cdf" or "pdf". The default value is "cdf".
likelihood (str, optional) – The likelihood function to use, either "multinomial" or "poisson".
The default value is "multinomial".
truncated_likelihood (bool, optional) – Whether to use truncated likelihood. The default value is True.
output_dictionary (bool, optional) – Whether to return the output as a dictionary.
If False, returns a numpy array. The default value is True
optimizer (str, optional) – The optimization method to use. Default is "Nelder-Mead".
Returns:
The estimated parameters of the gamma distribution.
If output_dictionary is True, returns a dictionary with keys N0, mu and Lambda.
If output_dictionary is False, returns a numpy array with [N0, mu, Lambda].
where Lambda = 1/scale, and mu = a - 1 with a being the shape parameter of the gamma distribution.
N0 is defined as N0 = Nt*Lambda**(mu+1)/gamma(mu+1).
Estimate the parameters of a lognormal distribution given histogram data.
Parameters:
counts (array-like) – The counts for each bin in the histogram.
mu (float) – The initial guess of the mean of the log of the distribution.
A good default value is 0.
sigma (float) – The initial guess of the standard deviation of the log distribution.
A good default value is 1.
bin_edges (array-like) – The edges of the bins.
probability_method (str, optional) – The method to compute probabilities, either "cdf" or "pdf". The default value is "cdf".
likelihood (str, optional) – The likelihood function to use, either "multinomial" or "poisson".
The default value is "multinomial".
truncated_likelihood (bool, optional) – Whether to use truncated likelihood. The default value is True.
output_dictionary (bool, optional) – Whether to return the output as a dictionary.
If False, returns a numpy array. The default value is True
optimizer (str, optional) – The optimization method to use. Default is "Nelder-Mead".
Returns:
The estimated parameters of the lognormal distribution.
If output_dictionary is True, returns a dictionary with keys Nt, mu, and sigma.
If output_dictionary is False,returns a numpy array with values [Nt, mu, sigma].
The lognormal distribution is defined as:
N(D) = Nt / (sqrt(2 * pi) * sigma * D) * exp(-(ln(D) - mu)**2 / (2 * sigma**2))
where Nt is the total number of counts, mu is the mean of the log of the distribution,
and sigma is the standard deviation of the log of the distribution.
Compute the expected probabilities for each bin given the distribution parameters.
Parameters:
params (array-like) – Parameters for the CDF or PDF function.
cdf_func (callable) – Cumulative distribution function (CDF) that takes bin edges and parameters as inputs.
pdf_func (callable) – Probability density function (PDF) that takes a value and parameters as inputs.
bin_edges (array-like) – Edges of the bins for which to compute the probabilities.
probability_method ({'cdf', 'pdf'}) – Method to compute the probabilities. If ‘cdf’, use the CDF to compute probabilities.
If ‘pdf’, integrate the PDF over each bin range.
normalized (bool, optional) – If True, normalize the probabilities to sum to 1. Default is False.
Returns:
expected_probabilities – Array of expected probabilities for each bin.
Estimate the parameters of an exponential particle size distribution (PSD) from the given dataset.
Fitting this model is equivalent to fitting a GammaPSD model fixing mu to 0.
Parameters:
ds (xarray.Dataset) – Input dataset containing drop number concentration data and diameter information.
It must include the following variables:
- drop_number_concentration: The number concentration of drops.
- diameter_bin_width”: The width of each diameter bin.
- diameter_bin_lower: The lower bounds of the diameter bins.
- diameter_bin_upper: The upper bounds of the diameter bins.
- diameter_bin_center: The center values of the diameter bins.
probability_method (str, optional) – Method to compute probabilities. The default value is cdf.
likelihood (str, optional) – Likelihood function to use for fitting. The default value is multinomial.
truncated_likelihood (bool, optional) – Whether to use truncated likelihood. The default value is True.
optimizer (str, optional) – Optimization method to use. The default value is Nelder-Mead.
Returns:
Dataset containing the estimated expontial distribution parameters:
- N0: Intercept parameter.
- Lambda: Scale parameter.
The resulting dataset will have an attribute disdrodb_psd_model set to ExponentialPSD.
Compute exponential distribution parameters following Testud 2001.
References
Testud, J., S. Oury, R. A. Black, P. Amayenc, and X. Dou, 2001:
The Concept of “Normalized” Distribution to Describe Raindrop Spectra:
A Tool for Cloud Physics and Cloud Remote Sensing.
J. Appl. Meteor. Climatol., 40, 1118-1140,
https://doi.org/10.1175/1520-0450(2001)040<1118:TCONDT>2.0.CO;2
Input dataset containing drop size distribution data. It must include the following variables:
- drop_number_concentration: The number concentration of drops.
- diameter_bin_width”: The width of each diameter bin.
- diameter_bin_lower: The lower bounds of the diameter bins.
- diameter_bin_upper: The upper bounds of the diameter bins.
- diameter_bin_center: The center values of the diameter bins.
- The moments M0…M6 variables required to compute the initial parameters
with the specified mom_method.
init_method (str or list) – The method(s) of moments used to initialize the gamma parameters.
If None (or ‘None’), the scale parameter is set to 1 and mu to 0 (a=1).
probability_method (str, optional) – Method to compute probabilities. The default value is cdf.
likelihood (str, optional) – Likelihood function to use for fitting. The default value is multinomial.
truncated_likelihood (bool, optional) – Whether to use truncated likelihood. The default value is True.
optimizer (str, optional) – Optimization method to use. The default value is Nelder-Mead.
Returns:
Dataset containing the estimated gamma distribution parameters:
- N0: Intercept parameter.
- mu: Shape parameter.
- Lambda: Scale parameter.
The dataset will also have an attribute disdrodb_psd_model set to GammaPSD.
Compute gamma distribution parameters following Cao et al., 2009.
References
Cao, Q., and G. Zhang, 2009:
Errors in Estimating Raindrop Size Distribution Parameters Employing Disdrometer and Simulated Raindrop Spectra.
J. Appl. Meteor. Climatol., 48, 406-425, https://doi.org/10.1175/2008JAMC2026.1.
Compute gamma distribution parameters following Cao et al., 2009.
References
Cao, Q., and G. Zhang, 2009:
Errors in Estimating Raindrop Size Distribution Parameters Employing Disdrometer and Simulated Raindrop Spectra.
J. Appl. Meteor. Climatol., 48, 406-425, https://doi.org/10.1175/2008JAMC2026.1.
Compute gamma distribution parameters following Ulbrich 1998.
References
Ulbrich, C. W., and D. Atlas, 1998:
Rainfall Microphysics and Radar Properties: Analysis Methods for Drop Size Spectra.
J. Appl. Meteor. Climatol., 37, 912-923,
https://doi.org/10.1175/1520-0450(1998)037<0912:RMARPA>2.0.CO;2
Cao, Q., and G. Zhang, 2009:
Errors in Estimating Raindrop Size Distribution Parameters Employing Disdrometer and Simulated Raindrop Spectra.
J. Appl. Meteor. Climatol., 48, 406-425, https://doi.org/10.1175/2008JAMC2026.1.
Thurai, M., Williams, C.R., Bringi, V.N., 2014:
Examining the correlations between drop size distribution parameters using data
from two side-by-side 2D-video disdrometers.
Atmospheric Research, 144, 95-110, https://doi.org/10.1016/j.atmosres.2014.01.002.
Compute gamma distribution parameters following Kozu 1991.
References
Kozu, T., and K. Nakamura, 1991:
Rainfall Parameter Estimation from Dual-Radar Measurements
Combining Reflectivity Profile and Path-integrated Attenuation.
J. Atmos. Oceanic Technol., 8, 259-270, https://doi.org/10.1175/1520-0426(1991)008<0259:RPEFDR>2.0.CO;2
Tokay, A., and D. A. Short, 1996:
Evidence from Tropical Raindrop Spectra of the Origin of Rain from
Stratiform versus Convective Clouds.
J. Appl. Meteor. Climatol., 35, 355-371,
https://doi.org/10.1175/1520-0450(1996)035<0355:EFTRSO>2.0.CO;2
Cao, Q., and G. Zhang, 2009:
Errors in Estimating Raindrop Size Distribution Parameters Employing Disdrometer and Simulated Raindrop Spectra.
J. Appl. Meteor. Climatol., 48, 406-425, https://doi.org/10.1175/2008JAMC2026.1.
Compute gamma distribution parameters following Cao et al., 2009.
References
Cao, Q., and G. Zhang, 2009:
Errors in Estimating Raindrop Size Distribution Parameters Employing Disdrometer and Simulated Raindrop Spectra.
J. Appl. Meteor. Climatol., 48, 406-425, https://doi.org/10.1175/2008JAMC2026.1.
variables (Input dataset containing drop size distribution data. It must include the following) –
drop_number_concentration (-) –
diameter_bin_width" (-) –
diameter_bin_lower (-) –
diameter_bin_upper (-) –
diameter_bin_center (-) –
probability_method (str, optional) – Method to compute probabilities. The default value is cdf.
likelihood (str, optional) – Likelihood function to use for fitting. The default value is multinomial.
truncated_likelihood (bool, optional) – Whether to use truncated likelihood. The default value is True.
optimizer (str, optional) – Optimization method to use. The default value is Nelder-Mead.
Returns:
Dataset containing the estimated lognormal distribution parameters:
- Nt: Total number concentration.
- mu: Mean of the lognormal distribution.
- sigma: Standard deviation of the lognormal distribution.
The resulting dataset will have an attribute disdrodb_psd_model set to LognormalPSD.
Compute lognormal distribution parameters following Kozu1991.
References
Kozu, T., and K. Nakamura, 1991:
Rainfall Parameter Estimation from Dual-Radar Measurements
Combining Reflectivity Profile and Path-integrated Attenuation.
J. Atmos. Oceanic Technol., 8, 259-270, https://doi.org/10.1175/1520-0426(1991)008<0259:RPEFDR>2.0.CO;2
Estimate model parameters for a given distribution using Maximum Likelihood.
Parameters:
ds (xarray.Dataset) – Input dataset containing drop number concentration data and diameter information.
It must include the following variables:
- drop_number_concentration: The number concentration of drops.
- diameter_bin_width”: The width of each diameter bin.
- diameter_bin_lower: The lower bounds of the diameter bins.
- diameter_bin_upper: The upper bounds of the diameter bins.
- diameter_bin_center: The center values of the diameter bins.
psd_modelstr
The PSD model to fit. See available_psd_models().
init_method: str or list
The method(s) of moments used to initialize the PSD model parameters.
Multiple methods can be specified. See available_mom_methods(psd_model).
probability_methodstr, optional
Method to compute probabilities. The default value is cdf.
likelihoodstr, optional
Likelihood function to use for fitting. The default value is multinomial.
truncated_likelihoodbool, optional
Whether to use Truncated Maximum Likelihood (TML). The default value is True.
optimizerstr, optional
Optimization method to use. The default value is Nelder-Mead.
Compute PSD model parameters using various method-of-moments (MOM) approaches.
The method is specified by the mom_methods abbreviations, e.g. ‘M012’, ‘M234’, ‘M246’.
Parameters:
ds (xarray.Dataset) – An xarray Dataset with the required moments M0…M6 as data variables.
mom_methods (str or list (optional)) – See valid values with disdrodb.psd.available_mom_methods(psd_model)
If None (the default), compute model parameters with all available MOM methods.
Returns:
A Dataset containing mu, Lambda, and N0 variables.
If multiple mom_methods are specified, the dataset has the dimension mom_method.
Estimate $mu$ of a Normalized Gamma distribution using Grid Search.
The D50 and Nw parameters of the Normalized Gamma distribution are derived empirically from the obs DSD.
$mu$ is derived by minimizing the errors between the obs DSD and modelled Normalized Gamma distribution.
Parameters:
Nd (array_like) – A drop size distribution
D50 (optional, float) – Median drop diameter in mm. If none is given, it will be estimated.
Nw (optional, float) – Normalized Intercept Parameter. If none is given, it will be estimated.
order (optional, float) – Order to which square the error when computing the sum of errors.
Order = 2 is equivalent to minimize the mean squared error (MSE) (L2 norm). The default is 2.
Order = 1 is equivalent to minimize the mean absolute error (MAE) (L1 norm).
Higher orders typically stretch higher the gamma distribution.
Returns:
ds_params – Dataset containing the estimated Normalized Gamma distribution parameters.
This class represents a binned particle size distribution (PSD) that computes PSD values
based on provided bin edges and corresponding PSD values. The PSD is evaluated via interpolation
using one of several available methods.
Parameters:
bin_edges (array_like) – A sequence of n+1 bin edge values defining the bins. The edges must be monotonically increasing.
bin_psd (array_like) – A sequence of n PSD values corresponding to the intervals defined by bin_edges.
interp_method ({'step_left', 'step_right', 'linear', 'pchip'}, optional) – The interpolation method used to compute the PSD values. The default is ‘step_left’.
D (For any input diameter (or diameters)) –
If D lies outside the range (bin_edges[0], bin_edges[-1]), the PSD value is set to 0.
The interpolation function is defined internally based on the chosen method.
PSD values are clipped to ensure they are non-negative.
Examples
>>> importnumpyasnp>>> bin_edges=[0.0,1.0,2.0,3.0,4.0]>>> bin_psd=[10.0,20.0,30.0,0.0]>>> D=np.linspace(0,3.5,100)>>>>>> # Using linear interpolation>>> psd_linear=BinnedPSD(bin_edges,bin_psd,interp_method="linear")>>> psd_values=psd_linear(D)>>>>>> # Values for D outside (bin_edges[0], bin_edges[-1]) are set to 0
Ulbrich, C. W., 1985: The Effects of Drop Size Distribution Truncation on
Rainfall Integral Parameters and Empirical Relations.
J. Appl. Meteor. Climatol., 24, 580-590, https://doi.org/10.1175/1520-0450(1985)024<0580:TEODSD>2.0.CO;2
An alternative formulation as function of Dm:
# Testud (2001), Bringi (2001), Williams et al., 2014, Dolan 2018
# –> Normalized with respect to liquid water content (mass) –> Nx=D3/Dm4
N(D) = Nw * f1(mu) * (D/Dm)**mu * exp(-(mu+4)*D/Dm) # Nw * f(D; Dm, mu)
f1(mu) = 6/(4**4) * (mu+4)**(mu+4)/Gamma(mu+4)
Note: gamma(4) = 6
An alternative formulation as function of Dm:
# Tokay et al., 2010
# Illingworth et al., 2002 (see eq10 to derive full formulation!)
# –> Normalized with respect to total concentration –> Nx = #/Dm
N(D) = Nt* * f2(mu) * (D/Dm)**mu * exp(-(mu+4)*D/Dm)
f2(mu) = (mu+4)**(mu+1)/Gamma(mu+1)
Willis, P. T., 1984: Functional Fits to Some Observed Drop Size Distributions and Parameterization of Rain.
J. Atmos. Sci., 41, 1648-1661, https://doi.org/10.1175/1520-0469(1984)041<1648:FFTSOD>2.0.CO;2
Testud, J., S. Oury, R. A. Black, P. Amayenc, and X. Dou, 2001: The Concept of “Normalized” Distribution
to Describe Raindrop Spectra: A Tool for Cloud Physics and Cloud Remote Sensing.
J. Appl. Meteor. Climatol., 40, 1118-1140, https://doi.org/10.1175/1520-0450(2001)040<1118:TCONDT>2.0.CO;2
Illingworth, A. J., and T. M. Blackman, 2002:
The Need to Represent Raindrop Size Spectra as Normalized Gamma Distributions for
the Interpretation of Polarization Radar Observations.
J. Appl. Meteor. Climatol., 41, 286-297, https://doi.org/10.1175/1520-0450(2002)041<0286:TNTRRS>2.0.CO;2
Bringi, V. N., G. Huang, V. Chandrasekar, and E. Gorgucci, 2002:
A Methodology for Estimating the Parameters of a Gamma Raindrop Size Distribution Model from
Polarimetric Radar Data: Application to a Squall-Line Event from the TRMM/Brazil Campaign.
J. Atmos. Oceanic Technol., 19, 633-645, https://doi.org/10.1175/1520-0426(2002)019<0633:AMFETP>2.0.CO;2
Bringi, V. N., V. Chandrasekar, J. Hubbert, E. Gorgucci, W. L. Randeu, and M. Schoenhuber, 2003:
Raindrop Size Distribution in Different Climatic Regimes from Disdrometer and Dual-Polarized Radar Analysis.
J. Atmos. Sci., 60, 354-365, https://doi.org/10.1175/1520-0469(2003)060<0354:RSDIDC>2.0.CO;2
Tokay, A., and P. G. Bashor, 2010: An Experimental Study of Small-Scale Variability of Raindrop Size Distribution.
J. Appl. Meteor. Climatol., 49, 2348-2365, https://doi.org/10.1175/2010JAMC2269.1
Kozu, T., and K. Nakamura, 1991:
Rainfall Parameter Estimation from Dual-Radar Measurements
Combining Reflectivity Profile and Path-integrated Attenuation.
J. Atmos. Oceanic Technol., 8, 259-270, https://doi.org/10.1175/1520-0426(1991)008<0259:RPEFDR>2.0.CO;2
Kozu, T., and K. Nakamura, 1991:
Rainfall Parameter Estimation from Dual-Radar Measurements
Combining Reflectivity Profile and Path-integrated Attenuation.
J. Atmos. Oceanic Technol., 8, 259-270, https://doi.org/10.1175/1520-0426(1991)008<0259:RPEFDR>2.0.CO;2
Kozu, T., and K. Nakamura, 1991:
Rainfall Parameter Estimation from Dual-Radar Measurements
Combining Reflectivity Profile and Path-integrated Attenuation.
J. Atmos. Oceanic Technol., 8, 259-270, https://doi.org/10.1175/1520-0426(1991)008<0259:RPEFDR>2.0.CO;2
Ulbrich, C. W., 1985: The Effects of Drop Size Distribution Truncation on
Rainfall Integral Parameters and Empirical Relations.
J. Appl. Meteor. Climatol., 24, 580-590, https://doi.org/10.1175/1520-0450(1985)024<0580:TEODSD>2.0.CO;2
An alternative formulation as function of Dm:
# Testud (2001), Bringi (2001), Williams et al., 2014, Dolan 2018
# –> Normalized with respect to liquid water content (mass) –> Nx=D3/Dm4
N(D) = Nw * f1(mu) * (D/Dm)**mu * exp(-(mu+4)*D/Dm) # Nw * f(D; Dm, mu)
f1(mu) = 6/(4**4) * (mu+4)**(mu+4)/Gamma(mu+4)
Note: gamma(4) = 6
An alternative formulation as function of Dm:
# Tokay et al., 2010
# Illingworth et al., 2002 (see eq10 to derive full formulation!)
# –> Normalized with respect to total concentration –> Nx = #/Dm
N(D) = Nt* * f2(mu) * (D/Dm)**mu * exp(-(mu+4)*D/Dm)
f2(mu) = (mu+4)**(mu+1)/Gamma(mu+1)
Willis, P. T., 1984: Functional Fits to Some Observed Drop Size Distributions and Parameterization of Rain.
J. Atmos. Sci., 41, 1648-1661, https://doi.org/10.1175/1520-0469(1984)041<1648:FFTSOD>2.0.CO;2
Testud, J., S. Oury, R. A. Black, P. Amayenc, and X. Dou, 2001: The Concept of “Normalized” Distribution
to Describe Raindrop Spectra: A Tool for Cloud Physics and Cloud Remote Sensing.
J. Appl. Meteor. Climatol., 40, 1118-1140, https://doi.org/10.1175/1520-0450(2001)040<1118:TCONDT>2.0.CO;2
Illingworth, A. J., and T. M. Blackman, 2002:
The Need to Represent Raindrop Size Spectra as Normalized Gamma Distributions for
the Interpretation of Polarization Radar Observations.
J. Appl. Meteor. Climatol., 41, 286-297, https://doi.org/10.1175/1520-0450(2002)041<0286:TNTRRS>2.0.CO;2
Bringi, V. N., G. Huang, V. Chandrasekar, and E. Gorgucci, 2002:
A Methodology for Estimating the Parameters of a Gamma Raindrop Size Distribution Model from
Polarimetric Radar Data: Application to a Squall-Line Event from the TRMM/Brazil Campaign.
J. Atmos. Oceanic Technol., 19, 633-645, https://doi.org/10.1175/1520-0426(2002)019<0633:AMFETP>2.0.CO;2
Bringi, V. N., V. Chandrasekar, J. Hubbert, E. Gorgucci, W. L. Randeu, and M. Schoenhuber, 2003:
Raindrop Size Distribution in Different Climatic Regimes from Disdrometer and Dual-Polarized Radar Analysis.
J. Atmos. Sci., 60, 354-365, https://doi.org/10.1175/1520-0469(2003)060<0354:RSDIDC>2.0.CO;2
Tokay, A., and P. G. Bashor, 2010: An Experimental Study of Small-Scale Variability of Raindrop Size Distribution.
J. Appl. Meteor. Climatol., 49, 2348-2365, https://doi.org/10.1175/2010JAMC2269.1