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

Michelle Serino mmserino at tamu.edu
Thu Oct 22 16:55:44 MDT 2015


Good afternoon,

I am modifying one of NCAR's scripts (skewt_6.ncl
<http://www.ncl.ucar.edu/Applications/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
<https://www.dropbox.com/s/rdfehu5geoy43mh/ruc2anl_252_20090605_2000_000.grb?dl=0>


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151022/57e18409/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ncl
Type: application/octet-stream
Size: 3480 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151022/57e18409/attachment.obj 


More information about the ncl-talk mailing list