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

Function get_rh_2m

src/wrf/g_rh.py:88–154  ·  view source on GitHub ↗

Return the 2m 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 :c

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

Source from the content-addressed store, hash-verified

86 description="2m relative humidity",
87 units="%")
88def get_rh_2m(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
89 meta=True, _key=None):
90 """Return the 2m relative humidity.
91
92 This functions extracts the necessary variables from the NetCDF file
93 object in order to perform the calculation.
94
95 Args:
96
97 wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \
98 iterable): WRF-ARW NetCDF
99 data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile`
100 or an iterable sequence of the aforementioned types.
101
102 timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The
103 desired time index. This value can be a positive integer,
104 negative integer, or
105 :data:`wrf.ALL_TIMES` (an alias for None) to return
106 all times in the file or sequence. The default is 0.
107
108 method (:obj:`str`, optional): The aggregation method to use for
109 sequences. Must be either 'cat' or 'join'.
110 'cat' combines the data along the Time dimension.
111 'join' creates a new dimension for the file index.
112 The default is 'cat'.
113
114 squeeze (:obj:`bool`, optional): Set to False to prevent dimensions
115 with a size of 1 from being automatically removed from the shape
116 of the output. Default is True.
117
118 cache (:obj:`dict`, optional): A dictionary of (varname, ndarray)
119 that can be used to supply pre-extracted NetCDF variables to the
120 computational routines. It is primarily used for internal
121 purposes, but can also be used to improve performance by
122 eliminating the need to repeatedly extract the same variables
123 used in multiple diagnostics calculations, particularly when using
124 large sequences of files.
125 Default is None.
126
127 meta (:obj:`bool`, optional): Set to False to disable metadata and
128 return :class:`numpy.ndarray` instead of
129 :class:`xarray.DataArray`. Default is True.
130
131 _key (:obj:`int`, optional): A caching key. This is used for internal
132 purposes only. Default is None.
133
134 Returns:
135 :class:`xarray.DataArray` or :class:`numpy.ndarray`: The 2m relative
136 humidity. If xarray is
137 enabled and the *meta* parameter is True, then the result will be a
138 :class:`xarray.DataArray` object. Otherwise, the result will be a
139 :class:`numpy.ndarray` object with no metadata.
140
141 """
142 varnames = ("T2", "PSFC", "Q2")
143 ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache,
144 meta=False, _key=_key)
145 t2 = ncvars["T2"]

Callers

nothing calls this directly

Calls 2

extract_varsFunction · 0.85
_rhFunction · 0.85

Tested by

no test coverage detected