diff --git a/src/wrf/api.py b/src/wrf/api.py index ddab30d..c5dec8c 100644 --- a/src/wrf/api.py +++ b/src/wrf/api.py @@ -33,7 +33,7 @@ from .projection import (WrfProj, NullProjection, LambertConformal, Mercator, getproj) from .coordpair import CoordPair from .interputils import to_xy_coords -from cache import cache_item, get_cached_item +from .cache import cache_item, get_cached_item from .version import __version__ __all__ = [] diff --git a/src/wrf/computation.py b/src/wrf/computation.py index d66fcf8..dcca9b8 100644 --- a/src/wrf/computation.py +++ b/src/wrf/computation.py @@ -104,7 +104,7 @@ def xy(field, pivot_point=None, angle=None, start_point=None, end_point=None, @set_interp_metadata("1d") -def interp1d(field, z_in, z_out, missingval=Constants.DEFAULT_FILL, +def interp1d(field, z_in, z_out, missing=Constants.DEFAULT_FILL, meta=True): """Return the linear interpolation of a one-dimensional variable. @@ -127,7 +127,7 @@ def interp1d(field, z_in, z_out, missingval=Constants.DEFAULT_FILL, one-dimensional array of *z_in* coordinate points to interpolate to. Must be the same type as *z_in*. - missingval (:obj:`float`, optional): The fill value to use for the + missing (:obj:`float`, optional): The fill value to use for the output. Default is :data:`wrf.Constants.DEFAULT_FILL`. meta (:obj:`bool`, optional): Set to False to disable metadata and @@ -174,7 +174,7 @@ def interp1d(field, z_in, z_out, missingval=Constants.DEFAULT_FILL, interp_vals = interp1d(p_1d, ht_1d, levels) """ - return _interp1d(field, z_in, z_out, missingval) + return _interp1d(field, z_in, z_out, missing) @set_interp_metadata("2dxy") @@ -713,7 +713,7 @@ def smooth2d(field, passes, meta=True): @set_cape_alg_metadata(is2d=True, copyarg="pres_hpa") def cape_2d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, - missingval=Constants.DEFAULT_FILL, meta=True): + missing=Constants.DEFAULT_FILL, meta=True): """Return the two-dimensional CAPE, CIN, LCL, and LFC. This function calculates the maximum convective available potential @@ -789,7 +789,7 @@ def cape_2d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, data uses terrain following coordinates (WRF data). Set to False for pressure level data. - missingval (:obj:`float`, optional): The fill value to use for the + missing (:obj:`float`, optional): The fill value to use for the output. Default is :data:`wrf.Constants.DEFAULT_FILL`. meta (:obj:`bool`): Set to False to disable metadata and return @@ -821,7 +821,7 @@ def cape_2d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, i3dflag = 0 cape_cin = _cape(pres_hpa, tkel, qv, height, terrain, psfc_hpa, - missingval, i3dflag, ter_follow) + missing, i3dflag, ter_follow) left_dims = cape_cin.shape[1:-3] right_dims = cape_cin.shape[-2:] @@ -838,12 +838,12 @@ def cape_2d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, result[2,...,:,:] = cape_cin[1,...,-2,:,:] result[3,...,:,:] = cape_cin[1,...,-3,:,:] - return ma.masked_values(result, missingval) + return ma.masked_values(result, missing) @set_cape_alg_metadata(is2d=False, copyarg="pres_hpa") def cape_3d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, - missingval=Constants.DEFAULT_FILL, meta=True): + missing=Constants.DEFAULT_FILL, meta=True): """Return the three-dimensional CAPE and CIN. This function calculates the maximum convective available potential @@ -911,7 +911,7 @@ def cape_3d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, data uses terrain following coordinates (WRF data). Set to False for pressure level data. - missingval (:obj:`float`, optional): The fill value to use for the + missing (:obj:`float`, optional): The fill value to use for the output. Default is :data:`wrf.Constants.DEFAULT_FILL`. meta (:obj:`bool`): Set to False to disable metadata and return @@ -943,9 +943,9 @@ def cape_3d(pres_hpa, tkel, qv, height, terrain, psfc_hpa, ter_follow, i3dflag = 1 cape_cin = _cape(pres_hpa, tkel, qv, height, terrain, psfc_hpa, - missingval, i3dflag, ter_follow) + missing, i3dflag, ter_follow) - return ma.masked_values(cape_cin, missingval) + return ma.masked_values(cape_cin, missing) @set_cloudfrac_alg_metadata(copyarg="pres") diff --git a/test/ipynb/nocopy_test.ipynb b/test/ipynb/nocopy_test.ipynb index 0876abb..44a68e2 100644 --- a/test/ipynb/nocopy_test.ipynb +++ b/test/ipynb/nocopy_test.ipynb @@ -130,11 +130,11 @@ "outputs": [], "source": [ "# Pressure using pivot and angle\n", - "from wrf import getvar, vertcross\n", + "from wrf import getvar, vertcross, CoordPair\n", "\n", "z = getvar(ncfile, \"z\", timeidx=None)\n", "p = getvar(ncfile, \"pressure\", timeidx=None)\n", - "pivot_point = (z.shape[-2] / 2, z.shape[-1] / 2) \n", + "pivot_point = CoordPair(z.shape[-2] / 2, z.shape[-1] / 2) \n", "angle = 90.0\n", "\n", "p_vert = vertcross(p, z, pivot_point=pivot_point, angle=angle)\n", @@ -142,8 +142,8 @@ "del p_vert\n", "\n", "# Pressure using start_point and end_point\n", - "start_point = (z.shape[-2]/2, 0)\n", - "end_point = (z.shape[-2]/2, -1)\n", + "start_point = CoordPair(z.shape[-2]/2, 0)\n", + "end_point = CoordPair(z.shape[-2]/2, -1)\n", "\n", "p_vert = vertcross(p, z, start_point=start_point, end_point=end_point)\n", "print(p_vert)\n", @@ -164,10 +164,10 @@ "outputs": [], "source": [ "# T2 using pivot and angle\n", - "from wrf import interpline, getvar\n", + "from wrf import interpline, getvar, CoordPair\n", "\n", "t2 = getvar([ncfile,ncfile,ncfile], \"T2\", timeidx=None)\n", - "pivot_point = (t2.shape[-2] / 2, t2.shape[-1] / 2) \n", + "pivot_point = CoordPair(t2.shape[-2] / 2, t2.shape[-1] / 2) \n", "angle = 90.0\n", "\n", "t2_line = interpline(t2, pivot_point=pivot_point, angle=angle)\n", @@ -176,8 +176,8 @@ "del t2_line\n", "\n", "# T2 using start_point and end_point\n", - "start_point = (t2.shape[-2]/2, 0)\n", - "end_point = (t2.shape[-2]/2, -1)\n", + "start_point = CoordPair(t2.shape[-2]/2, 0)\n", + "end_point = CoordPair(t2.shape[-2]/2, -1)\n", "\n", "t2_line = interpline(t2, start_point=start_point, end_point=end_point)\n", "print(t2_line)\n", @@ -430,7 +430,7 @@ "import numpy as np\n", "from wrf import (ALL_TIMES, to_np, Constants, getvar, extract_vars, destagger, \n", " interp1d, interp2dxy, interpz3d, \n", - " slp, tk, td, rh, uvmet, smooth2d, extract_global_attrs, xy)\n", + " slp, tk, td, rh, uvmet, smooth2d, extract_global_attrs, xy, CoordPair)\n", "from math import fabs, log, tan, sin, cos\n", "from wrf.util import either\n", "from netCDF4 import Dataset as nc\n", @@ -443,7 +443,7 @@ "\n", "z = getvar(wrfnc, \"z\", timeidx)\n", "\n", - "interp = interpz3d(field3d, z, 500, missingval=Constants.DEFAULT_FILL, meta=True)\n", + "interp = interpz3d(field3d, z, 500, missing=Constants.DEFAULT_FILL, meta=True)\n", "print (interp)\n", "print (\"\\n\")\n", "\n", @@ -479,7 +479,7 @@ "z_in = z[only_height]\n", "z_out = np.asarray([100.,200.,300.,500.,1000.,5000.], field3d.dtype)\n", "\n", - "int1d = interp1d(v_in, z_in, z_out, missingval=Constants.DEFAULT_FILL, meta=True)\n", + "int1d = interp1d(v_in, z_in, z_out, missing=Constants.DEFAULT_FILL, meta=True)\n", "print(int1d)\n", "print (\"\\n\")\n" ]