From f2f672151e8ef3a18b1f856c941b8e2fbe1c04e9 Mon Sep 17 00:00:00 2001 From: Bill Ladwig Date: Thu, 13 Apr 2017 16:47:11 -0600 Subject: [PATCH] No longer references DataArray where it shouldn't, so that things work again without xarray installed. Fixes #15 --- src/wrf/decorators.py | 23 +++++++++++++---------- src/wrf/specialdec.py | 8 ++------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/wrf/decorators.py b/src/wrf/decorators.py index 399bc94..406dcec 100644 --- a/src/wrf/decorators.py +++ b/src/wrf/decorators.py @@ -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 + arr = to_np(arg) - if isinstance(arr, np.ma.MaskedArray): - if arr.mask.all(): - + 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) + 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): diff --git a/src/wrf/specialdec.py b/src/wrf/specialdec.py index 8bbdb41..656fcd2 100644 --- a/src/wrf/specialdec.py +++ b/src/wrf/specialdec.py @@ -70,13 +70,9 @@ 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) + u_arr = to_np(u) - v_arr = v - if isinstance(v, DataArray): - v_arr = to_np(v) + v_arr = to_np(v) umissing = Constants.DEFAULT_FILL if isinstance(u_arr, np.ma.MaskedArray):