wrf.getvar¶
- wrf.getvar(wrfin, varname, timeidx=0, method='cat', squeeze=True, cache=None, meta=True, **kwargs)¶
Returns basic diagnostics from the WRF ARW model output.
A table of all available diagnostics is below.
Variable Name
Description
Available Units
Additional Keyword Arguments
avo
Absolute Vorticity
10-5 s-1
eth/theta_e
Equivalent Potential Temperature
K
degC
degF
units (str) : Set to desired units. Default is ‘K’.
cape_2d
2D CAPE (MCAPE/MCIN/LCL/LFC)
J kg-1 ; J kg-1 ; m ; m
missing (float): Fill value for output only
cape_3d
3D CAPE and CIN
J kg-1
missing (float): Fill value for output only
ctt
Cloud Top Temperature
degC
K
degF
fill_nocloud (boolean): Set to True to use fill values for cloud free regions rather than surface temperature. Default is False.
missing (float): The fill value to use when fill_nocloud is True.
opt_thresh (float): The optical depth required to trigger the cloud top temperature calculation. Default is 1.0.
units (str) : Set to desired units. Default is ‘degC’.
cloudfrac
Cloud Fraction
%
vert_type (str): The vertical coordinate type for the cloud thresholds. Must be ‘height_agl’, ‘height_msl’, or ‘pres’. Default is ‘height_agl’.
low_thresh (float): The low cloud threshold (meters for ‘height_agl’ and ‘height_msl’, pascals for ‘pres’). Default is 300 m (97000 Pa)
mid_thresh (float): The mid cloud threshold (meters for ‘height_agl’ and ‘height_msl’, pascals for ‘pres’). Default is 2000 m (80000 Pa)
high_thresh (float): The high cloud threshold (meters for ‘height_agl’ and ‘height_msl’, pascals for ‘pres’). Default is 6000 m (45000 Pa)
dbz
Reflectivity
dBZ
do_variant (boolean): Set to True to enable variant calculation. Default is False.
do_liqskin (boolean): Set to True to enable liquid skin calculation. Default is False.
mdbz
Maximum Reflectivity
dBZ
do_variant (boolean): Set to True to enable variant calculation. Default is False.
do_liqskin (boolean): Set to True to enable liquid skin calculation. Default is False.
geopt/geopotential
Geopotential for the Mass Grid
m2 s-2
geopt_stag
Geopotential for the Vertically Staggered Grid
m2 s-2
helicity
Storm Relative Helicity
m2 s-2
top (float): The top level for the calculation in meters. Default is 3000.0.
lat
Latitude
decimal degrees
lon
Longitude
decimal degrees
omg/omega
Omega
Pa s-1
p/pres
Full Model Pressure
(in specified units)
Pa
hPa
mb
torr
mmhg
atm
units (str) : Set to desired units. Default is ‘Pa’.
pressure
Full Model Pressure (hPa)
hPa
pvo
Potential Vorticity
PVU
pw
Precipitable Water
kg m-2
rh
Relative Humidity
%
rh2
2m Relative Humidity
%
slp
Sea Level Pressure
hPa
hPa
mb
torr
mmhg
atm
units (str) : Set to desired units. Default is ‘hPa’.
T2
2m Temperature
K
ter
Model Terrain Height
m
km
dm
ft
mi
units (str) : Set to desired units. Default is ‘m’.
td2
2m Dew Point Temperature
degC
K
degF
units (str) : Set to desired units. Default is ‘degC’.
td
Dew Point Temperature
degC
K
degF
units (str) : Set to desired units. Default is ‘degC’.
tc
Temperature in Celsius
degC
th/theta
Potential Temperature
K
degC
degF
units (str) : Set to desired units. Default is ‘K’.
temp
Temperature (in specified units)
K
degC
degF
units (str) : Set to desired units. Default is ‘K’.
tk
Temperature in Kelvin
K
times
Times in the File or Sequence
xtimes
XTIME Coordinate
(if applicable)
minutes since
start of
model run
tv
Virtual Temperature
K
degC
degF
units (str) : Set to desired units. Default is ‘K’.
twb
Wet Bulb Temperature
K
degC
degF
units (str) : Set to desired units. Default is ‘K’.
updraft_helicity
Updraft Helicity
m2 s-2
bottom (float): The bottom level for the calculation in meters. Default is 2000.0.
top (float): The top level for the calculation in meters. Default is 5000.0.
ua
U-component of Wind on Mass Points
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
va
V-component of Wind on Mass Points
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
wa
W-component of Wind on Mass Points
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
uvmet10
10 m U and V Components of Wind
Rotated to Earth Coordinates
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
uvmet
U and V Components of Wind
Rotated to Earth Coordinates
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
wspd_wdir
Wind Speed and Direction (wind_from_direction)
in Grid Coordinates
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
wspd_wdir10
10m Wind Speed and Direction (wind_from_direction)
in Grid Coordinates
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
uvmet_wspd_wdir
Wind Speed and Direction (wind_from_direction)
Rotated to Earth Coordinates
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
uvmet10_wspd_wdir
10m Wind Speed and Direction (wind_from_direction)
Rotated to Earth Coordinates
m s-1
km h-1
mi h-1
kt
ft s-1
units (str) : Set to desired units. Default is ‘m s-1’.
z/height
Model Height for Mass Grid
m
km
dm
ft
mi
msl (boolean): Set to False to return AGL values. True is for MSL. Default is True.
units (str) : Set to desired units. Default is ‘m’.
height_agl
Model Height for Mass Grid (AGL)
m
km
dm
ft
mi
units (str) : Set to desired units. Default is ‘m’.
zstag
Model Height for Vertically Staggered Grid
m
km
dm
ft
mi
msl (boolean): Set to False to return AGL values. True is for MSL. Default is True.
units (str) : Set to desired units. Default is ‘m’.
- Parameters:
wrfin (
netCDF4.Dataset
,Nio.NioFile
, or an iterable) – WRF-ARW NetCDF data as anetCDF4.Dataset
,Nio.NioFile
or an iterable sequence of the aforementioned types.varname (
str
) – The variable name.timeidx (
int
orwrf.ALL_TIMES
, optional) – The desired time index. This value can be a positive integer, negative integer, orwrf.ALL_TIMES
(an alias for None) to return all times in the file or sequence. The default is 0.method (
str
, optional) – The aggregation method to use for sequences. Must be either ‘cat’ or ‘join’. ‘cat’ combines the data along the Time dimension. ‘join’ creates a new dimension for the file index. The default is ‘cat’.squeeze (
bool
, optional) – Set to False to prevent dimensions with a size of 1 from being automatically removed from the shape of the output. Default is True.cache (
dict
, optional) – A dictionary of (varname, ndarray) that can be used to supply pre-extracted NetCDF variables to the computational routines. It is primarily used for internal purposes, but can also be used to improve performance by eliminating the need to repeatedly extract the same variables used in multiple diagnostics calculations, particularly when using large sequences of files. Default is None.meta (
bool
, optional) – Set to False to disable metadata and returnnumpy.ndarray
instead ofxarray.DataArray
. Default is True.**kwargs – Optional keyword arguments for certain diagnostics. See table above.
- Returns:
If xarray is enabled and the meta parameter is True, then the result will be a
xarray.DataArray
object. Otherwise, the result will be anumpy.ndarray
object with no metadata.- Return type:
- Raises:
ValueError – Raised when an invalid diagnostic type or keyword argument is passed to the routine.
FortranError – Raised when a problem occurs during a Fortran calculation.
See also
Examples
Using netCDF4
from netCDF4 import Dataset from wrf import getvar wrfnc = Dataset("wrfout_d02_2010-06-13_21:00:00") slp = getvar(wrfnc, "slp")
Using PyNIO
from Nio import open_file from wrf import getvar wrfnc = open_file("wrfout_d02_2010-06-13_21:00:00"+".nc", "r") slp = getvar(wrfnc, "slp")
Using Iterables:
import os from netCDF4 import Dataset from wrf import getvar filedir = "/path/to/wrf/files" wrfin = [Dataset(f) for f in os.listdir(filedir) if f.startswith("wrfout_d02_")] uvmet = getvar(wrfin, "uvmet", timeidx=3, units="kt")