arlmet.sample_points#

arlmet.sample_points(source, points, variables, *, time=None, z_kind='pressure', method='linear')[source]#

Sample meteorological variables at arbitrary (lon, lat, z, time) points.

Accepts one file or a sequence of files spanning different time periods. For single-file sampling prefer sample_points_from_file() to avoid the overhead of building a time-to-file map.

Parameters:
  • source (File | Sequence[File]) – A single File or a sequence of files. Each timestamp must appear in at most one file.

  • points (DataFrame | Mapping[str, Any]) – DataFrame or dict with columns lon, lat, z, and time. time may be omitted when source is a single-time file.

  • variables (str | Iterable[str]) – One or more ARL field names, or 'pressure' for the virtual pressure variable.

  • time (Union[Timestamp, str, None]) – Override or supply a single timestamp when points has no time column.

  • z_kind (str) – Vertical coordinate for z: 'native', 'pressure', 'agl', or 'msl'. See sample_points_from_file() for details.

  • method (str) – Horizontal interpolation: 'linear' (bilinear) or 'nearest'.

Returns:

Copy of points with one column added per requested variable, index preserved.

Return type:

pd.DataFrame

Examples

>>> import pandas as pd
>>> import arlmet
>>> points = pd.DataFrame(
...     {"lon": [-111.9], "lat": [40.7], "z": [850.0], "time": ["2024-07-18 00:00"]}
... )
>>> with arlmet.File("met.arl") as met:
...     arlmet.sample_points(met, points, ["UWND", "VWND"])