[ncl-talk] Error in Skew-T Plotting Script

Dennis Shea shea at ucar.edu
Thu Oct 22 17:36:11 MDT 2015


There appears to be a naming error.

When I do

%> ncl_filedump ruc2anl_252_20090605_2000_000.grb | less

I get the variable names you use.

===

When I execute your script I ran into errors. I inserted a

f = addfile(...)
print(f)                ; should match ncl_filedump BUT they don't
... NCL need to fix

The variable names and dimension names are changed from the ncl_filedump.

I will fill out a JIRA ticket.

However, we can use the variable names from the 'print(f)', the script
works correctly.


===
See attached





On Thu, Oct 22, 2015 at 4:55 PM, Michelle Serino <mmserino at tamu.edu> wrote:
> Good afternoon,
>
> I am modifying one of NCAR's scripts (skewt_6.ncl) to plot a skew-T with
> RUC2 Analysis data in grib1 format.  I have modified the script accordingly
> to reflect the change in file type and to apply to the case I am studying,
> but most everything else I have left as it was originally.  I am receiving
> an error that, after some extensive research and attempts, I have been
> unable to fix, so I appreciate any help that anyone can provide.
>
> My code:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/skewt_func.ncl"
>
>
> begin
>
>
> ; --- Read RUC GRIB file------------;
>
>     dir  = "/atmomounts/home/grad/mserino/Desktop/"
>
>     fil  = "ruc2anl_252_20090605_2000_000.grb"
>
>
>     ; force a 'time' dimension
>
>     setfileoption("grb","SingleElementDimensions","Initial_time")
>
>
>     f     = addfile(dir+fil,"r")
>
>     p     = int2flt(f->lv_ISBL2)               ;  ( lv_ISBL2 )
>
>     time  = f->initial_time0_encoded  ; yyyymmddhh.hh_frac
>
>
>     ; RUC grid point locations
>
>     lat2d = f->gridlat_252              ; ( ygrid_0, xgrid_0 )
>
>     lon2d = f->gridlon_252
>
>     print("lat2d: min="+min(lat2d)+"  ;  max="+max(lat2d))
>
>     print("lon2d: min="+min(lon2d)+"  ;  max="+max(lon2d))
>
>
>     ;p     = p*0.01                    ; change units
>
>     p at units = "hPa"                   ; skewT, mixhum_ptrh use mb (hPa)
>
>
>     ; --- Specify one or more locations
>
>
>     lat   = (/ 37.25    , 43.25 /)
>
>     lon   = (/-107.75 ,-101.75   /)
>
>     npts  = dimsizes(lat)
>
>
>     ; create plot(s)
>
>
>     skewtOpts                 = True
>
>     skewtOpts at DrawColAreaFill = True    ; default is False
>
>
>     dataOpts   = True
>
>     dataOpts at PrintZ = True
>
>
>     do n=0,npts-1           ; loop over each grid pt
>
>
>         ; find grid point nearest the user specified location
>
>         nm  = getind_latlon2d (lat2d,lon2d, lat(n), lon(n))
>
>         nn  = nm(0,0)
>
>         mm  = nm(0,1)
>
>         print("location=("+lat(n)+","+lon(n)+")
> grid=("+lat2d(nn,mm)+","+lon2d(nn,mm)+")")
>
>
>
>         tk   = f->TMP_252_ISBL(0,:,nn,mm)
>
>         z    = f->HGT_P0_252_ISBL(0,:,nn,mm)
>
>         rh   = f->R_H_P0_252_ISBL(0,:,nn,mm)
>
>         u    = f->U_GRD_252_ISBL(0,:,nn,mm)
>
>         v    = f->V_GRD_252_ISBL(0,:,nn,mm)
>
>
>         ; change units and calculate needed variables
>
>         tc   = tk - 273.15
>
>         tc at units= "degC"
>
>
>         q    = mixhum_ptrh (p, tk, rh, 2)
>
>         q at units = "kg/kg"
>
>
>         tdc  = dewtemp_trh(tk,rh) - 273.15
>
>         tdc at units = "degC"
>
>
>         wspd = sqrt(u^2 + v^2)
>
>         wdir = wind_direction(u,v,0)
>
>
>         itime= toint(time)
>
>         skewtOpts at tiMainString    = "RUC: "+itime+":
> ("+lat(n)+","+lon(n)+")"
>
>
>         ; each location will have a different file name
>
>         wks  = gsn_open_wks ("png",
> "ruc2anl_skewt_"+itime+"_"+sprinti("%0.3i",n))
>
>         skewt_bkgd = skewT_BackGround (wks, skewtOpts)
>
>         skewt_data = skewT_PlotData   (wks, skewt_bkgd, p,tc,tdc,z,
> wspd,wdir, dataOpts)
>
>         draw (skewt_bkgd)
>
>         draw (skewt_data)
>
>         frame(wks)
>
>     end do
>
>
> end
>
>
> The error I get regards the lines in red:
>
> Either file (f) isn't defined or variable (lv_ISBL2) is not a variable in
> the file
>
>
> The correct file, f, is defined because I am able to print its contents.
> The variable "lv_ISBL2" is also a defined variable in the file, so I am not
> sure why it is not recognized.  My code is attached, and the RUC2 data are
> available at the link below.  Thank you again, and I look forward to hearing
> from you.
>
>
> ruc2anl_252_20090605_2000_000.grb
>
>
> Best regards,
>
>
> Michelle Serino
> M.S. Candidate
> Texas A&M University
> Atmospheric Sciences Dept.
> Eller O&M, Suite 1017
> College Station, TX 77843
> (484) 769-0949
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ruc2anl_skewt_2009060520_001.png
Type: image/png
Size: 200104 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151022/5dd19068/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ruc2anl_skewt_2009060520_000.png
Type: image/png
Size: 202294 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151022/5dd19068/attachment-0003.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ncl
Type: application/octet-stream
Size: 3500 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151022/5dd19068/attachment-0001.obj 


More information about the ncl-talk mailing list