From a44dd478927cf15f47b0625720f62eae84cdc17f Mon Sep 17 00:00:00 2001 From: Bill Ladwig Date: Wed, 6 Jan 2016 16:18:09 -0700 Subject: [PATCH] Changed default missing value to the one from netcdf.h that NCL uses --- wrf_open/var/src/python/wrf/var/cape.py | 4 ++-- wrf_open/var/src/python/wrf/var/constants.py | 1 + wrf_open/var/src/python/wrf/var/interp.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wrf_open/var/src/python/wrf/var/cape.py b/wrf_open/var/src/python/wrf/var/cape.py index 1f7ae90..d21a9f6 100755 --- a/wrf_open/var/src/python/wrf/var/cape.py +++ b/wrf_open/var/src/python/wrf/var/cape.py @@ -8,7 +8,7 @@ from wrf.var.util import extract_vars __all__ = ["get_2dcape", "get_3dcape"] -def get_2dcape(wrfnc, timeidx=0, missing=-999999.0): +def get_2dcape(wrfnc, timeidx=0, missing=Constants.DEFAULT_FILL): """Return the 2d fields of cape, cin, lcl, and lfc""" ncvars = extract_vars(wrfnc, timeidx, vars=("T", "P", "PB", "QVAPOR", "PH", "PHB", "HGT", "PSFC")) @@ -60,7 +60,7 @@ def get_2dcape(wrfnc, timeidx=0, missing=-999999.0): return ma.masked_values(res,missing) -def get_3dcape(wrfnc, timeidx=0, missing=-999999.0): +def get_3dcape(wrfnc, timeidx=0, missing=Constants.DEFAULT_FILL): """Return the 3d fields of cape and cin""" ncvars = extract_vars(wrfnc, timeidx, vars=("T", "P", "PB", "QVAPOR", diff --git a/wrf_open/var/src/python/wrf/var/constants.py b/wrf_open/var/src/python/wrf/var/constants.py index 58920e1..b34c63b 100755 --- a/wrf_open/var/src/python/wrf/var/constants.py +++ b/wrf_open/var/src/python/wrf/var/constants.py @@ -8,6 +8,7 @@ class Constants(object): TCK0 = 273.15 T_BASE = 300.0 # In WRF the base temperature is always 300 (not var T00) PI = 3.14159265 + DEFAULT_FILL = 9.9692099683868690e+36 # Value is from netcdf.h class ConversionFactors(object): diff --git a/wrf_open/var/src/python/wrf/var/interp.py b/wrf_open/var/src/python/wrf/var/interp.py index 76632dd..973192c 100755 --- a/wrf_open/var/src/python/wrf/var/interp.py +++ b/wrf_open/var/src/python/wrf/var/interp.py @@ -5,11 +5,12 @@ import numpy.ma as ma from wrf.var.extension import interpz3d,interp2dxy,interp1d from wrf.var.decorators import handle_left_iter, handle_casting +from wrf.var.constants import Constants __all__ = ["interplevel", "vertcross", "interpline"] # Note: Extension decorator is good enough to handle left dims -def interplevel(data3d,zdata,desiredloc,missingval=-99999): +def interplevel(data3d,zdata,desiredloc,missingval=Constants.DEFAULT_FILL): """Return the horizontally interpolated data at the provided level data3d - the 3D field to interpolate @@ -140,7 +141,7 @@ def _get_xy(xdim, ydim, pivot_point=None, angle=None, ignore_kargs=("missingval", "pivot_point", "angle", "start_point", "end_point")) @handle_casting(arg_idxs=(0,1)) -def vertcross(data3d, z, missingval=-99999, +def vertcross(data3d, z, missingval=Constants.DEFAULT_FILL, pivot_point=None,angle=None, start_point=None,end_point=None): """Return the vertical cross section for a 3D field, interpolated