arlmet.extract_subset#
- arlmet.extract_subset(source_path, destination_path, *, bbox=None, levels=None, variables=None)[source]#
Extract a spatial/vertical subset from an ARL file into a new ARL file.
- Parameters:
source_path (path-like) – Input and output ARL file paths.
destination_path (path-like) – Input and output ARL file paths.
bbox (tuple[float, float, float, float], optional) – Geographic bounding box
(west, south, east, north)in degrees.levels (iterable of int, optional) – ARL level indices to keep. Output levels are compacted and renumbered from zero while preserving the selected level heights.
variables (iterable of str, optional) – Variable names to keep. All variables are included by default.
- Returns:
The newly written subset, opened in read mode. Close it when done (or use it as a context manager). Callers that only need the file on disk may ignore the return value.
- Return type:
Examples
>>> import arlmet >>> with arlmet.extract_subset( ... "met.arl", ... "subset.arl", ... bbox=(-114.0, 39.0, -110.0, 42.0), ... levels=[0, 1, 2], ... ) as subset: ... ds = subset.to_dataset()