[ncl-talk] Error in Skew-T Plotting Script
Michelle Serino
mmserino at tamu.edu
Fri Oct 23 08:46:06 MDT 2015
For reference, this error is regarding the line that says, "wdir =
f->wind_direction(u,v,0)."
Michelle Serino
M.S. Candidate
Texas A&M University
Atmospheric Sciences Dept.
Eller O&M, Suite 1017
College Station, TX 77843
(484) 769-0949
On Fri, Oct 23, 2015 at 9:39 AM, Michelle Serino <mmserino at tamu.edu> wrote:
> Thank you for your quick reply! To clarify, what did you accomplish by
> submitting the JIRA ticket? Also, when I run your modified script, I am
> now getting an error that some vector subscripts need to be integers. Did
> you run into this as well?
>
> Thanks again,
>
> Michelle
>
> Michelle Serino
> M.S. Candidate
> Texas A&M University
> Atmospheric Sciences Dept.
> Eller O&M, Suite 1017
> College Station, TX 77843
> (484) 769-0949
>
> On Thu, Oct 22, 2015 at 6:55 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> My speculation is that different grib tables are being accessed.
>>
>> JIRA-2297
>>
>> On Thu, Oct 22, 2015 at 5:36 PM, Dennis Shea <shea at ucar.edu> wrote:
>> > 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 --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151023/db44ebb1/attachment.html
More information about the ncl-talk
mailing list