stilt.sampling.calc_pbl_height#

stilt.sampling.calc_pbl_height(particles, files, *, z_top=25000.0)[source]#

Return the mixed-layer height at each particle, found from the met’s profile as HYSPLIT’s kmixd: 3 finds it.

This is HYSPLIT’s default way to find the mixed layer, ported from its source (stbanl.f, Holtslag and Boville, 1993). Going up the column, the mixed layer ends where the bulk Richardson number between the lowest level and the level reached passes 0.25:

Ri = g · (θ(z) − θ₁ − θₑ) · (z − z₁) / ((θ₁ + θₑ) · |V(z) − V₁|²)

with θ the potential temperature, V the horizontal wind, and level 1 HYSPLIT’s lowest internal level. θₑ, the temperature excess of rising air, is 8.5 u* θ* / (u*³ + 0.6 w*³)^(1/3) in unstable air and 0 otherwise, with the friction velocity u* (USTR) and the friction temperature θ* from the sensible heat flux (SHTF) at the ground. The height is interpolated to where Ri is 0.25.

HYSPLIT computes the height at each met grid point and met time; a particle takes the nearest grid point’s height at the met times before and after it, linear in time. So does this function, on HYSPLIT’s internal levels for a run with the top z_top. It applies no minimum: HYSPLIT’s kmix0 is pbl_height_min in PYSTILT. A column with no height where Ri reaches 0.25 gets the second-highest internal level, as in HYSPLIT. Validation says how close it comes to the mlht HYSPLIT writes.

Parameters:
  • particles (DataFrame) – A particle table with lon, lat, and time.

  • files (Iterable[str | PathLike[str]]) – ARL met files that cover the particles’ times, with TEMP, PRES, UWND, VWND and SHGT, the sensible heat flux SHTF, and the friction velocity USTR or the momentum fluxes UMOF and VMOF.

  • z_top (float) – The top of the domain in meters, which sets HYSPLIT’s internal levels (z_top of runtraj.models.hysplit.HysplitConfig).

Returns:

The mixed-layer height at each row, in m above ground. A row off the met’s grid is NaN.

Return type:

ndarray

Raises:
  • ValueError – If particles has no time column or a row is outside the files’ times.

  • KeyError – If the files lack a variable it needs.

Examples

>>> meta = runtraj.particles.particles_metadata(
...     sim.particles_path
... )
>>> mlht = stilt.sampling.calc_pbl_height(
...     sim.particles, meta.met_files
... )