runtraj.sampling.calc_pbl_height#
- runtraj.sampling.calc_pbl_height(particles, met, *, method='hysplit', z_top=25000.0)[source]#
Return the mixed-layer height at each particle, found from the met as a transport model finds it.
The mixed layer a stage reads should be the one the particles were mixed in, and each transport model finds it in its own way. Choose the method of the run the particles came from:
"hysplit"(the default): HYSPLIT’s default,kmixd: 3. Going up the column, the mixed layer ends where the bulk Richardson number between the lowest level and the level reached passes 0.25 (below)."hysplit_temperature": HYSPLIT’skmixd: 1. The top is the highest level whose potential temperature is within 2 K of the column’s lowest."met": the met’s own boundary-layer heightPBLH, as it is used with HYSPLIT’skmixd: 0."flexpart": FLEXPART’s Richardson method (below), for a FLEXPART run on ERA5 model levels. FLEXPART on GFS uses the met’sPBLHinstead; give it"met".
HYSPLIT finds the height at each met grid point and met time, and a particle takes the nearest grid point’s height at the met times before and after it, linear in time. The three HYSPLIT methods do the same, on HYSPLIT’s internal levels for a run with the top z_top. They apply no minimum, as HYSPLIT’s
kmix0does: takenumpy.maximumwith yours. Each height is at least a little above the lowest internal level, as in HYSPLIT."hysplit"is ported from HYSPLIT’s source (stbanl.f, Holtslag and Boville, 1993):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 velocityu*(USTR) and the friction temperatureθ*from the sensible heat flux (SHTF) at the ground. The height is interpolated to where Ri is 0.25. A column with no height where Ri reaches 0.25 gets the second-highest internal level, as in HYSPLIT."flexpart"is ported from FLEXPART 11’srichardson(getfields_mod.f90, after Vogelezang and Holtslag, 1996). It works on the met’s own levels, with heights integrated up from 2 m, and measures from the 2 m virtual potential temperature θᵥ₂ (T02M,DP2M) and the wind of the lowest level V₁:Ri = g · (θᵥ(z) − θᵥ₂ − θₑ) · (z − 2) / ((θᵥ₂ + θₑ) · max(|V(z) − V₁|² + 100 u*², 0.1))
The top is where Ri first passes 0.25 in a layer that is not unstable, found to a twentieth of the layer. In unstable air the temperature excess θₑ = 8.5 H / (cₚ w*), with H the upward heat flux and w* the convective velocity of that top, is added and the top found again, up to three times. The height is kept between 100 and 4500 m, as FLEXPART keeps it. A particle takes the greatest height of the four grid points around it at the met times before and after it, as FLEXPART does by default. FLEXPART’s
LSUBGRID: 1raises the height by a subgrid-orography excess; that is left out, since the converted met holds no subgrid orography, and FLEXPART leaves it off by default.On three 6-hour HRRR runs from Salt Lake City,
"hysplit", kept at least 150 m, has a median ratio of 0.999 to 1.000 to themlhtHYSPLIT wrote withkmixd: 3, and 73 to 94 % of rows are within 2 %. On a 24-hour FLEXPART 11 run on ERA5 model levels from Salt Lake City,"flexpart"matched the mixed layer FLEXPART found (Notes).- Parameters:
particles (
DataFrame) – A particle table withlon,lat, andtime.met (
str|PathLike[str] |Iterable[str|PathLike[str]] |Dataset) –ARL met files that cover the particles’ times, or met in another format as one Dataset in
arlmet.open_dataset()’s layout, assample_met()takes. What it needs depends on method:"hysplit":TEMP,UWND,VWNDandSHGT, the sensible heat fluxSHTF, the friction velocityUSTRor the momentum fluxesUMOFandVMOF, and the pressure:PRES, or a vertical axis it follows from."hysplit_temperature":TEMP,SHGTand the pressure."met":PBLHandSHGT."flexpart":TEMP,SPHU,UWND,VWND, the pressure, and at the groundPRSS,T02M,DP2M,U10M,V10M,USTRandSHTF.
method (
str) – How the mixed layer is found: the transport model and its method.z_top (
float) – The top of the domain in meters, which sets HYSPLIT’s internal levels (z_topofruntraj.models.hysplit.HysplitConfig)."flexpart"reads the met’s own levels and ignores it.
- Returns:
The mixed-layer height at each row, in m above ground. A row off the met’s grid is NaN. A met time that lacks the surface fluxes, as a GFS analysis (
f000) does without the previous cycle’s forecast, has no height from"hysplit"or"flexpart": a row at that time is NaN, and a row between it and a met time with the fluxes takes the height of the other time. (HYSPLIT refuses such met, so there is nomlhtof its own to compare.) A column where"flexpart"finds no top in the met’s levels has none, where FLEXPART stops.- Return type:
- Raises:
ValueError – If method is not one of the four, particles has no
timecolumn, or a row is outside the files’ times.KeyError – If the met lacks a variable the method needs.
Notes
A Dataset gives the met’s own values. HYSPLIT reads the ARL file written from it, whose values are packed: in mountains
SHGTcan move by a few meters. In a deep, nearly neutral afternoon layer, a few meters near the ground move the"hysplit"height by hundreds of meters, most of all on pressure levels, whose first level above the ground can be only meters above HYSPLIT’s lowest internal level. On two hours of ERA5 pressure levels over Salt Lake City in July, the height from the Dataset had a median ratio of 0.91 to HYSPLIT’smlht. From the ARL file HYSPLIT read, the median ratio was 0.999, with 99 % of rows within 2 %. To compare with a HYSPLIT run, give the files it read.FLEXPART writes a particle’s
hmixinterpolated from the grid points’ heights (bilinear across the grid, linear in time), not the greatest of them it mixes the particle in, so"flexpart"is at least thehmixit wrote at most rows. Interpolated the same way, the grid points’ heights"flexpart"finds had a median ratio of 1.000 to thehmixof the run above, with 80 % of 24,000 rows within 2 % and 94 % within 10 %. The rest comes from the converted met, which differs from what FLEXPART reads in two small ways: an ARL hybrid level keeps its pressure offset to the whole hPa, andUSTRis found with the density of dry air at 2 m, where FLEXPART uses moist air.Examples
>>> meta = runtraj.particles.particles_metadata( ... sim.particles_path ... ) >>> mlht = runtraj.sampling.calc_pbl_height( ... sim.particles, meta.met_files ... )
A FLEXPART run on ERA5, with the met its transport model opens:
>>> met = runtraj.models.open_met( ... "flexpart", met_config, files, bounds ... ) >>> mlht = runtraj.sampling.calc_pbl_height( ... particles, met, method="flexpart" ... )