Browse Source

Fix documentation typos. Updated API outlines. Fixed an issue with a computation routine name conflict.

main
Bill Ladwig 9 years ago
parent
commit
eec730c8ab
  1. 3
      .gitignore
  2. 3
      doc/source/conf.py
  3. 124
      doc/source/internal_api/index.rst
  4. 161
      doc/source/user_api/index.rst
  5. 37
      src/wrf/api.py
  6. 75
      src/wrf/computation.py
  7. 18
      src/wrf/extension.py
  8. 2
      src/wrf/interp.py
  9. 8
      src/wrf/projection.py
  10. 13
      src/wrf/util.py

3
.gitignore vendored

@ -43,6 +43,7 @@ Thumbs.db
*.project *.project
*.pydevproject *.pydevproject
doc/build doc/build
doc/source/api/generated doc/source/internal_api/generated
doc/source/user_api/generated
test/ipynb/.ipynb_checkpoints test/ipynb/.ipynb_checkpoints

3
doc/source/conf.py

@ -67,6 +67,9 @@ extensions = [
intersphinx_mapping = { intersphinx_mapping = {
'matplotlib': ('http://matplotlib.org/', None), 'matplotlib': ('http://matplotlib.org/', None),
'basemap' : ('http://matplotlib.org/basemap/', None),
'cartopy' : (
'http://scitools.org.uk/cartopy/docs/latest/index.html', None),
'python': ('http://docs.python.org/3/', None), 'python': ('http://docs.python.org/3/', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None), 'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'xarray': ('http://xarray.pydata.org/en/stable/', None), 'xarray': ('http://xarray.pydata.org/en/stable/', None),

124
doc/source/internal_api/index.rst

@ -1,8 +1,69 @@
Internal API Internal API
============= =============
-------------
Routines
-------------
Extraction and Diagnostic Routines
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The routines below are called internally by :meth:`wrf.getvar`.
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.cape.get_2dcape
wrf.cape.get_3dcape
wrf.cloudfrac.get_cloudfrac
wrf.ctt.get_ctt
wrf.dbz.get_dbz
wrf.dbz.get_max_dbz
wrf.dewpoint.get_dp
wrf.dewpoint.get_dp_2m
wrf.geoht.get_geopt
wrf.geoht.get_height
wrf.helicity.get_srh
wrf.helicity.get_uh
wrf.omega.get_omega
wrf.pressure.get_pressure
wrf.pressure.get_pressure_hpa
wrf.pw.get_pw
wrf.rh.get_rh
wrf.rh.get_rh_2m
wrf.slp.get_slp
wrf.temp.get_theta
wrf.temp.get_temp
wrf.temp.get_eth
wrf.temp.get_tv
wrf.temp.get_tw
wrf.temp.get_tk
wrf.temp.get_tc
wrf.terrain.get_terrain
wrf.times.get_times
wrf.times.get_xtimes
wrf.uvmet.get_uvmet
wrf.uvmet.get_uvmet10
wrf.uvmet.get_uvmet_wspd_wdir
wrf.uvmet.get_uvmet10_wspd_wdir
wrf.vorticity.get_avo
wrf.vorticity.get_pvo
wrf.wind.get_u_destag
wrf.wind.get_v_destag
wrf.wind.get_w_destag
wrf.wind.get_destag_wspd_wdir
wrf.wind.get_destag_wspd_wdir10
-------------------------
Decorators
----------------
Algorithm Decorators Algorithm Decorators
-------------------- ^^^^^^^^^^^^^^^^^^^^^^^^
The decorators below are used for performing common operations related to The decorators below are used for performing common operations related to
diagnostic and interpolation calculations. diagnostic and interpolation calculations.
@ -11,18 +72,18 @@ diagnostic and interpolation calculations.
:nosignatures: :nosignatures:
:toctree: ./generated/ :toctree: ./generated/
wrf.convert_units wrf.decorators.convert_units
wrf.left_iteration wrf.decorators.left_iteration
wrf.cast_type wrf.decorators.cast_type
wrf.extract_and_transpose wrf.decorators.extract_and_transpose
wrf.check_args wrf.decorators.check_args
wrf.uvmet_left_iter wrf.specialdec.uvmet_left_iter
wrf.cape_left_iter wrf.specialdec.cape_left_iter
wrf.cloudfrac_left_iter wrf.specialdec.cloudfrac_left_iter
Metadata Decorators Metadata Decorators
-------------------- ^^^^^^^^^^^^^^^^^^^^^^
The decorators below are used for performing common operations related to The decorators below are used for performing common operations related to
setting metadata. setting metadata.
@ -31,24 +92,24 @@ setting metadata.
:nosignatures: :nosignatures:
:toctree: ./generated/ :toctree: ./generated/
wrf.copy_and_set_metadata wrf.metadecorators.copy_and_set_metadata
wrf.set_wind_metadata wrf.metadecorators.set_wind_metadata
wrf.set_cape_metadata wrf.metadecorators.set_cape_metadata
wrf.set_cloudfrac_metadata wrf.metadecorators.set_cloudfrac_metadata
wrf.set_latlon_metadata wrf.metadecorators.set_latlon_metadata
wrf.set_height_metadata wrf.metadecorators.set_height_metadata
wrf.set_interp_metadata wrf.metadecorators.set_interp_metadata
wrf.set_alg_metadata wrf.metadecorators.set_alg_metadata
wrf.set_uvmet_alg_metadata wrf.metadecorators.set_uvmet_alg_metadata
wrf.set_cape_alg_metadata wrf.metadecorators.set_cape_alg_metadata
wrf.set_cloudfrac_alg_metadata wrf.metadecorators.set_cloudfrac_alg_metadata
wrf.set_destag_metadata wrf.metadecorators.set_destag_metadata
Decorator Utilities Decorator Utilities
-------------------- ^^^^^^^^^^^^^^^^^^^^^^^
The routines below are used within decorators. The routines below are used within the decorators.
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
@ -60,10 +121,19 @@ The routines below are used within decorators.
wrf.from_args wrf.from_args
wrf.args_to_list wrf.args_to_list
wrf.arg_location wrf.arg_location
Miscellaneous Classes
----------------------
------------------------
Classes
-----------------------
Iterable Wrapper Class
^^^^^^^^^^^^^^^^^^^^^^^
The class below is an Iterable wrapper class and provides an __iter__ function
that always returns the beginning of the sequence, regardless of the
Iterable type.
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:

161
doc/source/user_api/index.rst

@ -1,8 +1,13 @@
User API User API
============= =============
-----------------
Routines
------------------
Diagnostic Routine Diagnostic Routine
------------------- ^^^^^^^^^^^^^^^^^^^^^^^
The routine below is the primary routine for extracting variables from a The routine below is the primary routine for extracting variables from a
WRF-ARW NetCDF file (or sequence of files) and performing diagnostic WRF-ARW NetCDF file (or sequence of files) and performing diagnostic
@ -16,7 +21,7 @@ calculations.
Interpolation Routines Interpolation Routines
---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^
The routines below are the primary routines used for performing interpolation The routines below are the primary routines used for performing interpolation
calculations. calculations.
@ -29,15 +34,29 @@ calculations.
wrf.vertcross wrf.vertcross
wrf.interpline wrf.interpline
wrf.vinterp wrf.vinterp
Lat-Lon to/from XY Routines
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The routines below are used for converting back and forth between xy-grid
space and latitude-longitude space.
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.ll_to_xy
wrf.xy_to_ll
wrf.ll_to_xy_proj
wrf.xy_to_ll_proj
Numpy Extraction Routine Numpy Extraction Routine
-------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The routine below is used to extract a :class:`numpy.ndarray` from a The routine below is used to extract a :class:`numpy.ndarray` from a
:class:`xarray.DataArray`. This routine must be used before passing :class:`xarray.DataArray`. This routine must be used before passing
the array object to a compiled extension. Otherwise, unusually crashes the array object to a compiled extension.
may occur.
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
@ -47,7 +66,7 @@ may occur.
Variable Extraction Routines Variable Extraction Routines
----------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The routines below are primarily used internally by :meth:`wrf.getvar`, but The routines below are primarily used internally by :meth:`wrf.getvar`, but
some users may find them useful to manually extract variables from a some users may find them useful to manually extract variables from a
@ -60,13 +79,12 @@ WRF NetCDF file (or a sequence of NetCDF files).
wrf.extract_vars wrf.extract_vars
wrf.combine_files wrf.combine_files
wrf.extract_dim wrf.extract_dim
wrf.extract_extract_global_attrs wrf.extract_global_attrs
wrf.extract_times wrf.extract_times
Raw Diagnostic Routines Raw Diagnostic Routines
------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^
The routines below can be used when working with variables that are not The routines below can be used when working with variables that are not
contained in a WRF-ARW NetCDF file. They can also be used with non-WRF data. contained in a WRF-ARW NetCDF file. They can also be used with non-WRF data.
@ -78,7 +96,6 @@ may vary when working with non-WRF data. Also, the vast majority of these
routines do not allow for missing values in any of the input arrays, so make routines do not allow for missing values in any of the input arrays, so make
sure they are removed before calling these routines. sure they are removed before calling these routines.
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
@ -89,7 +106,6 @@ sure they are removed before calling these routines.
wrf.interp2dxy wrf.interp2dxy
wrf.interpz3d wrf.interpz3d
wrf.slp wrf.slp
wrf.temp
wrf.tk wrf.tk
wrf.td wrf.td
wrf.rh wrf.rh
@ -111,23 +127,40 @@ sure they are removed before calling these routines.
wrf.pw wrf.pw
CoordPair Class Configuration Routines
---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^
The class below is used for coordinate metadata. The routines below are used to configure wrf-python by enabling or
disabling third party packages. For the most part, these settings are
configured automatically based on the presence of a third party package.
However, disabling xarray can be useful when you want to turn off all metadata
in one place.
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
:toctree: ./generated/ :toctree: ./generated/
wrf.CoordPair wrf.xarray_enabled
wrf.disable_xarray
wrf.enable_xarray
wrf.cartopy_enabled
wrf.disable_cartopy
wrf.enable_cartopy
wrf.basemap_enabled
wrf.disable_basemap
wrf.enable_basemap
wrf.pyngl_enabled
wrf.enable_pyngl
wrf.disable_pyngl
wrf.set_cache_size
wrf.get_cache_size
Miscellaneous Routines Miscellaneous Routines
----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^
The routines below are primarily used internally, but some users may find The routines below are primarily used internally, but some users may find
them helpful. them helpful for other purposes.
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
@ -152,6 +185,100 @@ them helpful.
wrf.get_proj_params wrf.get_proj_params
wrf.psafilepath wrf.psafilepath
wrf.get_id wrf.get_id
wrf.getproj
wrf.cache_item
wrf.get_cached_item
------------------------
Classes
----------------------
Exceptions
^^^^^^^^^^^^^^
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.DiagnosticError
CoordPair Class
^^^^^^^^^^^^^^^^^^^^^^^
The class below is used for storing coordinate metadata from routines that
use a single point for an (x, y) or (lat, lon) location.
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.CoordPair
CoordPair Methods
~~~~~~~~~~~~~~~~~~~~~~~
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.CoordPair.latlon_str
wrf.CoordPair.xy_str
Projection Classes
^^^^^^^^^^^^^^^^^^^^^^^^
The classes below are used to hold the projection information in the
'projection' entry within a :attr:`xarray.DataArray.attrs` attribute.
Projection Base Class
~~~~~~~~~~~~~~~~~~~~~~~~
The base class for all map projection types.
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.WrfProj
Projection Base Class Methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The class methods for all projection types.
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.WrfProj.basemap
wrf.WrfProj.cartopy
wrf.WrfProj.cartopy_xlim
wrf.WrfProj.cartopy_ylim
wrf.WrfProj.pyngl
wrf.WrfProj.cf
wrf.WrfProj.proj4
Projection Subclasses
~~~~~~~~~~~~~~~~~~~~~~~~
See :class:`wrf.WrfProj` for methods and attributes.
.. autosummary::
:nosignatures:
:toctree: ./generated/
wrf.NullProjection
wrf.LambertConformal
wrf.Mercator
wrf.PolarStereographic
wrf.LatLon
wrf.RotatedLatLon

37
src/wrf/api.py

@ -1,7 +1,8 @@
from .config import (xarray_enabled, disable_xarray, enable_xarray, from .config import (xarray_enabled, disable_xarray, enable_xarray,
cartopy_enabled, enable_cartopy, enable_cartopy, cartopy_enabled, disable_cartopy, enable_cartopy,
basemap_enabled, disable_basemap, enable_basemap, basemap_enabled, disable_basemap, enable_basemap,
pyngl_enabled, enable_pyngl, disable_pyngl) pyngl_enabled, enable_pyngl, disable_pyngl,
set_cache_size, get_cache_size)
from .constants import ALL_TIMES, Constants, ConversionFactors, ProjectionTypes from .constants import ALL_TIMES, Constants, ConversionFactors, ProjectionTypes
from .destag import destagger from .destag import destagger
from .routines import getvar from .routines import getvar
@ -9,6 +10,7 @@ from .computation import (xy, interp1d, interp2dxy, interpz3d, slp, tk, td, rh,
uvmet, smooth2d, cape_2d, cape_3d, cloudfrac, ctt, uvmet, smooth2d, cape_2d, cape_3d, cloudfrac, ctt,
dbz, srhel, udhel, avo, pvo, eth, wetbulb, tvirtual, dbz, srhel, udhel, avo, pvo, eth, wetbulb, tvirtual,
omega, pw) omega, pw)
from .extension import DiagnosticError
from .interp import (interplevel, vertcross, interpline, vinterp) from .interp import (interplevel, vertcross, interpline, vinterp)
from .latlon import (xy_to_ll, ll_to_xy, xy_to_ll_proj, ll_to_xy_proj) from .latlon import (xy_to_ll, ll_to_xy, xy_to_ll_proj, ll_to_xy_proj)
from .py3compat import (viewitems, viewkeys, viewvalues, isstr, py2round, from .py3compat import (viewitems, viewkeys, viewvalues, isstr, py2round,
@ -23,23 +25,19 @@ from .util import (npvalues, extract_global_attrs, is_standard_wrf_var,
IterWrapper, is_coordvar, latlon_coordvars, is_mapping, IterWrapper, is_coordvar, latlon_coordvars, is_mapping,
has_time_coord, is_multi_file, is_multi_time_req, has_time_coord, is_multi_file, is_multi_time_req,
get_coord_pairs, is_time_coord_var) get_coord_pairs, is_time_coord_var)
from .projection import (WrfProj, NullProjection, LambertConformal, Mercator,
PolarStereographic, LatLon, RotatedLatLon,
getproj)
from .coordpair import CoordPair from .coordpair import CoordPair
from decorators import (convert_units, left_iteration, cast_type, from cache import cache_item, get_cached_item
extract_and_transpose, check_args)
from specialdec import (uvmet_left_iter, cape_left_iter, cloudfrac_left_iter)
from metadecorators import (copy_and_set_metadata, set_wind_metadata,
set_cloudfrac_metadata, set_latlon_metadata,
set_height_metadata, set_interp_metadata,
set_alg_metadata, set_uvmet_alg_metadata,
set_cape_alg_metadata, set_cloudfrac_alg_metadata,
set_destag_metadata)
from .version import __version__ from .version import __version__
__all__ = [] __all__ = []
__all__ += ["xarray_enabled", "disable_xarray", "enable_xarray", __all__ += ["xarray_enabled", "disable_xarray", "enable_xarray",
"cartopy_enabled", "enable_cartopy", "enable_cartopy", "cartopy_enabled", "disable_cartopy", "enable_cartopy",
"basemap_enabled", "disable_basemap", "enable_basemap", "basemap_enabled", "disable_basemap", "enable_basemap",
"pyngl_enabled", "enable_pyngl", "disable_pyngl"] "pyngl_enabled", "enable_pyngl", "disable_pyngl",
"set_cache_size", "get_cache_size"]
__all__ += ["ALL_TIMES", "Constants", "ConversionFactors", "ProjectionTypes"] __all__ += ["ALL_TIMES", "Constants", "ConversionFactors", "ProjectionTypes"]
__all__ += ["destagger"] __all__ += ["destagger"]
__all__ += ["getvar"] __all__ += ["getvar"]
@ -47,6 +45,7 @@ __all__ += ["xy", "interp1d", "interp2dxy", "interpz3d", "slp", "tk", "td",
"rh", "uvmet", "smooth2d", "cape_2d", "cape_3d", "cloudfrac", "rh", "uvmet", "smooth2d", "cape_2d", "cape_3d", "cloudfrac",
"ctt", "dbz", "srhel", "udhel", "avo", "pvo", "eth", "wetbulb", "ctt", "dbz", "srhel", "udhel", "avo", "pvo", "eth", "wetbulb",
"tvirtual", "omega", "pw"] "tvirtual", "omega", "pw"]
__all__ += ["DiagnosticError"]
__all__ += ["interplevel", "vertcross", "interpline", "vinterp"] __all__ += ["interplevel", "vertcross", "interpline", "vinterp"]
__all__ += ["xy_to_ll", "ll_to_xy", "xy_to_ll_proj", "ll_to_xy_proj"] __all__ += ["xy_to_ll", "ll_to_xy", "xy_to_ll_proj", "ll_to_xy_proj"]
__all__ += ["viewitems", "viewkeys", "viewvalues", "isstr", "py2round", __all__ += ["viewitems", "viewkeys", "viewvalues", "isstr", "py2round",
@ -61,15 +60,9 @@ __all__ += ["npvalues", "extract_global_attrs", "is_standard_wrf_var",
"IterWrapper", "is_coordvar", "latlon_coordvars", "is_mapping", "IterWrapper", "is_coordvar", "latlon_coordvars", "is_mapping",
"has_time_coord", "is_multi_file", "is_multi_time_req", "has_time_coord", "is_multi_file", "is_multi_time_req",
"get_coord_pairs", "is_time_coord_var"] "get_coord_pairs", "is_time_coord_var"]
__all__ += ["convert_units", "left_iteration", "cast_type", __all__ += ["WrfProj", "NullProjection", "LambertConformal", "Mercator",
"extract_and_transpose", "check_args"] "PolarStereographic", "LatLon", "RotatedLatLon", "getproj"]
__all__ += ["uvmet_left_iter", "cape_left_iter", "cloudfrac_left_iter"]
__all__ += ["copy_and_set_metadata", "set_wind_metadata",
"set_cloudfrac_metadata", "set_latlon_metadata",
"set_height_metadata", "set_interp_metadata",
"set_alg_metadata", "set_uvmet_alg_metadata",
"set_cape_alg_metadata", "set_cloudfrac_alg_metadata",
"set_destag_metadata"]
__all__ += ["CoordPair"] __all__ += ["CoordPair"]
__all__ += ["cache_item", "get_cached_item"]
__all__ += ["__version__"] __all__ += ["__version__"]

75
src/wrf/computation.py

@ -334,7 +334,7 @@ def slp(height, tkel, pres, qv, meta=True, units="hPa"):
Geopotential height in [m] with the rightmost dimensions being Geopotential height in [m] with the rightmost dimensions being
bottom_top x south_north x west_east. bottom_top x south_north x west_east.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *height*. in [K] with same dimensionality as *height*.
pres (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Full pres (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Full
@ -382,8 +382,8 @@ def slp(height, tkel, pres, qv, meta=True, units="hPa"):
@set_alg_metadata(3, "pres", description="temperature") @set_alg_metadata(3, "pres", description="temperature")
@convert_units("temp", "k") @convert_units("temp", "k")
def temp(pres, theta, meta=True, units="K"): def tk(pres, theta, meta=True, units="K"):
"""Return the temperature in the specified units. """Return the temperature.
This is the raw computational algorithm and does not extract any variables This is the raw computational algorithm and does not extract any variables
from WRF output files. Use :meth:`wrf.getvar` to both extract and compute from WRF output files. Use :meth:`wrf.getvar` to both extract and compute
@ -437,59 +437,6 @@ def temp(pres, theta, meta=True, units="K"):
return _tk(pres, theta) return _tk(pres, theta)
def tk(pres, theta, meta=True):
"""Return the temperature in Kelvin.
This is an alias for *wrf.temp(pres, theta, meta, units='K')*. This
function is here for users that are familiar with NCL's wrf_tk.
This is the raw computational algorithm and does not extract any variables
from WRF output files. Use :meth:`wrf.getvar` to both extract and compute
diagnostic variables.
Args:
pres (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Full
pressure (perturbation + base state pressure) in [Pa] with at least
three dimensions. The rightmost dimensions are bottom_top x
south_north x west_east.
Note:
This variable must be
supplied as a :class:`xarray.DataArray` in order to copy the
dimension names to the output. Otherwise, default names will
be used.
theta (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Potential
temperature (perturbation plus reference temperature) in [K] with
the same dimensionality as *pres*.
meta (:obj:`bool`): Set to False to disable metadata and return
:class:`numpy.ndarray` instead of
:class:`xarray.DataArray`. Default is True.
Warning:
The input arrays must not contain any missing/fill values or
:data:`numpy.nan` values.
Returns:
:class:`xarray.DataArray` or :class:`numpy.ndarray`: The
temperature in Kelvin. If xarray is enabled and
the *meta* parameter is True, then the result will be an
:class:`xarray.DataArray` object. Otherwise, the result will
be a :class:`numpy.ndarray` object with no metadata.
See Also:
:meth:`wrf.getvar`, :meth:`wrf.temp`
"""
return temp(pres, theta, meta, units="K")
@set_alg_metadata(3, "pres", description="dew point temperature") @set_alg_metadata(3, "pres", description="dew point temperature")
@convert_units("temp", "c") @convert_units("temp", "c")
def td(pres, qv, meta=True, units="degC"): def td(pres, qv, meta=True, units="degC"):
@ -570,7 +517,7 @@ def rh(qv, pres, tkel, meta=True):
dimension names to the output. Otherwise, default names will dimension names to the output. Otherwise, default names will
be used. be used.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *qv*. in [K] with same dimensionality as *qv*.
Note: Note:
@ -816,7 +763,7 @@ def cape_2d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow,
dimension names to the output. Otherwise, default names will dimension names to the output. Otherwise, default names will
be used. be used.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *pres_hpa*. in [K] with same dimensionality as *pres_hpa*.
qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor
@ -938,7 +885,7 @@ def cape_3d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow,
dimension names to the output. Otherwise, default names will dimension names to the output. Otherwise, default names will
be used. be used.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *pres_hpa*. in [K] with same dimensionality as *pres_hpa*.
qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor
@ -1088,7 +1035,7 @@ def ctt(pres_hpa, tkel, qv, qcld, height, terrain, qice=None, meta=True,
dimension names to the output. Otherwise, default names will dimension names to the output. Otherwise, default names will
be used. be used.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *pres_hpa*. in [K] with same dimensionality as *pres_hpa*.
qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor
@ -1177,7 +1124,7 @@ def dbz(pres, tkel, qv, qr, qs=None, qg=None, use_varint=False,
dimension names to the output. Otherwise, default names will dimension names to the output. Otherwise, default names will
be used. be used.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *pres*. in [K] with same dimensionality as *pres*.
qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor
@ -1614,7 +1561,7 @@ def eth(qv, tkel, pres, meta=True, units="K"):
mixing ratio in [kg/kg] that is at least three dimensions, with mixing ratio in [kg/kg] that is at least three dimensions, with
the rightmost dimensions of bottom_top x south_north x west_east. the rightmost dimensions of bottom_top x south_north x west_east.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *qv*. in [K] with same dimensionality as *qv*.
Note: Note:
@ -1682,7 +1629,7 @@ def wetbulb(pres, tkel, qv, meta=True, units="K"):
dimension names to the output. Otherwise, default names will dimension names to the output. Otherwise, default names will
be used. be used.
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with same dimensionality as *pres*. in [K] with same dimensionality as *pres*.
qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor qv (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Water vapor
@ -1731,7 +1678,7 @@ def tvirtual(tkel, qv, meta=True, units="K"):
Args: Args:
tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`) Temperature tkel (:class:`xarray.DataArray` or :class:`numpy.ndarray`): Temperature
in [K] with the rightmost dimensions as bottom_top x south_north in [K] with the rightmost dimensions as bottom_top x south_north
x west_east. x west_east.

18
src/wrf/extension.py

@ -20,10 +20,10 @@ from .py3compat import py3range
from .specialdec import (uvmet_left_iter, cape_left_iter, from .specialdec import (uvmet_left_iter, cape_left_iter,
cloudfrac_left_iter) cloudfrac_left_iter)
class FortranError(Exception): class DiagnosticError(Exception):
"""Raised when an error occurs in a Fortran routine.""" """Raised when an error occurs in a diagnostic routine."""
def __init__(self, message=None): def __init__(self, message=None):
"""Initialize a :class:`wrf.FortranError` objection. """Initialize a :class:`wrf.DiagnosticError` objection.
Args: Args:
@ -206,7 +206,7 @@ def _slp(z, t, p, q, outview=None):
errmsg=errmsg) errmsg=errmsg)
if int(errstat) != 0: if int(errstat) != 0:
raise FortranError("".join(npbytes_to_str(errmsg)).strip()) raise DiagnosticError("".join(npbytes_to_str(errmsg)).strip())
return result return result
@ -465,7 +465,7 @@ def _wetbulb(p, tk, qv, psafile=psafilepath(), outview=None):
errmsg) errmsg)
if int(errstat) != 0: if int(errstat) != 0:
raise FortranError("".join(npbytes_to_str(errmsg)).strip()) raise DiagnosticError("".join(npbytes_to_str(errmsg)).strip())
return result return result
@ -613,7 +613,7 @@ def _cape(p_hpa, tk, qv, ht, ter, sfp, missing, i3dflag, ter_follow,
errmsg) errmsg)
if int(errstat) != 0: if int(errstat) != 0:
raise FortranError("".join(npbytes_to_str(errmsg)).strip()) raise DiagnosticError("".join(npbytes_to_str(errmsg)).strip())
return result return result
@ -681,7 +681,7 @@ def _lltoxy(map_proj, truelat1, truelat2, stdlon,
errmsg) errmsg)
if int(errstat) != 0: if int(errstat) != 0:
raise FortranError("".join(npbytes_to_str(errmsg)).strip()) raise DiagnosticError("".join(npbytes_to_str(errmsg)).strip())
return result return result
@ -721,7 +721,7 @@ def _xytoll(map_proj, truelat1, truelat2, stdlon, lat1, lon1,
errmsg) errmsg)
if int(errstat) != 0: if int(errstat) != 0:
raise FortranError("".join(npbytes_to_str(errmsg)).strip()) raise DiagnosticError("".join(npbytes_to_str(errmsg)).strip())
return result return result
@ -855,7 +855,7 @@ def _vintrp(field, pres, tk, qvp, ght, terrain, sfp, smsfp,
errmsg) errmsg)
if int(errstat) != 0: if int(errstat) != 0:
raise FortranError("".join(npbytes_to_str(errmsg)).strip()) raise DiagnosticError("".join(npbytes_to_str(errmsg)).strip())
return result return result

2
src/wrf/interp.py

@ -104,7 +104,7 @@ def vertcross(field3d, vert, levels=None, missing=Constants.DEFAULT_FILL,
The vertical levels for the cross section are fixed if *levels* is not The vertical levels for the cross section are fixed if *levels* is not
specified, and are determined by dividing the vertical coordinate in to specified, and are determined by dividing the vertical coordinate in to
grid boxes of roughly 1% of the maximum vertical distance from top to grid boxes of roughly 1% of the maximum vertical distance from top to
bottom. Otherwise, the *levels*argument can be used to specify specific bottom. Otherwise, the *levels* argument can be used to specify specific
vertical levels. If all vertical levels are desired, use the raw vertical levels. If all vertical levels are desired, use the raw
:meth:`wrf.interp2dxy` function. :meth:`wrf.interp2dxy` function.

8
src/wrf/projection.py

@ -105,13 +105,13 @@ class WrfProj(object):
Attributes: Attributes:
ll_lat (:obj:`float): Lower left corner latitude. ll_lat (:obj:`float`): Lower left corner latitude.
ll_lat (:obj:`float): Lower left corner longitude. ll_lat (:obj:`float`): Lower left corner longitude.
ur_lat (:obj:`float): Upper right corner latitude. ur_lat (:obj:`float`): Upper right corner latitude.
ur_lon (:obj:`float): Upper right corner longitude. ur_lon (:obj:`float`): Upper right corner longitude.
bottom_left (indexable sequence): A pair of (ll_lat, ll_lon). bottom_left (indexable sequence): A pair of (ll_lat, ll_lon).

13
src/wrf/util.py

@ -293,11 +293,6 @@ class IterWrapper(Iterable):
If the wrapped object is a custom type, then the :meth:`copy.copy` is If the wrapped object is a custom type, then the :meth:`copy.copy` is
called and a new instance is returned. In both cases, the original called and a new instance is returned. In both cases, the original
iterable object is unchanged. iterable object is unchanged.
Args:
wrapped (an iterable object): Any iterable object that contains the
*__iter__* method.
Note: Note:
@ -305,6 +300,14 @@ class IterWrapper(Iterable):
""" """
def __init__(self, wrapped): def __init__(self, wrapped):
"""Initialize an :class:`wrf.IterWrapper` object.
Args:
wrapped (an iterable object): Any iterable object that contains the
*__iter__* method.
"""
self._wrapped = wrapped self._wrapped = wrapped
def __iter__(self): def __iter__(self):

Loading…
Cancel
Save