pydsd package

Submodules

DSDProcessor module

class pydsd.DSDProcessor.DSDProcessor(wl=33.3, dr=1, shape='bc')[source]

Bases: object

calcParameters(D0, Nw, mu)[source]

DSR module

pydsd.DSR.bc(D_eq)[source]

Beard and Chuang Drop Shape relationship model.

Implementation of the Beard and Chuang Drop Shape model given in [1] . This gives the ratio of the major to minor axis.

Parameters
D_eq: float

Volume Equivalent Drop Diameter

Returns
axis_ratio: float

The ratio of the semi minor to semi major axis.

See also

tb

Thurai and Bringi DSR

pb

Pruppacher and Beard DSR

brandes

Brandes DSR

References

..[1] Beard, Kenneth V., Catherine Chuang, 1987: A New Model for the Equilibrium Shape of Raindrops. J. Atmos. Sci., 44, 1509-1524.

pydsd.DSR.brandes(D_eq)[source]

Brandes 2005 Drop shape relationship model.

Implementation of the Brandes et. al. drop shape model given in [1]. This gives the ratio of the major to minor axis as a function of equivalent liquid spherical diameter.

Parameters
D_eq: float or array_like

Volume Equivalent Drop Diameter

Returns
axis_ratio: float

The ratio of the semi minor to semi major axis.

See Also
tbThurai and Bringi DSR
pb: Pruppacher and Beard DSR
bc: Beard and Chuang DSR

References

..[1] Brandes, etl al. 2005: On the Influence of Assumed Drop Size Distribution Form on Radar-Retrieved Thunderstorm Microphysics. J. Appl. Meteor. Climatol., 45, 259-268.

pydsd.DSR.pb(D_eq)[source]

Pruppacher and Beard Drop Shape relationship model.

Implementation of the Pruppacher and Beard Drop Shape model given in [1] . This gives the ratio of the semi minor to semi major axis.

Parameters
D_eq: float

Volume Equivalent Drop Diameter

Returns
axis_ratio: float

The ratio of the major to minor axis.

See also

tb

Thurai and Bringi DSR

bc

Beard and Chuang DSR

brandes

Brandes DSR

References

..[1] Pruppacher, H. R. and Beard, K. V. (1970), A wind tunnel

investigation of the internal circulation and shape of water drops falling at terminal velocity in air. Q.J.R. Meteorol. Soc., 96: 247-256

pydsd.DSR.tb(D_eq)[source]

Thurai and Bringi Drop Shape relationship model.

Implementation of the Thurai and Bringi Drop Shape model given in [1] . This gives the ratio of the major to minor axis.

Parameters
D_eq: float

Volume Equivalent Drop Diameter

Returns
axis_ratio: float

The ratio of the major to minor axis.

See also

pb

Pruppacher and Beard DSR

bc

Beard and Chuang DSR

References

1

Thurai, Merhala, V. N. Bringi, “Drop axis ratios from a 2D video disdrometer.” J. Atmos. Oceanic Technol., 22, 966 - 978. 2005

DropSizeDistribution module

The Drop Size Distribution model contains the DropSizeDistribution class. This class represents drop size distributions returned from the various readers in the io module. The class knows how to perform scattering simulations on itself.

class pydsd.DropSizeDistribution.DropSizeDistribution(reader, time_start=None, location=None)[source]

Bases: object

DropSizeDistribution class to hold DSD’s and calculate parameters and relationships. Should be returned from the disdrometer*reader style functions.

Attributes
time: array_like

An array of times corresponding to the time each dsd was sampled in minutes relative to time_start.

time_start: datetime

A datetime object indicated start of disdrometer recording.

fields: dictionary

Dictionary of scattered components.

Nd2d Array

A list of drop size distributions

spread: array_like

Array giving the bin spread size for each size bin of the disdrometer.

velocity: array_like

Terminal Fall Velocity for each size bin. This is based on the disdrometer assumptions.

Z: array_like

The equivalent reflectivity factory from the disdrometer. Often taken as D**6.

bin_edges: array_like

N+1 sized array of the boundaries of each size bin. For 30 bins for instance, there will be 31 different bin boundaries.

diameter: array_like

The center size for each dsd bin.

calculate_RR()[source]

Calculate instantaneous rain rate.

This calculates instantaneous rain rate based on the flux of water.

calculate_R_Kdp_relationship()[source]

calculate_R_kdp_relationship calculates a power fit for the rainfall-kdp relationship based upon the calculated radar parameters(which should have already been run). It returns the scale and exponential parameter a and b in the first tuple, and the second returned argument gives the covariance matrix of the fit.

calculate_R_Zdr_Kdp_relationship()[source]

calculate_R_Zdr_Kdp_relationship calculates the power law fit for Zdr,Kdp based upon scattered radar parameters. It returns the scale and exponential parameters a, b, and c in the first tuple, and the second returned argument gives the covariance matrix of the fit. rain_rate > 0 Zdr > 0 Kdp > 0

calculate_R_Zh_Kdp_relationship()[source]

calculate_R_Zh_Kdp_relationship calculates the power law fit for Zh,Kdp based upon scattered radar parameters. It returns the scale and exponential parameters a, b, and c in the first tuple, and the second returned argument gives the covariance matrix of the fit. rain_rate > 0 Zdr > 0 Kdp > 0

calculate_R_Zh_Zdr_relationship()[source]

calculate_R_Zh_Zdr_relationship calculates the power law fit for Zh,Zdr based upon scattered radar parameters. It returns the scale and exponential parameters a, b, and c in the first tuple, and the second returned argument gives the covariance matrix of the fit. Uses a set of filters to remove bad data: rain_rate > 0 Zdr > 0 Kdp > 0

calculate_R_Zh_relationship()[source]

calculate_R_Zh_relationship calculates the power law fit for Zh based upon scattered radar parameters. It returns the scale and exponential parameter a and b in the first tuple, and the second returned argument gives the covariance matrix of the fit.

calculate_dsd_from_spectrum(effective_sampling_area=None, replace=True)[source]

Calculate N(D) from the drop spectrum based on the effective sampling area. Updates the entry for ND in fields. Requires that drop_spectrum be present in fields, and that the dsd has spectrum_fall_velocity defined.

Parameters
effective_sampling_area: function

Function that returns the effective sampling area as a function of diameter. Optionally a array with effective sampling area matched to diameter dimension can be provided as an array.

replace: boolean

Whether to replace Nd with the newly calculated one. If true, no return value to save memory.

calculate_dsd_parameterization(method='bringi')[source]

Calculates DSD Parameterization.

This calculates the dsd parameterization and stores the result in the fields dictionary. This includes the following parameters: Nt, W, D0, Nw, Dmax, Dm, N0, mu

calculate_fall_speed(diameter, density=1000, inplace=False)[source]

Calculate terminal fall velocity for drops[1] adjusted by the density of the air[2]

Parameters
diameter: array_like[float]

Array of diameters to calculate fall speed for.

density: float, optional

Density of the air in millibars. Defaults to 1000mb.

Returns
terminal_fall_speed: array_like[float]

Array of fall speeds matching size of diameter, adjusted for air density.

0450(1969)008<0249:TVORA>2.0.CO;2, 1969.

calculate_radar_parameters(dsr_func=<function bc>, scatter_time_range=None, max_diameter=9.0, scatter_table_filename=None)[source]

Calculates radar parameters for the Drop Size Distribution.

Calculates the radar parameters and stores them in the object. Defaults to X-Band,Beard and Chuang 10C setup.

Sets the dictionary parameters in fields dictionary:

Zh, Zdr, Kdp, Ai(Attenuation)

wavelength: optional, pytmatrix wavelength

Wavelength to calculate scattering coefficients at.

dsr_func: optional, function

Drop Shape Relationship function. Several are availab le in the DSR module. Defaults to Beard and Chuang

scatter_time_range: optional, tuple

Parameter to restrict the scattering to a time interval. The first element is the start time, while the second is the end time.

save_scattering_table(scattering_filename)[source]

Save scattering table used by PyDSD to be reloaded later. Note this should only be used on disdrometers with the same setup for scattering (frequency, bins, max size, etc). This feature is currently experimental and may be removed in the future if it turns out to not work correctly or to cause issues.

set_air_density(air_density)[source]

Set air density at ground level

set_canting_angle(canting_angle=20)[source]

Change the canting angle for scattering calculations. Requires scattering table to be regenerated afterwards.

set_scattering_temperature_and_frequency(scattering_temp=10, scattering_freq=9700000000.0)[source]

Change the scattering temperature. After use, re-run calculate_radar_parameters to see the effect this has on the parameters. Temperatures are in Celsius. Defaults to 10C X-band.

Parameters
scattering_temp: optional, float

Scattering temperature [C].

scattering_freq: optional, float

Scattering frequency [Hz].

JWDReader module

class pydsd.io.JWDReader.JWDReader(filename)[source]

Bases: object

JWDReader class takes takes a filename as it’s only argument(for now). This should be a Joss-Waldvogel datafile.

conv_md_to_nd(Nd)[source]
diameter = {'data': array([0.359, 0.455, 0.551, 0.656, 0.771, 0.913, 1.116, 1.331, 1.506, 1.665, 1.912, 2.259, 2.584, 2.869, 3.198, 3.544, 3.916, 4.35 , 4.859, 5.373]), 'long_name': 'Particle diameter of bins', 'standard_name': 'diameter', 'units': 'mm'}
getSec(s, start_hh, start_mm)[source]
spread = {'data': array([0.092, 0.1 , 0.091, 0.119, 0.112, 0.172, 0.233, 0.197, 0.153, 0.166, 0.329, 0.364, 0.286, 0.284, 0.374, 0.319, 0.423, 0.446, 0.572, 0.455]), 'long_name': 'Bin size spread of bins', 'standard_name': 'spread', 'units': 'mm'}
pydsd.io.JWDReader.read_jwd(filename)[source]

Takes a filename pointing to a Joss-WaldVogel file and returns a drop size distribution object.

Usage: dsd = read_jwd(filename)

Returns: DropSizeDistrometer object

ParsivelNasaGVReader module

class pydsd.io.ParsivelNasaGVReader.NASA_APU_reader(filename, campaign, skip_header)[source]

Bases: object

This class reads and parses parsivel disdrometer data from NASA ground validation campaigns. These conform to document ???

Use the read_parsivel_nasa_gv() function to interface with this.

diameter = {'data': array([ 0.06, 0.19, 0.32, 0.45, 0.58, 0.71, 0.84, 0.96, 1.09, 1.22, 1.42, 1.67, 1.93, 2.19, 2.45, 2.83, 3.35, 3.86, 4.38, 4.89, 5.66, 6.7 , 7.72, 8.76, 9.78, 11.33, 13.39, 15.45, 17.51, 19.57, 22.15, 25.24]), 'long_name': 'Particle diameter of bins', 'standard_name': 'diameter', 'units': 'mm'}
spread = {'data': array([0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.257, 0.257, 0.257, 0.257, 0.257, 0.515, 0.515, 0.515, 0.515, 0.515, 1.03 , 1.03 , 1.03 , 1.03 , 1.03 , 2.06 , 2.06 , 2.06 , 2.06 , 2.06 , 3.09 , 3.09 ]), 'long_name': 'Bin size spread of bins', 'standard_name': 'spread', 'units': 'mm'}
supported_campaigns = ['ifloods', 'mc3e_dsd', 'mc3e_raw']
velocity = {'data': array([ 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.96, 1.13, 1.35, 1.59, 1.83, 2.08, 2.4 , 2.78, 3.15, 3.5 , 3.84, 4.4 , 5.2 , 6. , 6.8 , 7.6 , 8.8 , 10.4 , 12. , 13.6 , 15.2 , 17.6 , 20.8 ]), 'long_name': 'Terminal fall velocity for each bin', 'standard_name': 'velocity', 'units': 'm s^-1'}
pydsd.io.ParsivelNasaGVReader.read_parsivel_nasa_gv(filename, campaign='ifloods', skip_header=None)[source]
Parameters
filename: str

Data file name.

campaign: str

Campaign identifier that reads file based upon the format used to produce that data.

skip_header: int

A number of header lines to skip when reading the file.

Takes a filename pointing to a Parsivel NASA Field Campaign file and returns
a drop size distribution object.
Usage:
dsd = read_parsivel_nasa_gv(filename, campaign=’MC3E_dsd’)
Current Options for campaign are:
‘ifloods’
‘mc3e_dsd’
‘mc3e_raw’
Returns:
DropSizeDistrometer object
Note: NASA’s processing strips out rain rate so we have to
recalculate it based upon a fall speed relationship.

ParsivelReader module

class pydsd.io.ParsivelReader.ParsivelReader(filename)[source]

Bases: object

ParsivelReader class takes takes a filename as it’s only argument(for now). This should be a parsivel raw datafile(output from the parsivel).

diameter = {'data': array([ 0.06, 0.19, 0.32, 0.45, 0.58, 0.71, 0.84, 0.96, 1.09, 1.22, 1.42, 1.67, 1.93, 2.19, 2.45, 2.83, 3.35, 3.86, 4.38, 4.89, 5.66, 6.7 , 7.72, 8.76, 9.78, 11.33, 13.39, 15.45, 17.51, 19.57, 22.15, 25.24]), 'long_name': 'Particle diameter of bins', 'standard_name': 'diameter', 'units': 'mm'}
get_sec(s)[source]
pcm_matrix = (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0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1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
spread = {'data': [0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.129, 0.257, 0.257, 0.257, 0.257, 0.257, 0.515, 0.515, 0.515, 0.515, 0.515, 1.03, 1.03, 1.03, 1.03, 1.03, 2.06, 2.06, 2.06, 2.06, 2.06, 3.09, 3.09], 'long_name': 'Bin size spread of bins', 'standard_name': 'spread', 'units': 'mm'}
v_spread = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.4, 0.8, 0.8, 0.8, 0.8, 0.8, 1.6, 1.6, 1.6, 1.6, 1.6, 3.2, 3.2]
velocity = {'data': array([ 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95, 1.1 , 1.3 , 1.5 , 1.7 , 1.9 , 2.2 , 2.6 , 3. , 3.4 , 3.8 , 4.4 , 5.2 , 6. , 6.8 , 7.6 , 8.8 , 10.4 , 12. , 13.6 , 15.2 , 17.6 , 20.8 ]), 'long_name': 'Terminal fall velocity for each bin', 'standard_name': 'velocity', 'units': 'm s^-1'}
pydsd.io.ParsivelReader.read_parsivel(filename)[source]

Takes a filename pointing to a parsivel raw file and returns a drop size distribution object.

Usage: dsd = read_parsivel(filename)

Returns: DropSizeDistrometer object

expfit module

pydsd.utility.expfit.expfit(x, y)[source]

expfit calculates an exponential power law fit based upon levenburg-marquardt minimization. Fits are of the form. y = ax**b Parameters: ———– x: array_like

independent variable

y: array_like

dependent variable

pydsd.utility.expfit.expfit2(x, y)[source]

expfit2 calculates an exponential power law fit based upon levenburg-marquardt minimization. Fits are of the form. y = a(x[0]**b)(x[1]**c) Parameters: ———– x: array_like

independent variables packed. x[0] is first independent variable tuple, x[1] the second.

y: array_like

dependent variable

Module contents