stilt.sampling.sample_met#
- stilt.sampling.sample_met(particles, files, columns=('mlht', 'dens', 'pres', 'zsfc'))[source]#
Return the particles with met columns sampled from ARL files at each particle’s position.
A transport model that writes only positions can get the columns HYSPLIT writes from the met this way. Each row is sampled at its
lon,lat,zagl, andtime: bilinear across the met’s grid and linear in height between its levels (arlmet.sample_points()), then linear in time between the two met times around the particle’s, as HYSPLIT does. Each column comes from these ARL variables:mlhtisPBLH, the met model’s boundary-layer height, in m above ground.densis 100PRES/ (RTEMP(1 + 0.61SPHU)), the density of moist air in kg m⁻³, with R = 287.04 J kg⁻¹ K⁻¹.presisPRES, the pressure, in hPa.zsfcisSHGT, the terrain height, in m above sea level.
The values are the met’s, not HYSPLIT’s. HYSPLIT’s
mlhtis the met’sPBLHonly withkmixd: 0, and then it is at leastkmix0; the default,kmixd: 3, finds the mixed layer from the profile. HYSPLIT also finds the heights of the met’s levels its own way, so itspresanddensdiffer from these; Meteorology says by how much.- Parameters:
particles (
DataFrame) – A particle table withlon,lat,zagl, andtime.sim.particleshastime. For a table a transport model returned, add it: the receptor time plusageminutes.files (
Iterable[str|PathLike[str]]) – ARL met files that cover the particles’ times, such as the files the run read (met_filesofstilt.transport.ModelRunor ofstilt.particles.particles_metadata()).
- Returns:
A copy of particles with the columns added. A row off the met’s grid, below its lowest level, or above its top is NaN.
- Return type:
- Raises:
ValueError – If a column is not one of the four or is in particles already (drop it first), particles has no
timecolumn, or a row is outside the files’ times.KeyError – If the files lack a variable a column needs.
Examples
>>> meta = stilt.particles.particles_metadata(sim.particles_path) >>> hysplit = sim.particles >>> sampled = stilt.sampling.sample_met( ... hysplit.drop(columns="pres"), meta.met_files, columns=["pres"] ... ) >>> (sampled["pres"] - hysplit["pres"]).describe()