Browse Source

Merge branch 'feature/issue_73' into develop

lon0
Bill Ladwig 6 years ago
parent
commit
ff5ea2c493
  1. 74
      src/wrf/g_cape.py
  2. 44
      src/wrf/g_cloudfrac.py
  3. 44
      src/wrf/g_uvmet.py
  4. 47
      src/wrf/g_wind.py
  5. 63
      src/wrf/routines.py
  6. BIN
      test/plot_tests/d01/cape2d_only.png
  7. BIN
      test/plot_tests/d01/cape3d_only.png
  8. BIN
      test/plot_tests/d01/cin2d_only.png
  9. BIN
      test/plot_tests/d01/cin3d_only.png
  10. BIN
      test/plot_tests/d01/high_cfrac.png
  11. BIN
      test/plot_tests/d01/lcl.png
  12. BIN
      test/plot_tests/d01/lfc.png
  13. BIN
      test/plot_tests/d01/low_cfrac.png
  14. BIN
      test/plot_tests/d01/mid_cfrac.png
  15. BIN
      test/plot_tests/d01/uvmet10_wdir.png
  16. BIN
      test/plot_tests/d01/uvmet10_wspd.png
  17. BIN
      test/plot_tests/d01/uvmet_wdir.png
  18. BIN
      test/plot_tests/d01/uvmet_wspd.png
  19. BIN
      test/plot_tests/d01/wdir.png
  20. BIN
      test/plot_tests/d01/wdir10.png
  21. BIN
      test/plot_tests/d01/wspd.png
  22. BIN
      test/plot_tests/d01/wspd10.png
  23. BIN
      test/plot_tests/d02/cape2d_only.png
  24. BIN
      test/plot_tests/d02/cape3d_only.png
  25. BIN
      test/plot_tests/d02/cin2d_only.png
  26. BIN
      test/plot_tests/d02/cin3d_only.png
  27. BIN
      test/plot_tests/d02/high_cfrac.png
  28. BIN
      test/plot_tests/d02/lcl.png
  29. BIN
      test/plot_tests/d02/lfc.png
  30. BIN
      test/plot_tests/d02/low_cfrac.png
  31. BIN
      test/plot_tests/d02/mid_cfrac.png
  32. BIN
      test/plot_tests/d02/uvmet10_wdir.png
  33. BIN
      test/plot_tests/d02/uvmet10_wspd.png
  34. BIN
      test/plot_tests/d02/uvmet_wdir.png
  35. BIN
      test/plot_tests/d02/uvmet_wspd.png
  36. BIN
      test/plot_tests/d02/wdir.png
  37. BIN
      test/plot_tests/d02/wdir10.png
  38. BIN
      test/plot_tests/d02/wspd.png
  39. BIN
      test/plot_tests/d02/wspd10.png
  40. 49
      test/plot_tests/plot_all.ipynb

74
src/wrf/g_cape.py

@ -225,4 +225,78 @@ def get_3dcape(wrfin, timeidx=0, method="cat", @@ -225,4 +225,78 @@ def get_3dcape(wrfin, timeidx=0, method="cat",
return ma.masked_values(cape_cin, missing)
def get_cape2d_only(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
meta=True, _key=None, missing=default_fill(np.float64)):
result = get_2dcape(wrfin, timeidx, method, squeeze, cache,
meta, _key, missing)[0,:]
if meta:
result.attrs["description"] = "mcape"
result.attrs["units"] = "J kg-1"
return result
def get_cin2d_only(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
meta=True, _key=None, missing=default_fill(np.float64)):
result = get_2dcape(wrfin, timeidx, method, squeeze, cache,
meta, _key, missing)[1,:]
if meta:
result.attrs["description"] = "mcin"
result.attrs["units"] = "J kg-1"
return result
def get_lcl(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
meta=True, _key=None, missing=default_fill(np.float64)):
result = get_2dcape(wrfin, timeidx, method, squeeze, cache,
meta, _key, missing)[2,:]
if meta:
result.attrs["description"] = "lcl"
result.attrs["units"] = "m"
return result
def get_lfc(wrfin, timeidx=0, method="cat", squeeze=True, cache=None,
meta=True, _key=None, missing=default_fill(np.float64)):
result = get_2dcape(wrfin, timeidx, method, squeeze, cache,
meta, _key, missing)[3,:]
if meta:
result.attrs["description"] = "lfc"
result.attrs["units"] = "m"
return result
def get_3dcape_only(wrfin, timeidx=0, method="cat",
squeeze=True, cache=None, meta=True,
_key=None, missing=default_fill(np.float64)):
result = get_3dcape(wrfin, timeidx, method, squeeze, cache, meta,
_key, missing)[0,:]
if meta:
result.attrs["description"] = "cape"
result.attrs["units"] = "J kg-1"
return result
def get_3dcin_only(wrfin, timeidx=0, method="cat",
squeeze=True, cache=None, meta=True,
_key=None, missing=default_fill(np.float64)):
result = get_3dcape(wrfin, timeidx, method, squeeze, cache, meta,
_key, missing)[1,:]
if meta:
result.attrs["description"] = "cin"
result.attrs["units"] = "J kg-1"
return result

44
src/wrf/g_cloudfrac.py

@ -161,3 +161,47 @@ def get_cloudfrac(wrfin, timeidx=0, method="cat", squeeze=True, @@ -161,3 +161,47 @@ def get_cloudfrac(wrfin, timeidx=0, method="cat", squeeze=True,
return ma.masked_values(cfrac, missing)
def get_low_cloudfrac(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
vert_type="height_agl", low_thresh=None, mid_thresh=None,
high_thresh=None, missing=default_fill(np.float64)):
result = get_cloudfrac(wrfin, timeidx, method, squeeze,
cache, meta, _key,
vert_type, low_thresh, mid_thresh,
high_thresh, missing)[0,:]
if meta:
result.attrs["description"] = "low clouds"
return result
def get_mid_cloudfrac(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
vert_type="height_agl", low_thresh=None, mid_thresh=None,
high_thresh=None, missing=default_fill(np.float64)):
result = get_cloudfrac(wrfin, timeidx, method, squeeze,
cache, meta, _key,
vert_type, low_thresh, mid_thresh,
high_thresh, missing)[1,:]
if meta:
result.attrs["description"] = "mid clouds"
return result
def get_high_cloudfrac(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
vert_type="height_agl", low_thresh=None, mid_thresh=None,
high_thresh=None, missing=default_fill(np.float64)):
result = get_cloudfrac(wrfin, timeidx, method, squeeze,
cache, meta, _key,
vert_type, low_thresh, mid_thresh,
high_thresh, missing)[2,:]
if meta:
result.attrs["description"] = "high clouds"
return result

44
src/wrf/g_uvmet.py

@ -520,7 +520,51 @@ def get_uvmet10_wspd_wdir(wrfin, timeidx=0, method="cat", squeeze=True, @@ -520,7 +520,51 @@ def get_uvmet10_wspd_wdir(wrfin, timeidx=0, method="cat", squeeze=True,
return _calc_wspd_wdir(uvmet10[0,...,:,:], uvmet10[1,...,:,:], True, units)
def get_uvmet_wspd(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
units="m s-1"):
result = get_uvmet_wspd_wdir(wrfin, timeidx, method, squeeze,
cache, meta, _key, units)[0,:]
if meta:
result.attrs["description"] = "earth rotated wspd"
return result
def get_uvmet_wdir(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
units="m s-1"):
result = get_uvmet_wspd_wdir(wrfin, timeidx, method, squeeze,
cache, meta, _key, units)[1,:]
if meta:
result.attrs["description"] = "earth rotated wdir"
return result
def get_uvmet10_wspd(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
units="m s-1"):
result = get_uvmet10_wspd_wdir(wrfin, timeidx, method, squeeze,
cache, meta, _key, units)[0,:]
if meta:
result.attrs["description"] = "10m earth rotated wspd"
return result
def get_uvmet10_wdir(wrfin, timeidx=0, method="cat", squeeze=True,
cache=None, meta=True, _key=None,
units="m s-1"):
result = get_uvmet10_wspd_wdir(wrfin, timeidx, method, squeeze,
cache, meta, _key, units)[1,:]
if meta:
result.attrs["description"] = "10m earth rotated wdir"
return result

47
src/wrf/g_wind.py

@ -507,3 +507,50 @@ def get_destag_wspd_wdir10(wrfin, timeidx=0, method="cat", @@ -507,3 +507,50 @@ def get_destag_wspd_wdir10(wrfin, timeidx=0, method="cat",
return _calc_wspd_wdir(u, v, True, units)
def get_destag_wspd(wrfin, timeidx=0, method="cat",
squeeze=True, cache=None, meta=True, _key=None,
units="m s-1"):
result = get_destag_wspd_wdir(wrfin, timeidx, method, squeeze, cache,
meta, _key, units)[0,:]
if meta:
result.attrs["description"] = "wspd in projection space"
return result
def get_destag_wdir(wrfin, timeidx=0, method="cat",
squeeze=True, cache=None, meta=True, _key=None,
units="m s-1"):
result = get_destag_wspd_wdir(wrfin, timeidx, method, squeeze, cache,
meta, _key, units)[1,:]
if meta:
result.attrs["description"] = "wdir in projection space"
return result
def get_destag_wspd10(wrfin, timeidx=0, method="cat",
squeeze=True, cache=None, meta=True, _key=None,
units="m s-1"):
result = get_destag_wspd_wdir10(wrfin, timeidx, method,
squeeze, cache, meta, _key, units)[0,:]
if meta:
result.attrs["description"] = "10m wspd in projection space"
return result
def get_destag_wdir10(wrfin, timeidx=0, method="cat",
squeeze=True, cache=None, meta=True, _key=None,
units="m s-1"):
result = get_destag_wspd_wdir10(wrfin, timeidx, method,
squeeze, cache, meta, _key, units)[1,:]
if meta:
result.attrs["description"] = "10m wdir in projection space"
return result

63
src/wrf/routines.py

@ -2,7 +2,9 @@ from __future__ import (absolute_import, division, print_function) @@ -2,7 +2,9 @@ from __future__ import (absolute_import, division, print_function)
from .util import (get_iterable, is_standard_wrf_var, extract_vars, viewkeys,
get_id)
from .g_cape import get_2dcape, get_3dcape
from .g_cape import (get_2dcape, get_3dcape, get_cape2d_only,
get_cin2d_only, get_lcl, get_lfc, get_3dcape_only,
get_3dcin_only)
from .g_ctt import get_ctt
from .g_dbz import get_dbz, get_max_dbz
from .g_dewpoint import get_dp, get_dp_2m
@ -17,12 +19,16 @@ from .g_slp import get_slp @@ -17,12 +19,16 @@ from .g_slp import get_slp
from .g_temp import get_tc, get_eth, get_temp, get_theta, get_tk, get_tv, get_tw
from .g_terrain import get_terrain
from .g_uvmet import (get_uvmet, get_uvmet10, get_uvmet10_wspd_wdir,
get_uvmet_wspd_wdir)
get_uvmet_wspd_wdir, get_uvmet_wspd, get_uvmet_wdir,
get_uvmet10_wspd, get_uvmet10_wdir)
from .g_vorticity import get_avo, get_pvo
from .g_wind import (get_destag_wspd_wdir, get_destag_wspd_wdir10,
get_u_destag, get_v_destag, get_w_destag)
get_u_destag, get_v_destag, get_w_destag,
get_destag_wspd, get_destag_wdir, get_destag_wspd10,
get_destag_wdir10)
from .g_times import get_times, get_xtimes
from .g_cloudfrac import get_cloudfrac
from .g_cloudfrac import (get_cloudfrac, get_low_cloudfrac, get_mid_cloudfrac,
get_high_cloudfrac)
# func is the function to call. kargs are required arguments that should
@ -70,7 +76,25 @@ _FUNC_MAP = {"cape2d" : get_2dcape, @@ -70,7 +76,25 @@ _FUNC_MAP = {"cape2d" : get_2dcape,
"ctt" : get_ctt,
"cloudfrac" : get_cloudfrac,
"geopt_stag" : get_stag_geopt,
"zstag" : get_stag_height
"zstag" : get_stag_height,
# Diagnostics below are extracted from multi-product diagnostics
"cape2d_only" : get_cape2d_only,
"cin2d_only" : get_cin2d_only,
"lcl" : get_lcl,
"lfc" : get_lfc,
"cape3d_only" : get_3dcape_only,
"cin3d_only": get_3dcin_only,
"uvmet_wspd" : get_uvmet_wspd,
"uvmet_wdir" : get_uvmet_wdir,
"uvmet10_wspd" : get_uvmet10_wspd,
"uvmet10_wdir" : get_uvmet10_wdir,
"wspd" : get_destag_wspd,
"wdir" : get_destag_wdir,
"wspd10" : get_destag_wspd10,
"wdir10" : get_destag_wdir10,
"low_cloudfrac" : get_low_cloudfrac,
"mid_cloudfrac" : get_mid_cloudfrac,
"high_cloudfrac" : get_high_cloudfrac
}
_VALID_KARGS = {"cape2d" : ["missing"],
@ -118,6 +142,26 @@ _VALID_KARGS = {"cape2d" : ["missing"], @@ -118,6 +142,26 @@ _VALID_KARGS = {"cape2d" : ["missing"],
"mid_thresh", "high_thresh"],
"geopt_stag" : [],
"zstag" : ["msl", "units"],
"cape2d_only" : ["missing"],
"cin2d_only" : ["missing"],
"lcl" : ["missing"],
"lfc" : ["missing"],
"cape3d_only" : ["missing"],
"cin3d_only": ["missing"],
"uvmet_wspd" : ["units"],
"uvmet_wdir" : ["units"],
"uvmet10_wspd" : ["units"],
"uvmet10_wdir" : ["units"],
"wspd" : ["units"],
"wdir" : ["units"],
"wspd10" : ["units"],
"wdir10" : ["units"],
"low_cloudfrac" : ["vert_type", "low_thresh",
"mid_thresh", "high_thresh"],
"mid_cloudfrac" : ["vert_type", "low_thresh",
"mid_thresh", "high_thresh"],
"high_cloudfrac" : ["vert_type", "low_thresh",
"mid_thresh", "high_thresh"],
"default" : []
}
@ -140,7 +184,14 @@ _ALIASES = {"cape_2d" : "cape2d", @@ -140,7 +184,14 @@ _ALIASES = {"cape_2d" : "cape2d",
"cfrac" : "cloudfrac",
"wspd_wdir_uvmet" : "uvmet_wspd_wdir",
"wspd_wdir_uvmet10" : "uvmet10_wspd_wdir",
"th" : "theta"
"th" : "theta",
"low_cfrac" : "low_cloudfrac",
"mid_cfrac" : "mid_cloudfrac",
"high_cfrac" : "high_cloudfrac",
"wspd_uvmet" : "uvmet_wspd" ,
"wdir_uvmet" : "uvmet_wdir" ,
"wspd_uvmet10" : "uvmet10_wspd" ,
"wdir_uvmet10" : "uvmet10_wdir" ,
}
class ArgumentError(Exception):

BIN
test/plot_tests/d01/cape2d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
test/plot_tests/d01/cape3d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

BIN
test/plot_tests/d01/cin2d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

BIN
test/plot_tests/d01/cin3d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
test/plot_tests/d01/high_cfrac.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
test/plot_tests/d01/lcl.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 KiB

BIN
test/plot_tests/d01/lfc.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

BIN
test/plot_tests/d01/low_cfrac.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

BIN
test/plot_tests/d01/mid_cfrac.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

BIN
test/plot_tests/d01/uvmet10_wdir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

BIN
test/plot_tests/d01/uvmet10_wspd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
test/plot_tests/d01/uvmet_wdir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

BIN
test/plot_tests/d01/uvmet_wspd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
test/plot_tests/d01/wdir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

BIN
test/plot_tests/d01/wdir10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

BIN
test/plot_tests/d01/wspd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
test/plot_tests/d01/wspd10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
test/plot_tests/d02/cape2d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

BIN
test/plot_tests/d02/cape3d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

BIN
test/plot_tests/d02/cin2d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
test/plot_tests/d02/cin3d_only.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
test/plot_tests/d02/high_cfrac.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
test/plot_tests/d02/lcl.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
test/plot_tests/d02/lfc.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

BIN
test/plot_tests/d02/low_cfrac.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
test/plot_tests/d02/mid_cfrac.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
test/plot_tests/d02/uvmet10_wdir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
test/plot_tests/d02/uvmet10_wspd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
test/plot_tests/d02/uvmet_wdir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
test/plot_tests/d02/uvmet_wspd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
test/plot_tests/d02/wdir.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

BIN
test/plot_tests/d02/wdir10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

BIN
test/plot_tests/d02/wspd.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
test/plot_tests/d02/wspd10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

49
test/plot_tests/plot_all.ipynb

@ -210,6 +210,50 @@ @@ -210,6 +210,50 @@
" elif diagname == \"uvmet10_wspd_wdir\":\n",
" levels = numpy.arange(-40,40,5)\n",
" extend = \"both\"\n",
" elif diagname ==\"cape2d_only\":\n",
" levels = numpy.arange(200.,4000.,250.)\n",
" extend = \"max\"\n",
" elif diagname ==\"cin2d_only\": \n",
" levels = numpy.arange(10.,200.,10.)\n",
" extend = \"max\"\n",
" elif diagname ==\"lcl\":\n",
" levels = numpy.arange(50.,2000.,50.)\n",
" extend = \"max\"\n",
" elif diagname ==\"lfc\": \n",
" levels = numpy.arange(100.,5000.,100.)\n",
" extend = \"max\"\n",
" elif diagname ==\"cape3d_only\": \n",
" levels = numpy.arange(200.,4000.,250.)\n",
" extend = \"max\"\n",
" elif diagname ==\"cin3d_only\": \n",
" levels = levels = numpy.arange(10.,200.,10.)\n",
" extend = \"max\"\n",
" elif diagname ==\"uvmet_wspd\": \n",
" levels = numpy.arange(-40,40,5)\n",
" extend = \"both\"\n",
" elif diagname ==\"uvmet_wdir\": \n",
" levels = numpy.arange(0,370,10)\n",
" elif diagname ==\"uvmet10_wspd\": \n",
" levels = numpy.arange(-40,40,5)\n",
" extend = \"both\"\n",
" elif diagname ==\"uvmet10_wdir\": \n",
" levels = numpy.arange(0,370,10)\n",
" elif diagname ==\"wspd\": \n",
" levels = numpy.arange(-40,40,5)\n",
" extend = \"both\"\n",
" elif diagname ==\"wdir\": \n",
" levels = numpy.arange(0,370,10)\n",
" elif diagname ==\"wspd10\": \n",
" levels = numpy.arange(-40,40,5)\n",
" extend = \"both\"\n",
" elif diagname ==\"wdir10\": \n",
" levels = numpy.arange(0,370,10)\n",
" elif diagname ==\"low_cfrac\":\n",
" levels = numpy.arange(0.0,1.1,.2)\n",
" elif diagname ==\"mid_cfrac\": \n",
" levels = numpy.arange(0.0,1.1,.2)\n",
" elif diagname ==\"high_cfrac\":\n",
" levels = numpy.arange(0.0,1.1,.2)\n",
" \n",
" return levels, extend"
]
@ -238,7 +282,10 @@ @@ -238,7 +282,10 @@
" \"pvo\", \"pw\", \"rh2\", \"rh\", \"slp\", \"td2\", \"td\", \"tc\",\n",
" \"theta\", \"tk\", \"tv\", \"twb\", \"updraft_helicity\", \"ua\", \"va\", \n",
" \"wa\", \"uvmet10\", \"uvmet\", \"z\", \"wspd_wdir\", \"wspd_wdir10\",\n",
" \"uvmet_wspd_wdir\", \"uvmet10_wspd_wdir\", \"cfrac\"):\n",
" \"uvmet_wspd_wdir\", \"uvmet10_wspd_wdir\", \"cfrac\",\n",
" \"cape2d_only\",\"cin2d_only\", \"lcl\", \"lfc\", \"cape3d_only\", \"cin3d_only\",\"uvmet_wspd\", \n",
" \"uvmet_wdir\",\"uvmet10_wspd\", \"uvmet10_wdir\",\"wspd\", \"wdir\", \"wspd10\", \"wdir10\",\n",
" \"low_cfrac\", \"mid_cfrac\", \"high_cfrac\"):\n",
" \n",
" # Get the terrain height\n",
" print(diagname)\n",

Loading…
Cancel
Save