arlmet.open_dataset#

arlmet.open_dataset(filename_or_obj, *, drop_variables=None, bbox=None, bbox_crs=None, levels=None)[source]#

Open an ARL meteorology file as an xarray Dataset.

Surface-only variables (e.g. SHGT, T02M, PRSS) have dimensions (time, lat, lon) with no level dimension. Upper-air variables (e.g. UWND, VWND, TEMP) have dimensions (time, level, lat, lon). An upper-air variable stored on only some levels (or times) is NaN where the file has no record for it, and so is a record flagged missing.

The level coordinate holds the file’s ARL level indices (surface is 0, so upper-air levels start at 1). With levels= the kept levels keep their original indices, which may therefore have gaps.

The forecast_hour(time) coordinate holds each time step’s forecast hour, the one its index record stores. A data record’s own forecast hour can differ (an accumulated field taken from a 6-hour forecast may say 6 where the index record says 0), but it is not represented here: HYSPLIT reads a data record’s forecast hour only as the missing flag, and the hour it uses is the index record’s. arlmet.DataRecord.forecast reads a record’s own hour.

Values are as the file stores them. On a mass-coupled WRF file (source AWRF with MUU0 and MUV0, the time-averaged winds of arw2arl) UWND, VWND and WWND are coupled to the column mass, and their description attribute gives the conversion HYSPLIT makes (UWND * MSFU / MUU0, …); arlmet.sample_points() returns the converted winds.

ARL metadata is accessible via the .arl accessor:

ds = arlmet.open_dataset("met.arl")
ds.arl.grid  # Grid object (survives isel/sel)
ds.arl.vertical_axis  # VerticalAxis
ds.isel(level=0)  # selects level 0 for upper vars; sfc vars unchanged
Parameters:
  • filename_or_obj (str | PathLike[str]) – Path to the ARL file.

  • drop_variables (Sequence[str] | None) – Variable names to omit from the resulting dataset.

  • bbox (tuple[float, float, float, float] | None) – Geographic bounding box (west, south, east, north) in degrees. On a projected grid the crop is the smallest rectangle of cells that holds the box’s part on the grid (arlmet.Grid.window_from_bbox()).

  • bbox_crs (Any) – The coordinate reference system bbox is in ("EPSG:32612", anything pyproj.CRS.from_user_input() takes), making the box (xmin, ymin, xmax, ymax) in its units; the default is degrees (arlmet.Grid.window_from_bbox()).

  • levels (Iterable[int] | None) – ARL level indices to keep.

Returns:

attrs holds source, vertical_flag and arlmet_version, the arlmet version that built the Dataset.

Return type:

Dataset