arlmet.File.extract_subset#

File.extract_subset(dest, *, bbox=None, bbox_crs=None, levels=None, variables=None)[source]#

Write a spatial/vertical subset of this file to a new ARL file.

Equivalent to arlmet.extract_subset() with this file’s path as the input.

Parameters:
  • dest (str | PathLike[str]) – Output ARL file. Overwrites any existing file. Must not be this file.

  • 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. Output levels are compacted and renumbered from zero while preserving the selected level heights.

  • variables (str | Iterable[str] | None) – Variable names to keep, as the file spells them; a single string is one name. All variables are included by default.

Returns:

The output path, Path(dest).

Return type:

Path

Examples

>>> import arlmet
>>> with arlmet.File("met.arl") as met:
...     out = met.extract_subset("subset.arl", bbox=(-114, 39, -110, 42))
>>> ds = arlmet.open_dataset(out)