Browse Source

No longer references DataArray where it shouldn't, so that things work again without xarray installed. Fixes #15

lon0
Bill Ladwig 8 years ago
parent
commit
f2f672151e
  1. 21
      src/wrf/decorators.py
  2. 4
      src/wrf/specialdec.py

21
src/wrf/decorators.py

@ -186,26 +186,29 @@ def left_iteration(ref_var_expected_dims, @@ -186,26 +186,29 @@ def left_iteration(ref_var_expected_dims,
# Skip the possible empty/missing arrays for the join method
skip_missing = False
for arg in new_args:
if isinstance(arg, DataArray):
arr = to_np(arg)
elif isinstance(arg, np.ndarray):
arr = arg
try:
_ = arg.ndim
except AttributeError:
continue # Not an array object
else:
continue
if isinstance(arr, np.ma.MaskedArray):
if arr.mask.all():
arr = to_np(arg)
try:
all_masked = arr.mask.all()
except AttributeError:
pass # Not a masked array
else:
if all_masked:
for output in viewvalues(outd):
output[left_and_slice_idxs] = (
Constants.DEFAULT_FILL)
skip_missing = True
mask_output = True
break
if skip_missing:
continue
# Insert the output views if one hasn't been provided
if "outview" not in new_kargs:
for outkey,output in viewitems(outd):

4
src/wrf/specialdec.py

@ -70,12 +70,8 @@ def uvmet_left_iter(alg_dtype=np.float64): @@ -70,12 +70,8 @@ def uvmet_left_iter(alg_dtype=np.float64):
mode = 2 # probably 3D with 2D lat/lon plus Time
has_missing = False
u_arr = u
if isinstance(u, DataArray):
u_arr = to_np(u)
v_arr = v
if isinstance(v, DataArray):
v_arr = to_np(v)
umissing = Constants.DEFAULT_FILL

Loading…
Cancel
Save