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

Dennis Shea shea at ucar.edu
Tue Nov 3 21:31:12 MST 2015


The different dimension names returned by 'ncl_filedump' and your
script is due to the fact that your script uses

; force a 'time' dimension
    setfileoption("grb","SingleElementDimensions","Initial_time")

By default, ncl_filedump does not do this. However, the dimension
names will match if you force the time dimension via

%> ncl_filedump -itime ruc....grb

Credit to Dave Brown.


On Fri, Oct 23, 2015 at 11:07 AM, Michelle Serino <mmserino at tamu.edu> wrote:
> Ok, I will install version 6.3.0.  Thank you so much for your prompt help!
>
> 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 10:40 AM, Dennis Shea <shea at ucar.edu> wrote:
>>
>> offline
>>
>> [1] You should upgrade to 6.3.0
>>
>> [2]
>> I have attached a file that contains the 'wind_direction' and
>> 'wind_speed' functions.
>> They may seem rather complicated. In fact, they are! However, to
>> handles 'calm' conditions and various dimension issues the NCL
>> function must ve very robust.
>>
>> load "./wind.ncl"
>>
>> On Fri, Oct 23, 2015 at 9:29 AM, Michelle Serino <mmserino at tamu.edu>
>> wrote:
>> > I apologize for my vagueness.  The error I get is "Undefined identifier:
>> > (wind_direction) is undefined, can't continue."  And I forgot to include
>> > the
>> > fact that I am using version 6.0.0, but I will use the equation in place
>> > of
>> > that function for now.
>> >
>> > 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 10:23 AM, Dennis Shea <shea at ucar.edu> wrote:
>> >>
>> >> I added the following print statement. The 1st 10 values for each
>> >> location are below.
>> >>
>> >>         wspd = sqrt(u^2 + v^2)
>> >>         wdir   = wind_direction(u,v,0)
>> >>
>> >>         print(wspd+"  "+u+"  "+v+"  "+wdir)
>> >>
>> >>
>> >> (0)     location=(37.25,-107.75)  grid=(37.2053,-107.789)
>> >> (0)     17.4863  15.6  7.9  243.142
>> >> (1)     21.3026  19.4  8.8  245.601
>> >> (2)     29.0661  28  7.8  254.434
>> >> (3)     37.2979  35.7  10.8  253.168
>> >> (4)     39.3146  36  15.8  246.304
>> >> (5)     38.2027  33.2  18.9  240.348
>> >> (6)     36.0325  30.3  19.5  237.236
>> >> (7)     34.2118  27.9  19.8  234.638
>> >> (8)     33.1622  26.3  20.2  232.474
>> >> (9)     32.453  25.4  20.2  231.506
>> >> [snip]
>> >> (0)     location=(43.25,-101.75)  grid=(43.1875,-101.65)
>> >> (0)     17.4152  17.3  2  263.405
>> >> (1)     23.0235  22.8  -3.2  277.989
>> >> (2)     29.3097  29.1  -3.5  276.858
>> >> (3)     43.9915  43.8  -4.1  275.348
>> >> (4)     46.5897  46.4  -4.2  275.172
>> >> (5)     41.3241  41.2  -3.2  274.441
>> >> (6)     37.191  37.1  -2.6  274.009
>> >> (7)     34.8695  34.8  -2.2  273.617
>> >> (8)     32.9439  32.9  -1.7  272.958
>> >> (9)     31.1315  31.1  -1.4  272.578
>> >>
>> >>
>> >> =====
>> >>
>> >>
>> >> When you say error you never specified  the specific error message.
>> >>
>> >> Was it something like ' wind_direction' not found?
>> >> The 'wind_direction' function  was introduced with NCL 6.1.0. Perhaps
>> >> you have an old version of NCL. The current release is 6.3.0
>> >>
>> >> wdir = atan2(u,v)*57.29579 + 180
>> >>
>> >> On Fri, Oct 23, 2015 at 8:46 AM, Michelle Serino <mmserino at tamu.edu>
>> >> wrote:
>> >> > 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
>> >> >>> >>
>> >> >>
>> >> >>
>> >> >
>> >
>> >
>
>


More information about the ncl-talk mailing list