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 a single ARL file or a sequence of files spanning different time periods. Each source may be an open File or a path to an ARL file; paths are opened (read mode) and closed automatically, while already-open Files are left open for the caller to manage.

Parameters:
  • source (Union[File, str, PathLike[str], Sequence[Union[File, str, PathLike[str]]]]) – A single open File or path, or a sequence of Files and/or paths. Each timestamp must appear in at most one source.

  • points (DataFrame | Mapping[str, Any]) – DataFrame or dict with columns lon, lat, z, and time. time may be omitted when source resolves to 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 arlmet.File.sample_points() 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"]}
... )
>>> arlmet.sample_points("met.arl", points, ["UWND", "VWND"])

Sample across files spanning different times by passing their paths:

>>> arlmet.sample_points(["met_00.arl", "met_06.arl"], points, ["UWND", "VWND"])