wrf.extract_vars

wrf.extract_vars(wrfin, timeidx, varnames, method='cat', squeeze=True, cache=None, meta=True, _key=None)

Extract variables from a NetCDF file object or a sequence of NetCDF file objects.

Parameters:
  • wrfin (iterable) – An iterable type, which includes lists, tuples, dictionaries, generators, and user-defined classes.
  • varnames (sequence of str) – A sequence of variable names.
  • timeidx (int or wrf.ALL_TIMES, optional) – The desired time index. This value can be a positive integer, negative integer, or wrf.ALL_TIMES (an alias for None) to return all times in the file or sequence. The default is 0.
  • method (str, optional) – The aggregation method to use for sequences. Must be either ‘cat’ or ‘join’. ‘cat’ combines the data along the Time dimension. ‘join’ creates a new dimension for the file index. The default is ‘cat’.
  • squeeze (bool, optional) – Set to False to prevent dimensions with a size of 1 from being automatically removed from the shape of the output. Default is True.
  • cache (dict, optional) – A dictionary of (varname, ndarray) that can be used to supply pre-extracted NetCDF variables to the computational routines. It is primarily used for internal purposes, but can also be used to improve performance by eliminating the need to repeatedly extract the same variables used in multiple diagnostics calculations, particularly when using large sequences of files. Default is None.
  • meta (bool, optional) – Set to False to disable metadata and return numpy.ndarray instead of xarray.DataArray. Default is True.
  • _key (int, optional) – Cache key for the coordinate variables. This is used for internal purposes only. Default is None.
Returns:

A mapping of variable name to an array object. If xarray is enabled and the meta parameter is True, then the array object will be a xarray.DataArray object. Otherwise, the array object will be a numpy.ndarray object with no metadata.

Return type:

dict