Browse Source

Fixed plot doc import issue. Updated error messages for map related utility functions when xarray is not installed or is disabled.

lon0
Bill Ladwig 8 years ago
parent
commit
fa5bebe242
  1. 2
      doc/source/plot.rst
  2. 2
      src/wrf/computation.py
  3. 15
      src/wrf/util.py

2
doc/source/plot.rst

@ -40,7 +40,7 @@ Plotting a Two-dimensional Field @@ -40,7 +40,7 @@ Plotting a Two-dimensional Field
import cartopy.crs as crs
from cartopy.feature import NaturalEarthFeature
from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim
from wrf import to_np, getvar, smooth2d, get_cartopy, cartopy_xlim, cartopy_ylim, latlon_coords
# Open the NetCDF file
ncfile = Dataset("wrfout_d01_2016-10-07_00_00_00")

2
src/wrf/computation.py

@ -26,7 +26,7 @@ def xy(field, pivot_point=None, angle=None, start_point=None, end_point=None, @@ -26,7 +26,7 @@ def xy(field, pivot_point=None, angle=None, start_point=None, end_point=None,
Args:
field3d (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A
field (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A
field with at least two dimensions.
pivot_point (:obj:`tuple` or :obj:`list`, optional): A

15
src/wrf/util.py

@ -3021,6 +3021,9 @@ def geo_bounds(var=None, wrfin=None, varname=None, timeidx=0, method="cat", @@ -3021,6 +3021,9 @@ def geo_bounds(var=None, wrfin=None, varname=None, timeidx=0, method="cat",
# Getting lat/lon from xarray coordinates
if var is not None:
if not xarray_enabled():
raise ValueError("xarray is not installed or is disabled")
is_moving = None
try:
var_coords = var.coords
@ -3142,8 +3145,15 @@ def _get_wrf_proj_geobnds(var, wrfin, varname, timeidx, method, squeeze, @@ -3142,8 +3145,15 @@ def _get_wrf_proj_geobnds(var, wrfin, varname, timeidx, method, squeeze,
"""
# Using a variable
if var is not None:
if not xarray_enabled():
raise ValueError("xarray is not installed or is disabled")
geobnds = geo_bounds(var)
try:
wrf_proj = var.attrs["projection"]
except AttributeError:
raise ValueError("variable does not contain projection "
"information")
else:
geobnds = geo_bounds(wrfin=wrfin, varname=varname, timeidx=timeidx,
method=method, cache=cache)
@ -3260,6 +3270,9 @@ def latlon_coords(var, as_np=False): @@ -3260,6 +3270,9 @@ def latlon_coords(var, as_np=False):
"""
if not xarray_enabled():
raise ValueError("xarray is not installed or is disabled")
try:
var_coords = var.coords
except AttributeError:
@ -3284,8 +3297,6 @@ def latlon_coords(var, as_np=False): @@ -3284,8 +3297,6 @@ def latlon_coords(var, as_np=False):
return lats, lons
def get_cartopy(var=None, wrfin=None, varname=None, timeidx=0, method="cat",
squeeze=True, cache=None):
"""Return a :class:`cartopy.crs.Projection` subclass for the

Loading…
Cancel
Save