pycaps.derive package

Submodules

pycaps.derive.derive_functions module

air_density(**kwargs)[source]

Calculates air density for given pressure and potential temperature arrays of arbitrary shape.

Parameters:**kwargs – Must contain ‘p’ (pressure in Pa) and ‘pt’ or ‘t’ (potential temperature or temperature, either in K). May also contain ‘qv’ (water vapor mixing ratio in kg/kg). Any arguments other than these are ignored.
Returns:Air density in kg/m^3 as an array of the same shape as p and pt
bunkers_motion(direction='RM', **kwargs)[source]

Defines the Storm motion based upon a vertical sounding using the Bunkers et al. (2000) storm motion approximation.

Args:

direction: The direction fo the storm motion, ‘RM’ or ‘LM.

**kwargs: Must contain ‘u’ (u wind component), ‘v’ (v wind component), ‘zp’ (physical model height), and ‘zpsoil’ (soil height),
u,v,zp,zpsoil must be numpy arrays with 3 dimensions. and the axes are assumed to be in (NZ, NY, NX) order. Any kwargs not ‘u’, ‘v’,’zp’,’zpsoil’ will be ignored

Returns: A numpy array containing the storm motion (m/s). The array is two dimensions (NY,NX)

calc_mesh(**kwargs)[source]

Calculated the Maximum Estimated Size of Hail (MESH) Witt et al. (1998)

Parameters:**kwargs – ‘dBZ’ (the reflectivity), ‘pt’ (potential temperature), ‘p’ (the pressure),’zp’ (the physical height). dBZ,pt,p,and zp must be numpy arrays with 3 dimensions and the axes are assumed to be in (NZ, NY, NX) order. Any kwargs not ‘dBZ’,’pt’,’p’,’zp’ will be ignored

Returns: The numpy matrix of MESH (mm). The arrays has two dimensions (NY,NX)

closest_grdpt(convert_scalar=True, **kwargs)[source]

Find the closest grid point above the given height, fast when interpolation is not desired

Parameters:
  • convert_scalar – Convert from scalar to physical height
  • **kwargs – ‘z’ (the vertical height), ‘zp’ (physical model height), z must be a scalar value in meters zp must be numpy arrays with 3 dimensions and the axes are assumed to be in (NZ, NY, NX) order. Any kwargs not ‘z’,’zp’ will be ignored

Returns: The numpy matrix with the vertical levels of said height. The arrays has two dimensions (NY,NX)

compute_srh(zOne=1000, zTwo=3000, direction='RM', **kwargs)[source]

Computes storm relative helicity

Parameters:
  • zOne – The bottom height for which the integral begins.
  • zTwo – The top height for which the integral ends.
  • direction – The direction fo the storm motion, ‘RM’ or ‘LM.
  • **kwargs – Must contain ‘u’ (u wind component), ‘v’ (v wind component), ‘zp’ (physical model height), and ‘zpsoil’ (soil height), u,v,zp,zpsoil must be numpy arrays with 3 dimensions. and the axes are assumed to be in (..., NY, NX) order. Any kwargs not ‘u’, ‘v’,’zp’,’zpsoil’ will be ignored

Returns: A numpy array containing Storm Relative Helicity (m^2/s^2). The array is the same shape as the input arrays.

dewp_from_qv(**kwargs)[source]

Get dewpoint temperature from water vapor mixing ratio, using the Clausius-Clapeyron equation.

Parameters:**kwargs – Must contain ‘qv’ (water vapor mixing ratio in kg/kg) and ‘p’ (pressure in Pa). Any other keyword arguments are ignored.
Returns:Dewpoint temperature in K.
dewp_from_rh(**kwargs)[source]

Get dewpoint temperature from relative humidity.

Parameters:**kwargs – Must contain ‘rh’ (relative humidity as a fraction from 0-1), ‘p’ (pressure in Pa), and ‘pt’ or ‘t’ (potential temperature or temperature, either in K). Any other keyword arguments are ignored.
Returns:Dewpoint temperature in K.
dict_fm_recarray(rec)[source]

Convert a numpy record array to a Python dictionary.

Parameters:rec – The record array to convert
Returns:A Python dictionary with keys taken from the array data type.
finite_diff(data, coords, axis=0)[source]

Compute a finite difference along a given axis.

Parameters:
  • data – A numpy array of which to take the finite difference.
  • coords – The coordinates for the axis along which to take the derivative, specified as a numpy array.
  • axis – The axis along which to take the finite difference; optional, defaults to 0.
Returns:

An array of the same shape as the data array containing the finite difference.

horiz_convergence(**kwargs)[source]

Computes horizontal convergence.

Parameters:**kwargs – Must contain ‘u’ (u wind component), ‘v’ (v wind component), ‘dx’ (grid spacing in the x direction), and ‘dy’ (grid spacing in the y direction). u and v must be numpy arrays with 2 or more dimensions, and the axes are assumed to be in (..., NY, NX) order. dx and dy must be scalar floats. Any kwargs not ‘u’, ‘v’, ‘dx’, or ‘dy’ are ignored.
Returns:A numpy array containing horizontal convergence in 1/s. The array is the same shape as the input arrays.
hydrometeor_classify(qc_opt, x, y, ref, zdr, rhv, vel, pt, p, qs, hgt, zp)[source]
isotherm_hgt(isotherm=0, convert_scalar=True, **kwargs)[source]

Calculate the the physical height of the gridpoint, one gridlevel above isotherm

Parameters:
  • isotherm – The isotherm height to analyze
  • convert_scalar – Convert from scalar to physical height
  • **kwargs

    ‘p’ (the pressure), ‘pt’ (the potential temperature), ‘zp’ (physical model height), p,pt,zp must be numpy arrays with 3 dimensions and the axes are assumed to be in (NZ, NY, NX) order. Any kwargs not ‘z’,’zp’ will be ignored

    If the temperature is known may use ‘T’ (the temperature) instead of ‘p’ and ‘pt’

Returns: The numpy matrix with the vertical levels of said isotherm. The arrays has two dimensions (NY,NX)

moist_lapse(**kwargs)[source]

Compute the moist adiabatic lapse rate at a given temperature and pressure.

Parameters:**kwargs – Must contain ‘p’ (pressure in Pa) and either ‘t’ or ‘pt’ (temperature or potential temperature, either in K). Any other keyword arguments are ignored.
Returns:The moist adiabatic lapse rate in K/Pa.
pbl_depth(**kwargs)[source]

ARPS planetary boundary layer depth calculation. Translated directly from pbldpth() in sfcphy3d.f90.

Parameters:**kwargs – Must contain ‘pt’ (potential temperature in K), ‘qv’ (water vapor mixing ratio in kg/kg), and ‘z’ (height in m). The arguments must be arrays with the first dimension being height; axis order (NZ, ...). Any other keyword arguments are ignored
Returns:Depth of the planetary boundary layer in m.
pmsl(**kwargs)[source]

Compute pressure at mean sea level, [check my assumption].

Parameters:**kwargs – Must contain ‘z’ (height in meters of each point above sea level), ‘p’ (pressure in Pa at each point), ‘pt’ or ‘t’ (potential temperature or temperature, either in K), and ‘qv’ (water vapor mixing ratio in kg/kg).
Returns:Pressure at mean sea level in Pa as a numpy array of the same shape as the input arrays.
qv_from_vapr(**kwargs)[source]

Get water vapor mixing ratio from vapor pressure.

Parameters:**kwargs – Must contain ‘p’ (pressure in Pa) and either ‘e’ (vapor pressure in Pa), ‘t’ (temperature in K), or ‘pt’ (potential temperature in K). Any other keyword arguments are ignored.
Returns:Water vapor mixing ratio in kg/kg
recarray_fm_dict(**dct)[source]

Convert a Python dictionary to a numpy record array.

Parameters:**dct – Dictionary keys to convert.
Returns:A numpy array with a record data type.
reflectivity_dualmom(**kwargs)[source]

Compute reflectivity from a dual-moment microphysics scheme.

Parameters:**kwargs – Must contain ‘qv’ (water vapor mixing ratio in kg/kg), ‘qr’ (rain mixing ratio in kg/kg), ‘qs’ (snow mixing ratio in kg/kg), ‘qh’ (hail mixing ratio in kg/kg), ‘qg’ (graupel mixing ratio in kg/kg), ‘nr’ (total number concentration of rain in #/m^3), ‘ns’ (total number concentration of snow in #/m^3), ‘nh’ (total number concentration of hail in #/m^3), ‘ng’ (total number concentration of graupel in #/m^3), ‘p’ (air pressure in Pa), and ‘pt’ or ‘t’ (potential temperature or temperature, either in K). Any other keyword arguments are ignored.
Returns:Radar reflectivity in dBZ
reflectivity_lin(**kwargs)[source]

Compute reflectivity from a Lin microphysics scheme

Parameters:**kwargs – Must contain ‘qv’ (water vapor mixing ratio in kg/kg), ‘qr’ (rain mixing ratio in kg/kg), ‘qs’ (snow mixing ratio in kg/kg), ‘qh’ (hail mixing ratio in kg/kg), ‘n0rain’ (n0 for the rain distribution in 1/m^4), ‘n0snow’ (n0 for the snow distribution in 1/m^4), ‘n0hail’ (n0 for the hail distribution in 1/m^4), ‘rhosnow’ (assumed density for snow in kg/m^3), ‘rhoice’ (assumed density for ice in kg/m3), ‘rhohail’ (assumed density for hail in kg/m^3), ‘p’ (air pressure in Pa), and ‘pt’ or ‘t’ (potential temperature or temperature, either in K). Any other keyword arguments are ignored.
Returns:Radar reflectivity in dBZ
temp_from_theta(**kwargs)[source]

Get temperature from potential temperature.

Parameters:**kwargs – Must contain ‘p’ (pressure in Pa) and ‘pt’ (potential temperature in K) either as scalars or numpy arrays. Any other keyword arguments are ignored.
Returns:Temperature in K
temp_from_vapr(**kwargs)[source]

Get temperature from vapor pressure, using the Clausius-Clapeyron equation.

Parameters:**kwargs – Must contain one of two sets of arguments. The first is ‘e’ (vapor pressure in Pa). The second is both ‘qv’ (water vapor mixing ratio in kg/kg) and ‘p’ (pressure in Pa). Any arguments other than these are ignored.
Returns:Temperature in K.
updraft_helicity(z_bottom=2000.0, z_top=5000.0, **kwargs)[source]

Calculates updraft helicity (m^2/s^2) given 3d winds and physical height.

u,v,w should have dimensions of [nz,ny,nx] dx and dy are scalars zp is a matrix of dimensions of [nz,ny,nx]

Parameters:
  • u – u-wind (east-west wind component)
  • v – v-wind (north-south wind component)
  • w – w-wind (vertical wind component)
  • dx – horizontal (east-west) grid spacing in meters
  • dy – horizontal (north-south) grid spacing in meters
  • zp – physical height
  • z_top – Bottom of layer over which to calculate updraft helicity (OPTIONAL: default 2000m)
  • z_bottom – Top of layer over which to calculate updraft helicity (OPTIONAL: default 5000m)
Returns:

The updraft helicity in m^2/s^2 in the layer z_bottom to z_top.

vapr_from_qv(**kwargs)[source]

Get vapor pressure from water vapor mixing ratio.

Parameters:**kwargs – Must contain ‘qv’ (water vapor mixing ratio in kg/kg) and ‘p’ (pressure in Pa). Any other keyword arguments are ignored.
Returns:Vapor pressure in Pa
vapr_from_temp(**kwargs)[source]

Get vapor pressure from temperature, using the Clausius-Clapeyron equation.

Parameters:**kwargs – Must contain ‘t’ (temperature in K) or ‘pt’ and ‘p’ (potential temperature in K and pressure in Pa). Any other keyword arguments are ignored.
Returns:Vapor pressure in Pa.
vert_vorticity(**kwargs)[source]

Computes vertical vorticity.

Parameters:**kwargs – Must contain ‘u’ (u wind component), ‘v’ (v wind component), ‘dx’ (grid spacing in the x direction), and ‘dy’ (grid spacing in the y direction). u and v must be numpy arrays with 2 or more dimensions, and the axes are assumed to be in (..., NY, NX) order. dx and dy must be scalar floats. Any kwargs not ‘u’, ‘v’, ‘dx’, or ‘dy’ are ignored.
Returns:A numpy array containing vertical vorticity in 1/s. The array is the same shape as the input arrays.
vert_windshear(z_one=1000, z_two=3000, **kwargs)[source]

Defines a vertical wind shear vector between two specfied heights. Useful in calculating SRH - I integrate between 1-3km.

Parameters:
  • zOne – The bottom height which is considered
  • zTwo – The top height which is considered
  • **kwargs – Must contain ‘u’ (u wind component), ‘v’ (v wind component), ‘zp’ (physical model height), and ‘zpsoil’ (soil height), u,v,zp,zpsoil must be numpy arrays with 3 dimensions. and the axes are assumed to be in (NZ, NY, NX) order. Any kwargs not ‘u’, ‘v’,’zp’,’zpsoil’ will be ignored

Returns: Two arrays of the U and V components of vertical wind shear (m/s). The arrays are two dimensional (NY,NX).

vg_tensor(**kwargs)[source]

Compute the components of the velocity gradient tensor.

Parameters:**kwargs – Must contain ‘u’, ‘u’, ‘w’, ‘x’, ‘y’, and ‘z’. u, v, and w are the zonal, meridional, and vertical components of wind, respectively, and must be 3-dimensional numpy arrays. The order of the axes is assumed to be (NZ, NY, NX). x and y should be 1-dimensional arrays containing the x and y coordinates for the domain, and z should be 3-dimensional arrays containing the vertical coordinates for the domain (e.g. ‘zp’ from an ARPS history file). All keywords that are not the aforementioned are ignored.
Returns:The 9 components of the velocity gradient tensor as a numpy record array. The records are ‘dudx’, ‘dudy’, ‘dudz’ (change in u wind in the x, y, and z directions), ‘dvdx’, ‘dvdy’, ‘dvdz’ (change in v wind in the x, y, and z directions), ‘dwdx’, ‘dwdy’, and ‘dwdz’ (change in w wind in the x, y, and z directions). The returned array is the same shape as the input arrays.
virt_temp(**kwargs)[source]

Compute virtual temperature.

Parameters:**kwargs – Must contain two things. The first is either ‘t’ (temperature in K) or ‘pt’ and ‘p’ (potential temperature in K and pressure in Pa). The second is either ‘sph’ (specific humidity in kg/kg) or ‘qv’ (water vapor mixing ratio in kg/kg). Any other keyword arguments are ignored.
Returns:Virtual temperature in K.
virt_theta(**kwargs)[source]

Compute virtual potential temperature.

Parameters:**kwargs – Must contain ‘pt’ (potential temperature in K) and either ‘qv’ or ‘sph’ (water vapor mixing ratio or specific humidity, either in kg/kg). Any other keyword arguments are ignored.
Returns:Virtual potential temperature in K
vort_components(**kwargs)[source]

Compute all components of vorticity on a 3-dimensional grid.

Parameters:**kwargs – Must contain ‘u’, ‘u’, ‘w’, ‘x’, ‘y’, and ‘z’. u, v, and w are the zonal, meridional, and vertical components of wind, respectively, and must be 3-dimensional numpy arrays. The order of the axes is assumed to be (NZ, NY, NX). x and y should be 1-dimensional arrays containing the x and y coordinates for the domain, and z should be 3-dimensional arrays containing the vertical coordinates for the domain (e.g. ‘zp’ from an ARPS history file). All keywords that are not the aforementioned are ignored.
Returns:The 3 components of vorticity as a numpy record array. The records are ‘xvort’ (vorticity in the x direction), ‘yvort’ (vorticity in the y direction), and ‘zvort’ (vertical vorticity). The returned array is the same shape as the input arrays.
zp_to_scalar(zp)[source]

Converts ARPS physical height (zp) to height of scalar values (zps).

Parameters:zp – ARPS physical height array (dimensions: (nz, ny, nx))
Returns
zp_scalar: zp converted to the height of scalar values (similar to ARPS variable zps)

pycaps.derive.dropsizedist module

class GraupelPSD(qgraupel, density=400.0, shape_param=0.0, intercept_param=None, num_concentration=None)[source]

Bases: pycaps.derive.dropsizedist.PSD

Represents one or more particle size distributions for graupel.

Parameters:
  • qgraupel (np.array) – Graupel mixing ratio (kg/kg)
  • density (np.array) – Hydrometeor density (kg/m^3). Optional, default is 400 kg/m^3.
  • shape_param (np.array) – Shape parameter for the PSD. Optional, default is 0.
  • intercept_param (np.array) – Intercept parameter for the PSD in 1/m^4.
  • num_concentration (np.array) – Total number concentration for the PSD in #/m^3.
reflectivityJZX(density_air, rain_psd, max_mixed_frac)[source]

Compute the graupel PSD’s contribution to linear reflectivity using the method of Jung, Zhang, and Xue (2008).

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • rain_psd (PSD) – Rain PSD to compute water fractions with.
  • max_mixed_frac (float) – Maximum mixed fraction for the graupel PSD.
Returns:

Graupel contribution to linear reflectivity

reflectivityZhang(density_air, iswet)[source]

Compute the graupel PSD’s contribution to linear reflectivity using the Zhang method.

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • is_wet (np.array) – Array of integers (either 0 or 1) telling whether or not this region is above 0 C.
Returns:

Graupel contribution to linear reflectivity. Will be 0 for the Zhang method.

class HailPSD(qhail, density=913.0, shape_param=0.0, intercept_param=None, num_concentration=None)[source]

Bases: pycaps.derive.dropsizedist.PSD

Represents one or more particle size distributions for hail.

Parameters:
  • qhail (np.array) – Hail mixing ratio (kg/kg)
  • density (np.array) – Hydrometeor density (kg/m^3). Optional, default is 913 kg/m^3.
  • shape_param (np.array) – Shape parameter for the PSD. Optional, default is 0.
  • intercept_param (np.array) – Intercept parameter for the PSD in 1/m^4.
  • num_concentration (np.array) – Total number concentration for the PSD in #/m^3.
reflectivityJZX(density_air, rain_psd, max_mixed_frac)[source]

Compute the hail PSD’s contribution to linear reflectivity using the method of Jung, Zhang, and Xue (2008).

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • rain_psd (PSD) – Rain PSD to compute water fractions with.
  • max_mixed_frac (float) – Maximum mixed fraction for the hail PSD.
Returns:

Hail contribution to linear reflectivity

reflectivityZhang(density_air, is_wet)[source]

Compute the hail PSD’s contribution to linear reflectivity using the Zhang method.

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • is_wet (np.array) – Array of integers (either 0 or 1) telling whether or not this region is above 0 C.
Returns:

Hail contribution to linear reflectivity

class PSD(q_hydro, density_hydro, alpha_hydro=0.0, n0_hydro=None, nt_hydro=None)[source]

Bases: object

Represents one or more particle size distributions for any hydrometeor.

Parameters:
  • q_hydro (np.array) – Hydrometeor mixing ratio (kg/kg)
  • density_hydro (np.array) – Hydrometeor density (kg/m^3)
  • alpha_hydro (np.array) – Shape parameter for the PSD
  • n0_hydro (np.array) – Intercept parameter for the PSD
  • nt_hydro (np.array) – Total number concentration for the PSD
density

Hydrometeor density.

interceptParam(density_air)[source]

Get the intercept parameter for the distribution.

Parameters:density_air (np.array) – Density of the air (kg/m^3).
Returns:The intercept parameter for the PSD.
mixingrat

Hydrometeor mixing ratio.

reflectivityJZX = <pycaps.util.util.abstract object>[source]
reflectivityZhang = <pycaps.util.util.abstract object>[source]
class PSDCollection(rain=None, snow=None, hail=None, graupel=None)[source]

Bases: object

Uses several PSDs to compute total statistics for particles in a volume.

Parameters:
  • rain (PSD) – The rain PSD in the collection. Optional, default is no rain PSD.
  • snow (PSD) – The rain PSD in the collection. Optional, default is no snow PSD.
  • hail (PSD) – The rain PSD in the collection. Optional, default is no hail PSD.
  • graupel (PSD) – The rain PSD in the collection. Optional, default is no graupel PSD.
reflectivity(*args, **kwargs)[source]

Computes the total logarithmic reflectivity for this PSD collection using different methods. The methods are described below.

Parameters:
  • *args – Differ based on which method you’re using. When method=’zhang’, air temperature (K) and air density (kg/m^3) are required. For method=’jzx’, only air density (kg/m^3) is required.
  • method (string) – The method to use when computing reflectivity. ‘zhang’ uses the Zhang reflectivity calculations, intended for single-moment microphysics with no graupel category. ‘jzx’ uses the method of Jung, Zhang, and Xue (2008).
Returns:

Logarithmic reflectivity (dBZ) computed for all PSDs in this collection.

class RainPSD(qrain, density=1000.0, shape_param=0.0, intercept_param=None, num_concentration=None)[source]

Bases: pycaps.derive.dropsizedist.PSD

Represents one or more particle size distributions for rain.

Parameters:
  • qrain (np.array) – Rain mixing ratio (kg/kg)
  • density (np.array) – Hydrometeor density (kg/m^3). Optional, default is 1000 kg/m^3.
  • shape_param (np.array) – Shape parameter for the PSD. Optional, default is 0.
  • intercept_param (np.array) – Intercept parameter for the PSD in 1/m^4.
  • num_concentration (np.array) – Total number concentration for the PSD in #/m^3.
reflectivityJZX(density_air, *frozen_psds)[source]

Compute the rain PSD’s contribution to linear reflectivity using the method of Jung, Zhang, and Xue (2008).

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • frozen_psds (list) – List of tuples. Each tuple contains a frozen PSD to compute water fractions with and the maximum mixed fraction. May be called by reflectivityJZX(... *list_of_psds_and_mixed_fractions).
Returns:

Rain contribution to linear reflectivity

reflectivityZhang(density_air, is_wet)[source]

Compute the rain PSD’s contribution to linear reflectivity using the Zhang method.

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • is_wet (np.array) – Array of integers (either 0 or 1) telling whether or not this region is above 0 C.
Returns:

Rain contribution to linear reflectivity

class SnowPSD(qsnow, density=100.0, shape_param=0.0, intercept_param=None, num_concentration=None)[source]

Bases: pycaps.derive.dropsizedist.PSD

Represents one or more particle size distributions for snow.

Parameters:
  • qsnow (np.array) – Snow mixing ratio (kg/kg)
  • density (np.array) – Hydrometeor density (kg/m^3). Optional, default is 100 kg/m^3.
  • shape_param (np.array) – Shape parameter for the PSD. Optional, default is 0.
  • intercept_param (np.array) – Intercept parameter for the PSD in 1/m^4.
  • num_concentration (np.array) – Total number concentration for the PSD in #/m^3.
reflectivityJZX(density_air, rain_psd, max_mixed_frac)[source]

Compute the snow PSD’s contribution to linear reflectivity using the method of Jung, Zhang, and Xue (2008).

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • rain_psd (PSD) – Rain PSD to compute water fractions with.
  • max_mixed_frac (float) – Maximum mixed fraction for the snow PSD.
Returns:

Snow contribution to linear reflectivity

reflectivityZhang(density_air, is_wet)[source]

Compute the snow PSD’s contribution to linear reflectivity using the Zhang method.

Parameters:
  • density_air (np.array) – Density of the air (kg/m^3)
  • is_wet (np.array) – Array of integers (either 0 or 1) telling whether or not this region is above 0 C.
Returns:

Snow contribution to linear reflectivity

pycaps.derive.iterative module

condensation_temp(args, initial_args)[source]

Solve iteratively to find the temperature and pressure at which a parcel will condense if lifted adiabatically.

Parameters:
  • args (list) – A list containing temperature in K, pressure in kPa, and mixing ratio in g/g for this iteration.
  • initial_args (list) – A list containing temperature in K, pressure in kPa, and mixing ratio in g/g from the initial iteration.
Returns:

The next guess at the temperature, pressure, and mixing ratio for the condensation temperature of a parcel lifted adiabatically.

iterative_main()[source]
mixed_saturated_parcel(args, initial_args)[source]

Solve iteratively to find the temperature and vapor pressure of a supersaturated parcel after condensation.

Parameters:
  • args (list) – A list containing temperature in K, pressure in Pa, and vapor pressure in Pa for this iteration.
  • initial_args (list) – A list containing temperature in K, pressure in Pa, and vapor pressure in Pa from the initial iteration.
Returns:

The next guess at the temperature, pressure, and vapor pressure for a supersaturated parcel after condensation.

solve_iteratively(func, args, first_guess=None, tolerance=1e-05)[source]

Solve a function iteratively.

Parameters:
  • func (function) – The function to solve. It should take two lists of arguments, the first for this iteration, the second from the initial iteration.
  • args (list) – Initial set of arguments, representing the initial state of the parcel.
  • first_guess (list) – A first guess at the solution. Optional, defaults to the initial state if not given.
  • tolerance (float) – Tolerance on the change between successive solutions. Optional, defaults to 1e-5 if not given.
Returns:

An iterative solution to the provided function.

vapor_pressure(temperature, rel_humidity)[source]
wet_bulb_temp(args, initial_args)[source]

Solve iteratively to find the wet-bulb temperature for a parcel

Parameters:
  • args (list) – A list containing temperature in K, pressure in kPa, and mixing ratio in g/g for this iteration.
  • initial_args (list) – A list containing temperature in K, pressure in kPa, and mixing ratio in g/g from the initial iteration.
Returns:

The next guess at temperature, pressure, and mixing ratio for the wet-bulb temperature of a parcel.

pycaps.derive.parcel module

compute_el(parcel, snd)[source]

Computes EL given a parcel trace and environmental trace.

Parameters:
  • parcel (tuple) – A tuple of (parcel pressure in hPa, parcel temperature in degrees C). Both should be 1- dimensional arrays.
  • snd (tuple) – A tuple of (environmental pressure in hPa, environmental temperature in degrees C). Both should be 1-dimensional arrays.
Returns:

The pressure of the parcel EL in hPa. In the case of multiple ELs, the highest one (lowest in pressure) is returned.

compute_lcl(sfc_T, sfc_p, sfc_r=None, sfc_td=None)[source]

Compute the LCL pressure and temperature given parcel temperature, pressure, and mixing ratio or dewpoint.

Parameters:
  • sfc_T – Parcel temperature in degrees C
  • sfc_p – Parcel pressure in hPa
  • sfc_r – Parcel mixing ratio in g/g. Optional if sfc_td is specified.
  • sfc_td – Parcel dewpoint in degrees C. Optional if sfc_r is specified.
Returns:

LCL temperature in degrees C and LCL pressure in hPa.

compute_lfc(parcel, snd)[source]

Computes LFC given a parcel trace and environmental trace.

Parameters:
  • parcel (tuple) – A tuple of (parcel pressure in hPa, parcel temperature in degrees C). Both should be 1- dimensional arrays.
  • snd (tuple) – A tuple of (environmental pressure in hPa, environmental temperature in degrees C). Both should be 1-dimensional arrays.
Returns:

The pressure of the parcel LFC in hPa. In the case of multiple LFCs, the highest one (lowest in pressure) is returned.

ml_parcel(t_snd, p_snd, td_snd, ml_depth=100)[source]

Find the mixed-layer parcel given temperature, dewpoint, and pressure profiles.

Parameters:
  • t_snd (np.ndarray) – A 1-dimensional array of temperatures in degrees C.
  • p_snd (np.ndarray) – A 1-dimensional array of pressures in hPa.
  • td_snd (np.ndarray) – A 1-dimensional array of dewpoints in degrees C.
  • ml_depth (float) – The depth of the mixed layer in hPa. Optional, defaults to 100 hPa.
Returns:

Temperature, in degrees C, pressure in hPa, and dewpoint in degrees C of the mixed-layer parcel.

mu_parcel(t_snd, p_snd, td_snd, search_depth=300)[source]

Find the most-unstable parcel given temperature, dewpoint, and pressure profiles.

Parameters:
  • t_snd (np.ndarray) – A 1-dimensional array of temperatures in degrees C.
  • p_snd (np.ndarray) – A 1-dimensional array of pressures in hPa.
  • td_snd (np.ndarray) – A 1-dimensional array of dewpoints in degrees C.
  • search_depth (float) – The depth of the layer to search in hPa. Optional, defaults to 300 hPa.
Returns:

Temperature, in degrees C, pressure in hPa, and dewpoint in degrees C of the most-unstable parcel.

sb_parcel(t_snd, p_snd, td_snd)[source]

Find the surface-based parcel given temperature, dewpoint, and pressure profiles.

Parameters:
  • t_snd (np.ndarray) – A 1-dimensional array of temperatures in degrees C.
  • p_snd (np.ndarray) – A 1-dimensional array of pressures in hPa.
  • td_snd (np.ndarray) – A 1-dimensional array of dewpoints in degrees C.
Returns:

Temperature in degrees C, pressure in hPa, and dewpoint in degrees C of the surface-based parcel.

Module contents