NCL Home > Documentation > Functions > WRF

# wrf_pvo

Calculates potential vorticity from WRF model output.

## Prototype

```	function wrf_pvo (
u       : numeric,
v       : numeric,
THETA   : numeric,
P       : numeric,
msfu    : numeric,
msfv    : numeric,
msfm    : numeric,
cor     : numeric,
dx   : numeric,
dy   : numeric,
opt  : integer
)

return_val [dimsizes(THETA)] :  float or double
```

## Arguments

u

X-wind component. An array whose rightmost three dimensions are bottom_top x south_north x west_east_stag.

v

Y-wind component. An array whose rightmost three dimensions are bottom_top x south_north_stag x west_east, and whose leftmost dimensions are the same as u's.

THETA

Potential temperature in K. An array whose rightmost dimensions are bottom_top x south_north x west_east, and whose leftmost dimensions are the same as u's.

P

Full pressure (perturbation + base state pressure). An array with the same dimensionality as THETA. Units must be [Pa].

msfu

Map scale factor on u-grid. An array whose rightmost two dimensions are the same as u's. If it contains additional leftmost dimensions, they must be the same as the u and v arrays.

msfv

Map scale factor on v-grid. An array with the same number of dimensions as msfu, whose rightmost two dimensions are the same as v's. If it contains additional leftmost dimensions, they must be the same as the u and v arrays.

msfm

Map scale factor on mass grid. An array with the same number of dimensions as msfu and msfv, whose rightmost two dimensions are south_north x west_east. If it contains additional leftmost dimensions, they must be the same as the u and v arrays.

cor

Coriolis sine latitude term. An array of the same dimensionality as msfm.

dx

A scalar representing the grid spacing in X.

dy

A scalar representing the grid spacing in Y.

opt

An integer option, not in use yet. Set to 0.

## Return value

Potential vorticity at each grid point. The multi-dimensional array will contain the same size and named dimensions as THETA. If THETA does not contain any named dimensions, the rightmost two dimensions will be named "south_north" and "west_east". The type will be double if any of the input is double, and float otherwise.

## Description

This function returns potential vorticity in "Potential Vorticity Unit (PVU)". 1 PVU = 1.0 x 10^(-6) m^2 s^(-1) K kg^(-1).

The return variable will contain two attributes:

return_val@description = "Potential Vorticity"
return_val@units = "PVU"

See the full list of WRF functions.

## Examples

Note: for WRF variable names and their definitions, you can easily check them by using "ncl_filedump":

```  ncl_filedump wrfout_d01_2000-01-24_12:00:00.nc
```

Example 1

``` nc_file = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r")
U    = nc_file->U
V    = nc_file->V
THETA= nc_file->T
P    = nc_file->P
PB   = nc_file->PB
MSFU = nc_file->MAPFAC_U
MSFV = nc_file->MAPFAC_V
MSFM = nc_file->MAPFAC_M
COR  = nc_file->F
DX   = nc_file@DX
DY   = nc_file@DY

THETA = THETA + 300.    ; potential temperature in K.
P     = P + PB          ; full pressure in Pa.

pvo = wrf_pvo( U, V, THETA, P, MSFU, MSFV, MSFM, COR, DX, DY, 0)
```
Example 2

The function wrf_user_getvar (available in the \$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl script) can also be used to calculate many diagnostics in one step.

```  load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
{"ft_lang_label":"__label__en","ft_lang_prob":0.7675806,"math_prob":0.9557284,"size":3518,"snap":"2021-43-2021-49","text_gpt3_token_len":1002,"char_repetition_ratio":0.14769493,"word_repetition_ratio":0.17904761,"special_character_ratio":0.2592382,"punctuation_ratio":0.1597015,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9865101,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-24T12:53:01Z\",\"WARC-Record-ID\":\"<urn:uuid:81d371a2-6ac5-458d-b063-25c43b000d59>\",\"Content-Length\":\"19075\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:66011fec-f1f3-4a73-bd8a-9ec39da2ab33>\",\"WARC-Concurrent-To\":\"<urn:uuid:a81c23e5-3c8c-4566-9557-0016c373ff45>\",\"WARC-IP-Address\":\"128.117.225.48\",\"WARC-Target-URI\":\"https://ncl.ucar.edu/Document/Functions/Built-in/wrf_pvo.shtml\",\"WARC-Payload-Digest\":\"sha1:6DKZQPNHZG6GT6BPNJXCMTVPTSPM4RCG\",\"WARC-Block-Digest\":\"sha1:W24MJNTNVYGGNMOMXHW3DKOCY2TJKEKG\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585997.77_warc_CC-MAIN-20211024111905-20211024141905-00321.warc.gz\"}"}