dparcel.parcel module

Class for parcel theory calculations on real atmospheric soundings.

class dparcel.parcel.FastParcel(pressure, height, temperature, dewpoint, liquid_ratio=None, info='', name='')

Bases: dparcel.environment.Environment

Class for improved parcel theory calculations with entrainment.

buoyancy(height, initial_height, initial_temperature, z_switch, t_switch, theta_e, total_water, liquid_correction=True, improve=5)

Calculate the buoyancy of an entraining parcel.

Parameters
  • height – Array of heights of interest.

  • initial_height – Starting height of the parcel.

  • initial_temperature – Initial temperature of the parcel.

  • z_switch – Height at which the parcel’s liquid completely evaporates.

  • z_switch. (t_switch Parcel temperature at) –

  • theta_e – Callable, giving parcel equivalent potential temperature as a function of height.

  • total_water – Callable, giving total water content of the parcel as a function of height.

  • liquid_correction – Whether or not to account for the mass of liquid water in the parcel.

  • improve – Number of Newton iterations to perform.

Returns

Arrays of parcel buoyancies at the heights of interest.

motion(time, initial_height, initial_velocity, t_initial, q_initial, l_initial, rate, liquid_correction=True, improve=1)

Solve the equation of motion for the parcel.

Integration stops if the parcel reaches a minimum height or the surface.

Parameters
  • time – Array of times for which the results will be reported.

  • initial_height – Initial height.

  • initial_velocity – Initial vertical velocity.

  • t_initial – Initial temperature.

  • q_initial – Initial specific humidity.

  • l_initial – Initial liquid ratio.

  • rate – Entrainment rate.

  • liquid_correction – Whether or not to account for the mass of liquid water.

  • improve – Number of Newton iterations to use for calculating temperature values.

Returns

Bunch object with the folliwing fields defined –
  • height – Array of parcel height at each time step.

  • velocity – Array of parcel velocity at each time step.

  • temperature – Array of parcel temperature at each time step.

  • specific_humidity – Array of parcel specific humidity at each time step.

  • liquid_ratio – Array of parcel liquid water mass ratio at each time step.

  • density – Array of parcel density at each time step.

  • buoyancy – Array of parcel buoyancy at each time step.

  • neutral_buoyancy_time – The time at which the parcel reached its neutral buoyancy level (np.nan if this did not occur because the parcel reached the ground before becoming neutrally buoyant).

  • hit_ground_time – The time at which the parcel reached the surface (np.nan if this did not occur because the parcel stopped at some minimum height above the surface).

  • min_height_time – The time at which the parcel reached its minimum height (np.nan if this did not occur because it reached the surface).

  • neutral_buoyancy_height – The height of the neutral buoyancy level (np.nan if it does not exist because the parcel reached the ground before becoming neutrally buoyant).

  • neutral_buoyancy_velocity – The parcel’s velocity at its neutral buoyancy level (np.nan if this does not exist because the parcel reached the ground before becoming neutrally buoyant).

  • hit_ground_velocity – The parcel’s velocity at the surface (np.nan if the parcel did not reach the surface).

  • min_height – The minimum height reached by the parcel (np.nan if it reached the surface).

parcel_equivalent_potential_temperature(initial_height, initial_temperature, initial_specific_humidity, entrainment_rate)

Calculate equivalent potential temperature of an entraining parcel.

Follows Eq. (6) of Sherwood et al. 2013.

Parameters
  • initial_height – Initial parcel height.

  • initial_temperature – Initial parcel temperature.

  • initial_specific_humidity – Initial parcel specific humidity.

  • entrainment_rate – Parcel entrainment rate (either a constant or a callable function of height).

Returns

A function that returns the equivalent potential temperature of the parcel, given a height below the starting height.

properties(height, initial_height, initial_temperature, z_switch, t_switch, theta_e, total_water, improve=5)

Calculate the properties of an entraining parcel.

Parameters
  • height – Array of heights of interest.

  • initial_height – Starting height of the parcel.

  • initial_temperature – Initial temperature of the parcel.

  • z_switch – Height at which the parcel’s liquid completely evaporates.

  • z_switch. (t_switch Parcel temperature at) –

  • theta_e – Callable, giving parcel equivalent potential temperature as a function of height.

  • total_water – Callable, giving total water content of the parcel as a function of height.

  • improve – Number of Newton iterations to perform.

Returns

Arrays of parcel temperatures, specific humidities and liquid ratios at the heights of interest.

water_content(initial_height, initial_specific_humidity, initial_liquid_ratio, entrainment_rate)

Calculate total water content of an entraining parcel.

Parameters
  • initial_height – Initial parcel height.

  • initial_specific_humidity – Initial parcel specific humidity.

  • initial_liquid_ratio – Initial parcel liquid water mass ratio.

  • entrainment_rate – Parcel entrainment rate (either a constant or a callable function of height).

Returns

A function that returns the total water content of the parcel, given a height below the starting height.

class dparcel.parcel.IdealisedFastParcel(relative_humidity)

Bases: dparcel.parcel.FastParcel

FastParcel in an idealised sounding.

__init__(relative_humidity)

Creates an instance of IdealisedFastParcel.

Parameters

relative_humidity – Relative humidity above the boundary layer.

Returns

An instance of IdealisedFastParcel.

class dparcel.parcel.IdealisedParcel(relative_humidity)

Bases: dparcel.parcel.Parcel

Parcel in an idealised sounding.

__init__(relative_humidity)

Creates an instance of IdealisedParcel.

Parameters

relative_humidity – Relative humidity above the boundary layer.

Returns

An instance of IdealisedParcel.

class dparcel.parcel.MotionResult

Bases: object

Container for calculation results.

__init__()

Instantiates a MotionResult.

class dparcel.parcel.Parcel(pressure, height, temperature, dewpoint, liquid_ratio=None, info='', name='')

Bases: dparcel.environment.Environment

Class for parcel theory calculations with entrainment.

buoyancy(height, initial_height, t_initial, q_initial, l_initial, rate, step=<Quantity(50, 'meter')>, kind='pseudo', liquid_correction=True)

Calculate parcel buoyancy as a function of height.

Parameters
  • height – Height of the parcel.

  • initial_height – Initial height.

  • t_initial – Initial temperature.

  • q_initial – Initial specific humidity.

  • l_initial – Initial liquid ratio.

  • rate – Entrainment rate.

  • step – Step size for entrainment calculation.

  • kind – ‘pseudo’ for pseudoadiabats, ‘reversible’ for reversible adiabats.

  • liquid_correction – Whether or not to account for the mass of liquid water.

Returns

The buoyancy of the parcel at <height>.

motion(time, initial_height, initial_velocity, t_initial, q_initial, l_initial, rate, step=<Quantity(50, 'meter')>, kind='pseudo', liquid_correction=True)

Solve the equation of motion for the parcel.

Integration stops if the parcel reaches a minimum height or the surface.

Parameters
  • time – Array of times for which the results will be reported.

  • initial_height – Initial height.

  • initial_velocity – Initial vertical velocity.

  • t_initial – Initial temperature.

  • q_initial – Initial specific humidity.

  • l_initial – Initial liquid ratio.

  • rate – Entrainment rate.

  • step – Step size for entrainment calculation.

  • kind – ‘pseudo’ for pseudoadiabats, ‘reversible’ for reversible adiabats.

  • liquid_correction – Whether or not to account for the mass of liquid water.

Returns

Bunch object with the folliwing fields defined –
  • height – Array of parcel height at each time step.

  • velocity – Array of parcel velocity at each time step.

  • temperature – Array of parcel temperature at each time step.

  • specific_humidity – Array of parcel specific humidity at each time step.

  • liquid_ratio – Array of parcel liquid water mass ratio at each time step.

  • density – Array of parcel density at each time step.

  • buoyancy – Array of parcel buoyancy at each time step.

  • neutral_buoyancy_time – The time at which the parcel reached its neutral buoyancy level (np.nan if this did not occur because the parcel reached the ground before becoming neutrally buoyant).

  • hit_ground_time – The time at which the parcel reached the surface (np.nan if this did not occur because the parcel stopped at some minimum height above the surface).

  • min_height_time – The time at which the parcel reached its minimum height (np.nan if this did not occur because it reached the surface).

  • neutral_buoyancy_height – The height of the neutral buoyancy level (np.nan if it does not exist because the parcel reached the ground before becoming neutrally buoyant).

  • neutral_buoyancy_velocity – The parcel’s velocity at its neutral buoyancy level (np.nan if this does not exist because the parcel reached the ground before becoming neutrally buoyant).

  • hit_ground_velocity – The parcel’s velocity at the surface (np.nan if the parcel did not reach the surface).

  • min_height – The minimum height reached by the parcel (np.nan if it reached the surface).

parcel_density(height, initial_height, t_initial, q_initial, l_initial, rate, step=<Quantity(50, 'meter')>, kind='pseudo', liquid_correction=True)

Calculate parcel density as a function of height.

Parameters
  • height – Height of the parcel.

  • initial_height – Initial height.

  • t_initial – Initial temperature.

  • q_initial – Initial specific humidity.

  • l_initial – Initial liquid ratio.

  • rate – Entrainment rate.

  • step – Step size for entrainment calculation.

  • kind – ‘pseudo’ for pseudoadiabats, ‘reversible’ for reversible adiabats.

  • liquid_correction – Whether or not to account for the mass of liquid water.

Returns

The density of the parcel at <height>.

profile(height, t_initial, q_initial, l_initial, rate, step=<Quantity(50, 'meter')>, reference_height=None, kind='pseudo')

Calculate parcel properties for descent with entrainment.

Valid for arbitrary steps.

Parameters
  • height – Array of heights of interest.

  • t_initial – Initial parcel temperature.

  • q_initial – Initial parcel specific humidity.

  • l_initial – Initial parcel liquid ratio.

  • rate – Entrainment rate.

  • step – Size of downward step for computing finite differences.

  • kind – ‘pseudo’ for pseudoadiabats, ‘reversible’ for reversible adiabats.

Returns

3-tuple containing the temperature, specific humidity and

liquid ratio arrays for the given height array.