forked from 3rdparty/wrf-python
29 changed files with 5953 additions and 6039 deletions
@ -1,265 +1,254 @@ |
|||||||
from __future__ import (absolute_import, division, print_function) |
from __future__ import (absolute_import, division, print_function) |
||||||
|
|
||||||
from .py3compat import py2round |
from .py3compat import py2round |
||||||
|
|
||||||
|
|
||||||
def _binary_operator(operator): |
def _binary_operator(operator): |
||||||
"""Function wrapper for binary operators. |
"""Function wrapper for binary operators. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
operator (method): The operator to wrap. |
operator (method): The operator to wrap. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
method: An implementation for the *operator* type. |
method: An implementation for the *operator* type. |
||||||
|
|
||||||
""" |
""" |
||||||
def func(self, other): |
def func(self, other): |
||||||
"""Operator implementation. |
"""Operator implementation. |
||||||
|
|
||||||
Operator action is performed across the same class attributes when |
Operator action is performed across the same class attributes when |
||||||
the *other* object is a :class:`CoordPair`. If the *other* object is |
the *other* object is a :class:`CoordPair`. If the *other* object is |
||||||
a scalar value, the operator action is performed across all |
a scalar value, the operator action is performed across all |
||||||
attributes with the scalar value. |
attributes with the scalar value. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
other (:class:`CoordPair` or scalar): A separate :class:`CoordPair` |
other (:class:`CoordPair` or scalar): A separate :class:`CoordPair` |
||||||
object or scalar value. |
object or scalar value. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
:class:`CoordPair`: A new :class:`CoordPair` object that is the |
:class:`CoordPair`: A new :class:`CoordPair` object that is the |
||||||
result of the operator action. |
result of the operator action. |
||||||
|
|
||||||
""" |
""" |
||||||
if isinstance(other, CoordPair): |
if isinstance(other, CoordPair): |
||||||
args = [ |
args = [None if getattr(self, attr) is None or |
||||||
None if getattr(self, attr) is None or getattr(other, attr) is None |
getattr(other, attr) is None else |
||||||
else getattr(getattr(self, attr), operator)(getattr(other, attr)) |
getattr(getattr(self, attr), operator)(getattr(other, |
||||||
for attr in ("x", "y", "lat", "lon")] |
attr)) |
||||||
|
for attr in ("x", "y", "lat", "lon")] |
||||||
else: |
else: |
||||||
args = [ |
args = [None if getattr(self, attr) is None |
||||||
None if getattr(self, attr) is None |
else getattr(getattr(self, attr), operator)(other) |
||||||
else getattr(getattr(self, attr), operator)(other) |
for attr in ("x", "y", "lat", "lon")] |
||||||
for attr in ("x", "y", "lat", "lon")] |
|
||||||
|
|
||||||
return CoordPair(*args) |
return CoordPair(*args) |
||||||
|
|
||||||
return func |
return func |
||||||
|
|
||||||
|
|
||||||
def _unary_operator(operator): |
def _unary_operator(operator): |
||||||
"""Function wrapper for unary operators. |
"""Function wrapper for unary operators. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
operator (method): The operator to wrap. |
operator (method): The operator to wrap. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
method: An implementation for the *operator* type. |
method: An implementation for the *operator* type. |
||||||
|
|
||||||
""" |
""" |
||||||
def func(self): |
def func(self): |
||||||
"""Operator implementation. |
"""Operator implementation. |
||||||
|
|
||||||
Operator action is performed across all class attributes. |
Operator action is performed across all class attributes. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
:class:`CoordPair`: A new :class:`CoordPair` object that is the |
:class:`CoordPair`: A new :class:`CoordPair` object that is the |
||||||
result of the operator action. |
result of the operator action. |
||||||
|
|
||||||
""" |
""" |
||||||
args = [None if getattr(self, attr) is None |
args = [None if getattr(self, attr) is None |
||||||
else getattr(getattr(self, attr), operator)() |
else getattr(getattr(self, attr), operator)() |
||||||
for attr in ("x", "y", "lat", "lon")] |
for attr in ("x", "y", "lat", "lon")] |
||||||
|
|
||||||
return CoordPair(*args) |
return CoordPair(*args) |
||||||
|
|
||||||
return func |
return func |
||||||
|
|
||||||
|
|
||||||
def _cmp_operator(operator): |
def _cmp_operator(operator): |
||||||
"""Function wrapper for comparison operators. |
"""Function wrapper for comparison operators. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
operator (method): The operator to wrap. |
operator (method): The operator to wrap. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
method: An implementation for the *operator* type. |
method: An implementation for the *operator* type. |
||||||
|
|
||||||
""" |
""" |
||||||
|
|
||||||
def func(self, other): |
def func(self, other): |
||||||
"""Operator implementation. |
"""Operator implementation. |
||||||
|
|
||||||
Performs a comparison operation across all of the same class |
Performs a comparison operation across all of the same class |
||||||
attributes, and returns True if all these operations are True. |
attributes, and returns True if all these operations are True. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
:obj:`boot`: Returns True if all comparisons across class |
:obj:`boot`: Returns True if all comparisons across class |
||||||
attributes returns True, otherwise False. |
attributes returns True, otherwise False. |
||||||
|
|
||||||
""" |
""" |
||||||
vals = [getattr(getattr(self, attr), operator)(getattr(other, attr)) |
vals = [getattr(getattr(self, attr), operator)(getattr(other, attr)) |
||||||
for attr in ("x", "y", "lat", "lon") |
for attr in ("x", "y", "lat", "lon") |
||||||
if getattr(self, attr) is not None] |
if getattr(self, attr) is not None] |
||||||
|
|
||||||
return all(vals) |
return all(vals) |
||||||
|
|
||||||
return func |
return func |
||||||
|
|
||||||
|
|
||||||
class CoordPair(object): |
class CoordPair(object): |
||||||
"""A class that stores (x, y) and/or (latitude, longitude) |
"""A class that stores (x, y) and/or (latitude, longitude) |
||||||
coordinate pairs. |
coordinate pairs. |
||||||
|
|
||||||
Most math operators are supplied. When the other operand is a |
Most math operators are supplied. When the other operand is a |
||||||
:class:`CoordPair`, the operation is performed with the same attribute. |
:class:`CoordPair`, the operation is performed with the same attribute. |
||||||
When a math operation uses a scalar as the other operand, the |
When a math operation uses a scalar as the other operand, the |
||||||
operation is applied across all attributes. |
operation is applied across all attributes. |
||||||
|
|
||||||
Attributes: |
Attributes: |
||||||
|
|
||||||
x (:obj:`float`): The x-coordinate. |
x (:obj:`float`): The x-coordinate. |
||||||
y (:obj:`float`): The y-coordinate. |
y (:obj:`float`): The y-coordinate. |
||||||
lat (:obj:`float`): The latitude coordinate. |
lat (:obj:`float`): The latitude coordinate. |
||||||
lon (:obj:`float`): The longitude coordinate. |
lon (:obj:`float`): The longitude coordinate. |
||||||
|
|
||||||
|
|
||||||
""" |
""" |
||||||
def __init__(self, x=None, y=None, lat=None, lon=None): |
def __init__(self, x=None, y=None, lat=None, lon=None): |
||||||
"""Initialize a :class:`CoordPair` object. |
"""Initialize a :class:`CoordPair` object. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
x (:obj:`float`, optional): The x-coordinate. |
x (:obj:`float`, optional): The x-coordinate. |
||||||
y (:obj:`float`, optional): The y-coordinate. |
y (:obj:`float`, optional): The y-coordinate. |
||||||
lat (:obj:`float`, optional): The latitude coordinate. |
lat (:obj:`float`, optional): The latitude coordinate. |
||||||
lon (:obj:`float`, optional): The longitude coordinate. |
lon (:obj:`float`, optional): The longitude coordinate. |
||||||
|
|
||||||
|
|
||||||
""" |
""" |
||||||
self.x = x |
self.x = x |
||||||
self.y = y |
self.y = y |
||||||
self.lat = lat |
self.lat = lat |
||||||
self.lon = lon |
self.lon = lon |
||||||
|
|
||||||
|
|
||||||
def __repr__(self): |
def __repr__(self): |
||||||
args = [] |
args = [] |
||||||
if self.x is not None: |
if self.x is not None: |
||||||
args.append("x={}".format(self.x)) |
args.append("x={}".format(self.x)) |
||||||
args.append("y={}".format(self.y)) |
args.append("y={}".format(self.y)) |
||||||
|
|
||||||
if self.lat is not None: |
if self.lat is not None: |
||||||
args.append("lat={}".format(self.lat)) |
args.append("lat={}".format(self.lat)) |
||||||
args.append("lon={}".format(self.lon)) |
args.append("lon={}".format(self.lon)) |
||||||
|
|
||||||
argstr = ", ".join(args) |
argstr = ", ".join(args) |
||||||
|
|
||||||
return "{}({})".format(self.__class__.__name__, argstr) |
return "{}({})".format(self.__class__.__name__, argstr) |
||||||
|
|
||||||
|
|
||||||
def __str__(self): |
def __str__(self): |
||||||
return self.__repr__() |
return self.__repr__() |
||||||
|
|
||||||
|
|
||||||
def xy_str(self, fmt="{:.4f}, {:.4f}"): |
def xy_str(self, fmt="{:.4f}, {:.4f}"): |
||||||
"""Return a :obj:`str` for the (x,y) coordinate pair. |
"""Return a :obj:`str` for the (x,y) coordinate pair. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
fmt (:obj:`str`): The format string. Default is '{:.4f}, {:.4f}' |
fmt (:obj:`str`): The format string. Default is '{:.4f}, {:.4f}' |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
:obj:`str`: A string for the (x,y) coordinate pair |
:obj:`str`: A string for the (x,y) coordinate pair |
||||||
|
|
||||||
""" |
""" |
||||||
if self.x is None or self.y is None: |
if self.x is None or self.y is None: |
||||||
return None |
return None |
||||||
|
|
||||||
return fmt.format(self.x, self.y) |
return fmt.format(self.x, self.y) |
||||||
|
|
||||||
|
|
||||||
def latlon_str(self, fmt="{:.4f}, {:.4f}"): |
def latlon_str(self, fmt="{:.4f}, {:.4f}"): |
||||||
"""Return a :obj:`str` for the (latitude, longitude) coordinate pair. |
"""Return a :obj:`str` for the (latitude, longitude) coordinate pair. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
fmt (:obj:`str`): The format string. Default is '{:.4f}, {:.4f}' |
fmt (:obj:`str`): The format string. Default is '{:.4f}, {:.4f}' |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
:obj:`str`: A string for the (latitude, longitude) coordinate pair |
:obj:`str`: A string for the (latitude, longitude) coordinate pair |
||||||
|
|
||||||
""" |
""" |
||||||
if self.lat is None or self.lon is None: |
if self.lat is None or self.lon is None: |
||||||
return None |
return None |
||||||
|
|
||||||
return fmt.format(self.lat, self.lon) |
return fmt.format(self.lat, self.lon) |
||||||
|
|
||||||
|
|
||||||
def __round__(self, ndigits=None): |
def __round__(self, ndigits=None): |
||||||
"""Return a new :class:`CoordPair` object with all coordinate values |
"""Return a new :class:`CoordPair` object with all coordinate values |
||||||
rounded to the nearest integer. |
rounded to the nearest integer. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
ndigits (:obj:`int`): The number of digits. |
ndigits (:obj:`int`): The number of digits. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
|
|
||||||
:class:`CoordPair`: A CoordPair object. |
:class:`CoordPair`: A CoordPair object. |
||||||
|
|
||||||
""" |
""" |
||||||
args = [None if getattr(self, attr) is None |
args = [None if getattr(self, attr) is None |
||||||
else py2round(getattr(self, attr), ndigits) |
else py2round(getattr(self, attr), ndigits) |
||||||
for attr in ("x", "y", "lat", "lon")] |
for attr in ("x", "y", "lat", "lon")] |
||||||
|
|
||||||
return CoordPair(*args) |
return CoordPair(*args) |
||||||
|
|
||||||
|
|
||||||
def __pow__(self, other, modulo=None): |
def __pow__(self, other, modulo=None): |
||||||
if isinstance(other, CoordPair): |
if isinstance(other, CoordPair): |
||||||
args = [ |
args = [None if getattr(self, attr) is None or |
||||||
None if getattr(self, attr) is None or getattr(other, attr) is None |
getattr(other, attr) is None |
||||||
else getattr(getattr(self, attr), "__pow__")(getattr(other, attr), |
else getattr(getattr(self, attr), "__pow__")( |
||||||
modulo) |
getattr(other, attr), modulo) |
||||||
for attr in ("x", "y", "lat", "lon")] |
for attr in ("x", "y", "lat", "lon")] |
||||||
else: |
else: |
||||||
args = [ |
args = [None if getattr(self, attr) is None |
||||||
None if getattr(self, attr) is None |
else getattr(getattr(self, attr), "__pow__")(other, modulo) |
||||||
else getattr(getattr(self, attr), "__pow__")(other, modulo) |
for attr in ("x", "y", "lat", "lon")] |
||||||
for attr in ("x", "y", "lat", "lon")] |
|
||||||
|
|
||||||
return CoordPair(*args) |
return CoordPair(*args) |
||||||
|
|
||||||
|
|
||||||
def __rpow__(self, other): |
def __rpow__(self, other): |
||||||
return self.__pow__(other) |
return self.__pow__(other) |
||||||
|
|
||||||
|
|
||||||
for operator in ("__add__", "__divmod__", "__floordiv__", "__mod__", |
for operator in ("__add__", "__divmod__", "__floordiv__", "__mod__", |
||||||
"__mul__", "__sub__", "__truediv__", "__radd__", |
"__mul__", "__sub__", "__truediv__", "__radd__", |
||||||
"__rdivmod__", "__rsub__", "__rmul__", "__rtruediv__", |
"__rdivmod__", "__rsub__", "__rmul__", "__rtruediv__", |
||||||
"__rfloordiv__", "__rmod__"): |
"__rfloordiv__", "__rmod__"): |
||||||
setattr(CoordPair, operator, _binary_operator(operator)) |
setattr(CoordPair, operator, _binary_operator(operator)) |
||||||
|
|
||||||
|
|
||||||
for operator in ("__neg__", "__pos__", "__abs__", "__invert__"): |
for operator in ("__neg__", "__pos__", "__abs__", "__invert__"): |
||||||
setattr(CoordPair, operator, _unary_operator(operator)) |
setattr(CoordPair, operator, _unary_operator(operator)) |
||||||
|
|
||||||
|
|
||||||
for operator in ("__lt__", "__le__", "__eq__", "__ne__", "__gt__", "__ge__"): |
for operator in ("__lt__", "__le__", "__eq__", "__ne__", "__gt__", "__ge__"): |
||||||
setattr(CoordPair, operator, _cmp_operator(operator)) |
setattr(CoordPair, operator, _cmp_operator(operator)) |
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,164 +1,163 @@ |
|||||||
from __future__ import (absolute_import, division, print_function) |
from __future__ import (absolute_import, division, print_function) |
||||||
|
|
||||||
#from .extension import computetd |
|
||||||
from .extension import _td |
from .extension import _td |
||||||
from .decorators import convert_units |
from .decorators import convert_units |
||||||
from .metadecorators import copy_and_set_metadata |
from .metadecorators import copy_and_set_metadata |
||||||
from .util import extract_vars |
from .util import extract_vars |
||||||
|
|
||||||
|
|
||||||
@copy_and_set_metadata(copy_varname="QVAPOR", name="td", |
@copy_and_set_metadata(copy_varname="QVAPOR", name="td", |
||||||
description="dew point temperature") |
description="dew point temperature") |
||||||
@convert_units("temp", "c") |
@convert_units("temp", "c") |
||||||
def get_dp(wrfin, timeidx=0, method="cat", squeeze=True, |
def get_dp(wrfin, timeidx=0, method="cat", squeeze=True, |
||||||
cache=None, meta=True, _key=None, units="degC"): |
cache=None, meta=True, _key=None, units="degC"): |
||||||
"""Return the dewpoint temperature. |
"""Return the dewpoint temperature. |
||||||
|
|
||||||
This functions extracts the necessary variables from the NetCDF file |
This functions extracts the necessary variables from the NetCDF file |
||||||
object in order to perform the calculation. |
object in order to perform the calculation. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
||||||
iterable): WRF-ARW NetCDF |
iterable): WRF-ARW NetCDF |
||||||
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
||||||
or an iterable sequence of the aforementioned types. |
or an iterable sequence of the aforementioned types. |
||||||
|
|
||||||
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
||||||
desired time index. This value can be a positive integer, |
desired time index. This value can be a positive integer, |
||||||
negative integer, or |
negative integer, or |
||||||
:data:`wrf.ALL_TIMES` (an alias for None) to return |
:data:`wrf.ALL_TIMES` (an alias for None) to return |
||||||
all times in the file or sequence. The default is 0. |
all times in the file or sequence. The default is 0. |
||||||
|
|
||||||
method (:obj:`str`, optional): The aggregation method to use for |
method (:obj:`str`, optional): The aggregation method to use for |
||||||
sequences. Must be either 'cat' or 'join'. |
sequences. Must be either 'cat' or 'join'. |
||||||
'cat' combines the data along the Time dimension. |
'cat' combines the data along the Time dimension. |
||||||
'join' creates a new dimension for the file index. |
'join' creates a new dimension for the file index. |
||||||
The default is 'cat'. |
The default is 'cat'. |
||||||
|
|
||||||
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
||||||
with a size of 1 from being automatically removed from the shape |
with a size of 1 from being automatically removed from the shape |
||||||
of the output. Default is True. |
of the output. Default is True. |
||||||
|
|
||||||
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
||||||
that can be used to supply pre-extracted NetCDF variables to the |
that can be used to supply pre-extracted NetCDF variables to the |
||||||
computational routines. It is primarily used for internal |
computational routines. It is primarily used for internal |
||||||
purposes, but can also be used to improve performance by |
purposes, but can also be used to improve performance by |
||||||
eliminating the need to repeatedly extract the same variables |
eliminating the need to repeatedly extract the same variables |
||||||
used in multiple diagnostics calculations, particularly when using |
used in multiple diagnostics calculations, particularly when using |
||||||
large sequences of files. |
large sequences of files. |
||||||
Default is None. |
Default is None. |
||||||
|
|
||||||
meta (:obj:`bool`, optional): Set to False to disable metadata and |
meta (:obj:`bool`, optional): Set to False to disable metadata and |
||||||
return :class:`numpy.ndarray` instead of |
return :class:`numpy.ndarray` instead of |
||||||
:class:`xarray.DataArray`. Default is True. |
:class:`xarray.DataArray`. Default is True. |
||||||
|
|
||||||
_key (:obj:`int`, optional): A caching key. This is used for internal |
_key (:obj:`int`, optional): A caching key. This is used for internal |
||||||
purposes only. Default is None. |
purposes only. Default is None. |
||||||
|
|
||||||
units (:obj:`str`): The desired units. Refer to the :meth:`getvar` |
units (:obj:`str`): The desired units. Refer to the :meth:`getvar` |
||||||
product table for a list of available units for 'td'. Default |
product table for a list of available units for 'td'. Default |
||||||
is 'degC'. |
is 'degC'. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The |
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The |
||||||
dewpoint temperature. |
dewpoint temperature. |
||||||
If xarray is enabled and the *meta* parameter is True, then the result |
If xarray is enabled and the *meta* parameter is True, then the result |
||||||
will be a :class:`xarray.DataArray` object. Otherwise, the result will |
will be a :class:`xarray.DataArray` object. Otherwise, the result will |
||||||
be a :class:`numpy.ndarray` object with no metadata. |
be a :class:`numpy.ndarray` object with no metadata. |
||||||
|
|
||||||
""" |
""" |
||||||
|
|
||||||
varnames=("P", "PB", "QVAPOR") |
varnames = ("P", "PB", "QVAPOR") |
||||||
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
||||||
meta=False, _key=_key) |
meta=False, _key=_key) |
||||||
|
|
||||||
p = ncvars["P"] |
p = ncvars["P"] |
||||||
pb = ncvars["PB"] |
pb = ncvars["PB"] |
||||||
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
||||||
# break with every release |
# break with every release |
||||||
qvapor = ncvars["QVAPOR"].copy() |
qvapor = ncvars["QVAPOR"].copy() |
||||||
|
|
||||||
# Algorithm requires hPa |
# Algorithm requires hPa |
||||||
full_p = .01*(p + pb) |
full_p = .01*(p + pb) |
||||||
qvapor[qvapor < 0] = 0 |
qvapor[qvapor < 0] = 0 |
||||||
|
|
||||||
td = _td(full_p, qvapor) |
td = _td(full_p, qvapor) |
||||||
return td |
return td |
||||||
|
|
||||||
@copy_and_set_metadata(copy_varname="Q2", name="td2", |
|
||||||
|
@copy_and_set_metadata(copy_varname="Q2", name="td2", |
||||||
description="2m dew point temperature") |
description="2m dew point temperature") |
||||||
@convert_units("temp", "c") |
@convert_units("temp", "c") |
||||||
def get_dp_2m(wrfin, timeidx=0, method="cat", squeeze=True, |
def get_dp_2m(wrfin, timeidx=0, method="cat", squeeze=True, |
||||||
cache=None, meta=True, _key=None, units="degC"): |
cache=None, meta=True, _key=None, units="degC"): |
||||||
"""Return the 2m dewpoint temperature. |
"""Return the 2m dewpoint temperature. |
||||||
|
|
||||||
This functions extracts the necessary variables from the NetCDF file |
This functions extracts the necessary variables from the NetCDF file |
||||||
object in order to perform the calculation. |
object in order to perform the calculation. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
||||||
iterable): WRF-ARW NetCDF |
iterable): WRF-ARW NetCDF |
||||||
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
||||||
or an iterable sequence of the aforementioned types. |
or an iterable sequence of the aforementioned types. |
||||||
|
|
||||||
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
||||||
desired time index. This value can be a positive integer, |
desired time index. This value can be a positive integer, |
||||||
negative integer, or |
negative integer, or |
||||||
:data:`wrf.ALL_TIMES` (an alias for None) to return |
:data:`wrf.ALL_TIMES` (an alias for None) to return |
||||||
all times in the file or sequence. The default is 0. |
all times in the file or sequence. The default is 0. |
||||||
|
|
||||||
method (:obj:`str`, optional): The aggregation method to use for |
method (:obj:`str`, optional): The aggregation method to use for |
||||||
sequences. Must be either 'cat' or 'join'. |
sequences. Must be either 'cat' or 'join'. |
||||||
'cat' combines the data along the Time dimension. |
'cat' combines the data along the Time dimension. |
||||||
'join' creates a new dimension for the file index. |
'join' creates a new dimension for the file index. |
||||||
The default is 'cat'. |
The default is 'cat'. |
||||||
|
|
||||||
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
||||||
with a size of 1 from being automatically removed from the shape |
with a size of 1 from being automatically removed from the shape |
||||||
of the output. Default is True. |
of the output. Default is True. |
||||||
|
|
||||||
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
||||||
that can be used to supply pre-extracted NetCDF variables to the |
that can be used to supply pre-extracted NetCDF variables to the |
||||||
computational routines. It is primarily used for internal |
computational routines. It is primarily used for internal |
||||||
purposes, but can also be used to improve performance by |
purposes, but can also be used to improve performance by |
||||||
eliminating the need to repeatedly extract the same variables |
eliminating the need to repeatedly extract the same variables |
||||||
used in multiple diagnostics calculations, particularly when using |
used in multiple diagnostics calculations, particularly when using |
||||||
large sequences of files. |
large sequences of files. |
||||||
Default is None. |
Default is None. |
||||||
|
|
||||||
meta (:obj:`bool`, optional): Set to False to disable metadata and |
meta (:obj:`bool`, optional): Set to False to disable metadata and |
||||||
return :class:`numpy.ndarray` instead of |
return :class:`numpy.ndarray` instead of |
||||||
:class:`xarray.DataArray`. Default is True. |
:class:`xarray.DataArray`. Default is True. |
||||||
|
|
||||||
_key (:obj:`int`, optional): A caching key. This is used for internal |
_key (:obj:`int`, optional): A caching key. This is used for internal |
||||||
purposes only. Default is None. |
purposes only. Default is None. |
||||||
|
|
||||||
units (:obj:`str`): The desired units. Refer to the :meth:`getvar` |
units (:obj:`str`): The desired units. Refer to the :meth:`getvar` |
||||||
product table for a list of available units for 'td2'. Default |
product table for a list of available units for 'td2'. Default |
||||||
is 'degC'. |
is 'degC'. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The |
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The |
||||||
2m dewpoint temperature. |
2m dewpoint temperature. |
||||||
If xarray is enabled and the *meta* parameter is True, then the result |
If xarray is enabled and the *meta* parameter is True, then the result |
||||||
will be a :class:`xarray.DataArray` object. Otherwise, the result will |
will be a :class:`xarray.DataArray` object. Otherwise, the result will |
||||||
be a :class:`numpy.ndarray` object with no metadata. |
be a :class:`numpy.ndarray` object with no metadata. |
||||||
|
|
||||||
""" |
""" |
||||||
varnames=("PSFC", "Q2") |
varnames = ("PSFC", "Q2") |
||||||
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
||||||
meta=False, _key=_key) |
meta=False, _key=_key) |
||||||
|
|
||||||
# Algorithm requires hPa |
# Algorithm requires hPa |
||||||
psfc = .01*(ncvars["PSFC"]) |
psfc = .01*(ncvars["PSFC"]) |
||||||
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
||||||
# break with every release |
# break with every release |
||||||
q2 = ncvars["Q2"].copy() |
q2 = ncvars["Q2"].copy() |
||||||
q2[q2 < 0] = 0 |
q2[q2 < 0] = 0 |
||||||
|
|
||||||
td = _td(psfc, q2) |
td = _td(psfc, q2) |
||||||
|
|
||||||
return td |
|
||||||
|
|
||||||
|
return td |
||||||
|
@ -1,91 +1,86 @@ |
|||||||
from __future__ import (absolute_import, division, print_function) |
from __future__ import (absolute_import, division, print_function) |
||||||
|
|
||||||
#from .extension import computepw,computetv,computetk |
|
||||||
from .extension import _pw, _tv, _tk |
from .extension import _pw, _tv, _tk |
||||||
from .constants import Constants |
from .constants import Constants |
||||||
from .util import extract_vars |
from .util import extract_vars |
||||||
from .metadecorators import copy_and_set_metadata |
from .metadecorators import copy_and_set_metadata |
||||||
|
|
||||||
|
|
||||||
@copy_and_set_metadata(copy_varname="T", name="pw", |
@copy_and_set_metadata(copy_varname="T", name="pw", |
||||||
remove_dims=("bottom_top",), |
remove_dims=("bottom_top",), |
||||||
description="precipitable water", |
description="precipitable water", |
||||||
MemoryOrder="XY", |
MemoryOrder="XY", |
||||||
units="kg m-2") |
units="kg m-2") |
||||||
def get_pw(wrfin, timeidx=0, method="cat", squeeze=True, cache=None, |
def get_pw(wrfin, timeidx=0, method="cat", squeeze=True, cache=None, |
||||||
meta=True, _key=None): |
meta=True, _key=None): |
||||||
"""Return the preciptiable water. |
"""Return the preciptiable water. |
||||||
|
|
||||||
This functions extracts the necessary variables from the NetCDF file |
This functions extracts the necessary variables from the NetCDF file |
||||||
object in order to perform the calculation. |
object in order to perform the calculation. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
||||||
iterable): WRF-ARW NetCDF |
iterable): WRF-ARW NetCDF |
||||||
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
||||||
or an iterable sequence of the aforementioned types. |
or an iterable sequence of the aforementioned types. |
||||||
|
|
||||||
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
||||||
desired time index. This value can be a positive integer, |
desired time index. This value can be a positive integer, |
||||||
negative integer, or |
negative integer, or |
||||||
:data:`wrf.ALL_TIMES` (an alias for None) to return |
:data:`wrf.ALL_TIMES` (an alias for None) to return |
||||||
all times in the file or sequence. The default is 0. |
all times in the file or sequence. The default is 0. |
||||||
|
|
||||||
method (:obj:`str`, optional): The aggregation method to use for |
method (:obj:`str`, optional): The aggregation method to use for |
||||||
sequences. Must be either 'cat' or 'join'. |
sequences. Must be either 'cat' or 'join'. |
||||||
'cat' combines the data along the Time dimension. |
'cat' combines the data along the Time dimension. |
||||||
'join' creates a new dimension for the file index. |
'join' creates a new dimension for the file index. |
||||||
The default is 'cat'. |
The default is 'cat'. |
||||||
|
|
||||||
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
||||||
with a size of 1 from being automatically removed from the shape |
with a size of 1 from being automatically removed from the shape |
||||||
of the output. Default is True. |
of the output. Default is True. |
||||||
|
|
||||||
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
||||||
that can be used to supply pre-extracted NetCDF variables to the |
that can be used to supply pre-extracted NetCDF variables to the |
||||||
computational routines. It is primarily used for internal |
computational routines. It is primarily used for internal |
||||||
purposes, but can also be used to improve performance by |
purposes, but can also be used to improve performance by |
||||||
eliminating the need to repeatedly extract the same variables |
eliminating the need to repeatedly extract the same variables |
||||||
used in multiple diagnostics calculations, particularly when using |
used in multiple diagnostics calculations, particularly when using |
||||||
large sequences of files. |
large sequences of files. |
||||||
Default is None. |
Default is None. |
||||||
|
|
||||||
meta (:obj:`bool`, optional): Set to False to disable metadata and |
meta (:obj:`bool`, optional): Set to False to disable metadata and |
||||||
return :class:`numpy.ndarray` instead of |
return :class:`numpy.ndarray` instead of |
||||||
:class:`xarray.DataArray`. Default is True. |
:class:`xarray.DataArray`. Default is True. |
||||||
|
|
||||||
_key (:obj:`int`, optional): A caching key. This is used for internal |
_key (:obj:`int`, optional): A caching key. This is used for internal |
||||||
purposes only. Default is None. |
purposes only. Default is None. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The preciptable |
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The preciptable |
||||||
water. If xarray is |
water. If xarray is |
||||||
enabled and the *meta* parameter is True, then the result will be a |
enabled and the *meta* parameter is True, then the result will be a |
||||||
:class:`xarray.DataArray` object. Otherwise, the result will be a |
:class:`xarray.DataArray` object. Otherwise, the result will be a |
||||||
:class:`numpy.ndarray` object with no metadata. |
:class:`numpy.ndarray` object with no metadata. |
||||||
|
|
||||||
""" |
""" |
||||||
varnames=("T", "P", "PB", "PH", "PHB", "QVAPOR") |
varnames = ("T", "P", "PB", "PH", "PHB", "QVAPOR") |
||||||
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
||||||
meta=False, _key=_key) |
meta=False, _key=_key) |
||||||
|
|
||||||
t = ncvars["T"] |
t = ncvars["T"] |
||||||
p = ncvars["P"] |
p = ncvars["P"] |
||||||
pb = ncvars["PB"] |
pb = ncvars["PB"] |
||||||
ph = ncvars["PH"] |
ph = ncvars["PH"] |
||||||
phb = ncvars["PHB"] |
phb = ncvars["PHB"] |
||||||
qv = ncvars["QVAPOR"] |
qv = ncvars["QVAPOR"] |
||||||
|
|
||||||
full_p = p + pb |
full_p = p + pb |
||||||
ht = (ph + phb)/Constants.G |
ht = (ph + phb)/Constants.G |
||||||
full_t = t + Constants.T_BASE |
full_t = t + Constants.T_BASE |
||||||
|
|
||||||
tk = _tk(full_p, full_t) |
tk = _tk(full_p, full_t) |
||||||
tv = _tv(tk, qv) |
tv = _tv(tk, qv) |
||||||
|
|
||||||
return _pw(full_p, tv, qv, ht) |
return _pw(full_p, tv, qv, ht) |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,156 +1,154 @@ |
|||||||
from __future__ import (absolute_import, division, print_function) |
from __future__ import (absolute_import, division, print_function) |
||||||
|
|
||||||
from .constants import Constants |
from .constants import Constants |
||||||
#from .extension import computerh, computetk |
|
||||||
from .extension import _rh, _tk |
from .extension import _rh, _tk |
||||||
from .util import extract_vars |
from .util import extract_vars |
||||||
from .metadecorators import copy_and_set_metadata |
from .metadecorators import copy_and_set_metadata |
||||||
|
|
||||||
|
|
||||||
@copy_and_set_metadata(copy_varname="T", name="rh", |
@copy_and_set_metadata(copy_varname="T", name="rh", |
||||||
description="relative humidity", |
description="relative humidity", |
||||||
units="%") |
units="%") |
||||||
def get_rh(wrfin, timeidx=0, method="cat", squeeze=True, cache=None, |
def get_rh(wrfin, timeidx=0, method="cat", squeeze=True, cache=None, |
||||||
meta=True, _key=None): |
meta=True, _key=None): |
||||||
"""Return the relative humidity. |
"""Return the relative humidity. |
||||||
|
|
||||||
This functions extracts the necessary variables from the NetCDF file |
This functions extracts the necessary variables from the NetCDF file |
||||||
object in order to perform the calculation. |
object in order to perform the calculation. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
||||||
iterable): WRF-ARW NetCDF |
iterable): WRF-ARW NetCDF |
||||||
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
||||||
or an iterable sequence of the aforementioned types. |
or an iterable sequence of the aforementioned types. |
||||||
|
|
||||||
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
||||||
desired time index. This value can be a positive integer, |
desired time index. This value can be a positive integer, |
||||||
negative integer, or |
negative integer, or |
||||||
:data:`wrf.ALL_TIMES` (an alias for None) to return |
:data:`wrf.ALL_TIMES` (an alias for None) to return |
||||||
all times in the file or sequence. The default is 0. |
all times in the file or sequence. The default is 0. |
||||||
|
|
||||||
method (:obj:`str`, optional): The aggregation method to use for |
method (:obj:`str`, optional): The aggregation method to use for |
||||||
sequences. Must be either 'cat' or 'join'. |
sequences. Must be either 'cat' or 'join'. |
||||||
'cat' combines the data along the Time dimension. |
'cat' combines the data along the Time dimension. |
||||||
'join' creates a new dimension for the file index. |
'join' creates a new dimension for the file index. |
||||||
The default is 'cat'. |
The default is 'cat'. |
||||||
|
|
||||||
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
||||||
with a size of 1 from being automatically removed from the shape |
with a size of 1 from being automatically removed from the shape |
||||||
of the output. Default is True. |
of the output. Default is True. |
||||||
|
|
||||||
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
||||||
that can be used to supply pre-extracted NetCDF variables to the |
that can be used to supply pre-extracted NetCDF variables to the |
||||||
computational routines. It is primarily used for internal |
computational routines. It is primarily used for internal |
||||||
purposes, but can also be used to improve performance by |
purposes, but can also be used to improve performance by |
||||||
eliminating the need to repeatedly extract the same variables |
eliminating the need to repeatedly extract the same variables |
||||||
used in multiple diagnostics calculations, particularly when using |
used in multiple diagnostics calculations, particularly when using |
||||||
large sequences of files. |
large sequences of files. |
||||||
Default is None. |
Default is None. |
||||||
|
|
||||||
meta (:obj:`bool`, optional): Set to False to disable metadata and |
meta (:obj:`bool`, optional): Set to False to disable metadata and |
||||||
return :class:`numpy.ndarray` instead of |
return :class:`numpy.ndarray` instead of |
||||||
:class:`xarray.DataArray`. Default is True. |
:class:`xarray.DataArray`. Default is True. |
||||||
|
|
||||||
_key (:obj:`int`, optional): A caching key. This is used for internal |
_key (:obj:`int`, optional): A caching key. This is used for internal |
||||||
purposes only. Default is None. |
purposes only. Default is None. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The relative |
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The relative |
||||||
humidity. If xarray is |
humidity. If xarray is |
||||||
enabled and the *meta* parameter is True, then the result will be a |
enabled and the *meta* parameter is True, then the result will be a |
||||||
:class:`xarray.DataArray` object. Otherwise, the result will be a |
:class:`xarray.DataArray` object. Otherwise, the result will be a |
||||||
:class:`numpy.ndarray` object with no metadata. |
:class:`numpy.ndarray` object with no metadata. |
||||||
|
|
||||||
""" |
""" |
||||||
varnames=("T", "P", "PB", "QVAPOR") |
varnames = ("T", "P", "PB", "QVAPOR") |
||||||
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
||||||
meta=False, _key=_key) |
meta=False, _key=_key) |
||||||
t = ncvars["T"] |
t = ncvars["T"] |
||||||
p = ncvars["P"] |
p = ncvars["P"] |
||||||
pb = ncvars["PB"] |
pb = ncvars["PB"] |
||||||
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
||||||
# break with every release |
# break with every release |
||||||
qvapor = ncvars["QVAPOR"].copy() |
qvapor = ncvars["QVAPOR"].copy() |
||||||
|
|
||||||
full_t = t + Constants.T_BASE |
full_t = t + Constants.T_BASE |
||||||
full_p = p + pb |
full_p = p + pb |
||||||
qvapor[qvapor < 0] = 0 |
qvapor[qvapor < 0] = 0 |
||||||
tk = _tk(full_p, full_t) |
tk = _tk(full_p, full_t) |
||||||
rh = _rh(qvapor, full_p, tk) |
rh = _rh(qvapor, full_p, tk) |
||||||
|
|
||||||
return rh |
return rh |
||||||
|
|
||||||
|
|
||||||
@copy_and_set_metadata(copy_varname="T2", name="rh2", |
@copy_and_set_metadata(copy_varname="T2", name="rh2", |
||||||
description="2m relative humidity", |
description="2m relative humidity", |
||||||
units="%") |
units="%") |
||||||
def get_rh_2m(wrfin, timeidx=0, method="cat", squeeze=True, cache=None, |
def get_rh_2m(wrfin, timeidx=0, method="cat", squeeze=True, cache=None, |
||||||
meta=True, _key=None): |
meta=True, _key=None): |
||||||
"""Return the 2m relative humidity. |
"""Return the 2m relative humidity. |
||||||
|
|
||||||
This functions extracts the necessary variables from the NetCDF file |
This functions extracts the necessary variables from the NetCDF file |
||||||
object in order to perform the calculation. |
object in order to perform the calculation. |
||||||
|
|
||||||
Args: |
Args: |
||||||
|
|
||||||
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
||||||
iterable): WRF-ARW NetCDF |
iterable): WRF-ARW NetCDF |
||||||
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
||||||
or an iterable sequence of the aforementioned types. |
or an iterable sequence of the aforementioned types. |
||||||
|
|
||||||
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The |
||||||
desired time index. This value can be a positive integer, |
desired time index. This value can be a positive integer, |
||||||
negative integer, or |
negative integer, or |
||||||
:data:`wrf.ALL_TIMES` (an alias for None) to return |
:data:`wrf.ALL_TIMES` (an alias for None) to return |
||||||
all times in the file or sequence. The default is 0. |
all times in the file or sequence. The default is 0. |
||||||
|
|
||||||
method (:obj:`str`, optional): The aggregation method to use for |
method (:obj:`str`, optional): The aggregation method to use for |
||||||
sequences. Must be either 'cat' or 'join'. |
sequences. Must be either 'cat' or 'join'. |
||||||
'cat' combines the data along the Time dimension. |
'cat' combines the data along the Time dimension. |
||||||
'join' creates a new dimension for the file index. |
'join' creates a new dimension for the file index. |
||||||
The default is 'cat'. |
The default is 'cat'. |
||||||
|
|
||||||
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
||||||
with a size of 1 from being automatically removed from the shape |
with a size of 1 from being automatically removed from the shape |
||||||
of the output. Default is True. |
of the output. Default is True. |
||||||
|
|
||||||
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
||||||
that can be used to supply pre-extracted NetCDF variables to the |
that can be used to supply pre-extracted NetCDF variables to the |
||||||
computational routines. It is primarily used for internal |
computational routines. It is primarily used for internal |
||||||
purposes, but can also be used to improve performance by |
purposes, but can also be used to improve performance by |
||||||
eliminating the need to repeatedly extract the same variables |
eliminating the need to repeatedly extract the same variables |
||||||
used in multiple diagnostics calculations, particularly when using |
used in multiple diagnostics calculations, particularly when using |
||||||
large sequences of files. |
large sequences of files. |
||||||
Default is None. |
Default is None. |
||||||
|
|
||||||
meta (:obj:`bool`, optional): Set to False to disable metadata and |
meta (:obj:`bool`, optional): Set to False to disable metadata and |
||||||
return :class:`numpy.ndarray` instead of |
return :class:`numpy.ndarray` instead of |
||||||
:class:`xarray.DataArray`. Default is True. |
:class:`xarray.DataArray`. Default is True. |
||||||
|
|
||||||
_key (:obj:`int`, optional): A caching key. This is used for internal |
_key (:obj:`int`, optional): A caching key. This is used for internal |
||||||
purposes only. Default is None. |
purposes only. Default is None. |
||||||
|
|
||||||
Returns: |
Returns: |
||||||
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The 2m relative |
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The 2m relative |
||||||
humidity. If xarray is |
humidity. If xarray is |
||||||
enabled and the *meta* parameter is True, then the result will be a |
enabled and the *meta* parameter is True, then the result will be a |
||||||
:class:`xarray.DataArray` object. Otherwise, the result will be a |
:class:`xarray.DataArray` object. Otherwise, the result will be a |
||||||
:class:`numpy.ndarray` object with no metadata. |
:class:`numpy.ndarray` object with no metadata. |
||||||
|
|
||||||
""" |
""" |
||||||
varnames=("T2", "PSFC", "Q2") |
varnames = ("T2", "PSFC", "Q2") |
||||||
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
ncvars = extract_vars(wrfin, timeidx, varnames, method, squeeze, cache, |
||||||
meta=False, _key=_key) |
meta=False, _key=_key) |
||||||
t2 = ncvars["T2"] |
t2 = ncvars["T2"] |
||||||
psfc = ncvars["PSFC"] |
psfc = ncvars["PSFC"] |
||||||
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
# Copy needed for the mmap nonsense of scipy.io.netcdf, which seems to |
||||||
# break with every release |
# break with every release |
||||||
q2 = ncvars["Q2"].copy() |
q2 = ncvars["Q2"].copy() |
||||||
|
|
||||||
q2[q2 < 0] = 0 |
q2[q2 < 0] = 0 |
||||||
rh = _rh(q2, psfc, t2) |
rh = _rh(q2, psfc, t2) |
||||||
|
|
||||||
return rh |
|
||||||
|
|
||||||
|
return rh |
||||||
|
Loading…
Reference in new issue