[ncl-talk] calculate a variable from other wrf variables and plot it
Bill Ladwig
ladwig at ucar.edu
Fri May 27 16:38:38 MDT 2016
I also want to add that theta-e is already available via wrf_user_getvar
using the 'eth' variable, if you want to use the built-in one.
Regards,
Bill
On Fri, May 27, 2016 at 4:03 PM, Mary Haley <haley at ucar.edu> wrote:
> Does running the script produce an error message? If so, please email the
> exact error message.
>
> I do see that you are imbedding a function inside the main code. I believe
> this is acceptable in NCL, but just to be sure, I need to see what your
> error message states.
>
> If there's no error message, then describe in more detail what the problem
> is (i.e. if the plot is bad, describe how it is bad, and include an image
> if possible).
>
> Thanks,
>
> --Mary
>
>
> On Fri, May 27, 2016 at 1:33 PM, Agud Pique, Enric <eagud.q at ccma.cat>
> wrote:
>
>> Hello people,
>>
>>
>>
>> I would like to plot a variable calculated from several wrf
>> variables....for example, the following code....get temperature, pressure
>> and relative humidity and after I select tempC and relhum in 850 hPa...
>> after calculate Theta E, I want to plot it, but when I execute the scripts
>> it fails...what is wrong?
>>
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>> begin
>> a = addfile("./wrfout_d01_2016-05-24_18:00:00","r")
>> wks = gsn_open_wks("X11","plt_Surface")
>>
>>
>> tc = wrf_user_getvar(a,"tc",0)
>> p = wrf_user_getvar(a,"pressure",0)
>> rh = wrf_user_getvar(a,"rh",0)
>> pressure = 850.
>> res = True
>>
>> tempC = wrf_user_intrp3d(tc,p,"h",850.,0.,res)
>> relhum= wrf_user_intrp3d(rh,p,"h",850.,0.,res)
>>
>> pltres = True
>> mpres = True
>>
>> opts = res
>> opts at cnFillOn = True
>> opts at cnLevelSelectionMode = "ExplicitLevels"
>>
>> ;-----------------------------------------
>> ; Calculate Theta E
>> ;-----------------------------------------
>>
>>
>> undef("calc_thetae")
>>
>> function calc_thetae(tempC,pres,relhum)
>>
>> local tempC, pres, relhum, tc, tk, pp, p0, rh, es, en, rv, rd, cp, kd,
>> td, tl, thetal, thetae
>>
>> begin
>> pres = 850.
>> Tc = tempC ; [C]
>> tk = tempC+273.15 ; [K]
>> pp = pres ; [hPa]
>> p0 = 1000 ; [hPa]
>> rh = relhum/100 ; [no dimensions]
>> es = 6.112*exp(17.67*Tc/(Tc+243.5)) ; [hPa]
>> en = rh*es ; [hPa]
>> rv = 0.622*en/(pp-en) ; [no dimensions]
>> rd = 287.04 ; [J/kgK]
>> cp = 1005.7 ; [J/kgK]
>> kd = rd/cp ; [no dimensions]
>> tl = (1/((1/(tk-55))-(log(rh)/2840)))+55 ; [K]
>> thetal = tk*((p0/(pp-en))^kd)*((tk/tl)^(0.28*rv)) ; [K]
>> thetae = thetal*exp(((3036/tl)-1.78)*rv*(1+0.448*rv)) ; [K]
>> thetae = thetae-273.15 ; [C]
>> return(thetae)
>> end
>>
>> contour_t2 = wrf_contour(a,wks,thetae,opts)
>>
>> plot= wrf_map_overlays(a,wks,(/contour_t2/),pltres ,mpres)
>>
>> end
>>
>> Best
>>
>>
>>
>> Enric
>>
>> *De:* Agud Pique, Enric
>> *Enviat:* dimarts, 24 / maig / 2016 21:17
>> *Per a:* ncl-talk at ucar.edu
>> *Tema:* get some variables from wrf output
>>
>>
>>
>> Hello people,
>>
>>
>>
>> I would like to use wrf_user_getvar or another function in order to get
>> from a wrf filet he following variables:
>>
>>
>>
>> *Temperature on 850 hPa-Level in ºC,*
>>
>> *Geopotential height on 850 hPa-Level *
>>
>> *Relative humidity on 850 hPa-Level *
>>
>>
>>
>> I know how to get the temperature on T2
>>
>> T2 = wrf_user_getvar(a,"T2",0)
>> where a is the wrf file...but in 850hPa?
>>
>>
>>
>> Thank you
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160527/a532604f/attachment.html
More information about the ncl-talk
mailing list