MCPcopy Create free account
hub / github.com/NCAR/wrf-python / get_rh

Function get_rh

src/wrf/g_rh.py:12–82  ·  view source on GitHub ↗

Return the relative humidity. This functions extracts the necessary variables from the NetCDF file object in order to perform the calculation. Args: wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ iterable): WRF-ARW NetCDF data as a :clas

(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
           meta=True, _key=None)

Source from the content-addressed store, hash-verified

10 description="relative humidity",
11 units="%")
12def get_rh(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
13 meta=True, _key=None):
14 """Return the relative humidity.
15
16 This functions extracts the necessary variables from the NetCDF file
17 object in order to perform the calculation.
18
19 Args:
20
21 wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \
22 iterable): WRF-ARW NetCDF
23 data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile`
24 or an iterable sequence of the aforementioned types.
25
26 timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The
27 desired time index. This value can be a positive integer,
28 negative integer, or
29 :data:`wrf.ALL_TIMES` (an alias for None) to return
30 all times in the file or sequence. The default is 0.
31
32 method (:obj:`str`, optional): The aggregation method to use for
33 sequences. Must be either 'cat' or 'join'.
34 'cat' combines the data along the Time dimension.
35 'join' creates a new dimension for the file index.
36 The default is 'cat'.
37
38 squeeze (:obj:`bool`, optional): Set to False to prevent dimensions
39 with a size of 1 from being automatically removed from the shape
40 of the output. Default is True.
41
42 cache (:obj:`dict`, optional): A dictionary of (varname, ndarray)
43 that can be used to supply pre-extracted NetCDF variables to the
44 computational routines. It is primarily used for internal
45 purposes, but can also be used to improve performance by
46 eliminating the need to repeatedly extract the same variables
47 used in multiple diagnostics calculations, particularly when using
48 large sequences of files.
49 Default is None.
50
51 meta (:obj:`bool`, optional): Set to False to disable metadata and
52 return :class:`numpy.ndarray` instead of
53 :class:`xarray.DataArray`. Default is True.
54
55 _key (:obj:`int`, optional): A caching key. This is used for internal
56 purposes only. Default is None.
57
58 Returns:
59 :class:`xarray.DataArray` or :class:`numpy.ndarray`: The relative
60 humidity. If xarray is
61 enabled and the *meta* parameter is True, then the result will be a
62 :class:`xarray.DataArray` object. Otherwise, the result will be a
63 :class:`numpy.ndarray` object with no metadata.
64
65 """
66 varnames = ("T", "P", "PB", "QVAPOR")
67 ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache,
68 meta=False, _key=_key)
69 t = ncvars["T"]

Callers

nothing calls this directly

Calls 3

extract_varsFunction · 0.85
_tkFunction · 0.85
_rhFunction · 0.85

Tested by

no test coverage detected