This script, is really more of a function, the best way to use this would be to copy the contents of this script into the bottom of the script you wish to use it in. This function reads in temperature and moisture information and returns a good approximation of both potential and equivalent potential temperature.
This function asks for up to four inputs, though only temperature and moisture inputs are required.
It is capable of calculating equivalent potential temperature given four different moisture input variables:
- Relative Humidity (-rh)
- Mixing Ratio (-r)
- Vapor Pressure (-e)
- Specific Humidity (-q)
The default is relative humidity.
Example Usage: theta(tmpprs,rhprs)
-This example would define PT and EPT using relative humidity as the input.
In addition to calculating potential and equivalent potential temperature at given pressure levels, this function also allows you to specify surface pressure as the pressure input. This adjusts for the fact that it would simply calculate everything at fixed pressure levels.
Example Usage: theta(tmp2m,spfhum2m,pressfc,'-q')
-This returns the surface PT and EPT calculated using specific humidity as the input.
Notes on Usage: As always, all input variables must be in MKS units. If you wish to use a method other than relative humidity, but do not wish to use a specific variable for surface pressure, just type 'lev' or '-' in place of where surface pressure would normally go (e.g., theta(tmp,mixr,'-','-r')) Be sure to put '' around any variables with a "-" in them, or grads will try to subtract.
I have not tested this function with all of the above variables,but this function does work well with both relative humidity and specific humidity. As always, report any bugs here!
*Minor bug fixed 09/2013