<div dir="ltr">Good afternoon,<br><div class="gmail_quote"><div dir="ltr"><div style="font-size:13px"><br></div><div style="font-size:13px">I am modifying one of NCAR's scripts (<a href="http://www.ncl.ucar.edu/Applications/Scripts/skewt_6.ncl" target="_blank">skewt_6.ncl</a>) 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.</div><div style="font-size:13px"><br></div><div><u><font face="arial, helvetica, sans-serif">My code:</font></u></div><div style="font-size:13px"><br></div><div style="font-size:13px"><p style="margin:0px;font-size:11px;font-family:Menlo">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</p><p style="margin:0px;font-size:11px;font-family:Menlo">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</p><p style="margin:0px;font-size:11px;font-family:Menlo">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/skewt_func.ncl"</p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">begin</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">; --- Read RUC GRIB file------------;</p><p style="margin:0px;font-size:11px;font-family:Menlo">  dir = "/atmomounts/home/grad/mserino/Desktop/"</p><p style="margin:0px;font-size:11px;font-family:Menlo">  fil = "ruc2anl_252_20090605_2000_000.grb"</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  ; force a 'time' dimension</p><p style="margin:0px;font-size:11px;font-family:Menlo">  setfileoption("grb","SingleElementDimensions","Initial_time")</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  <font color="#ff0000">f   = addfile(dir+fil,"r")</font></p><p style="margin:0px;font-size:11px;font-family:Menlo">   <font color="#ff0000">p   = int2flt(f->lv_ISBL2)        ; ( lv_ISBL2 )</font></p><p style="margin:0px;font-size:11px;font-family:Menlo">  time = f->initial_time0_encoded ; yyyymmddhh.hh_frac</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  ; RUC grid point locations</p><p style="margin:0px;font-size:11px;font-family:Menlo">  lat2d = f->gridlat_252       ; ( ygrid_0, xgrid_0 )</p><p style="margin:0px;font-size:11px;font-family:Menlo">  lon2d = f->gridlon_252</p><p style="margin:0px;font-size:11px;font-family:Menlo">  print("lat2d: min="+min(lat2d)+" ; max="+max(lat2d))</p><p style="margin:0px;font-size:11px;font-family:Menlo">  print("lon2d: min="+min(lon2d)+" ; max="+max(lon2d))</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  ;p   = p*0.01          ; change units</p><p style="margin:0px;font-size:11px;font-family:Menlo">  p@units = "hPa"          ; skewT, mixhum_ptrh use mb (hPa)</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  ; --- Specify one or more locations</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  lat  = (/ 37.25  , 43.25 /)</p><p style="margin:0px;font-size:11px;font-family:Menlo">  lon  = (/-107.75 ,-101.75  /)</p><p style="margin:0px;font-size:11px;font-family:Menlo">  npts = dimsizes(lat)</p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  ; create plot(s)</p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  skewtOpts         = True</p><p style="margin:0px;font-size:11px;font-family:Menlo">  skewtOpts@DrawColAreaFill = True  ; default is False</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  dataOpts  = True</p><p style="margin:0px;font-size:11px;font-family:Menlo">  dataOpts@PrintZ = True</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">  do n=0,npts-1      ; loop over each grid pt</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    ; find grid point nearest the user specified location</p><p style="margin:0px;font-size:11px;font-family:Menlo">    nm = getind_latlon2d (lat2d,lon2d, lat(n), lon(n))</p><p style="margin:0px;font-size:11px;font-family:Menlo">    nn = nm(0,0)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    mm = nm(0,1)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    print("location=("+lat(n)+","+lon(n)+") grid=("+lat2d(nn,mm)+","+lon2d(nn,mm)+")")</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    tk  = f->TMP_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    z  = f->HGT_P0_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    rh  = f->R_H_P0_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    u  = f->U_GRD_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    v  = f->V_GRD_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    ; change units and calculate needed variables</p><p style="margin:0px;font-size:11px;font-family:Menlo">    tc  = tk - 273.15</p><p style="margin:0px;font-size:11px;font-family:Menlo">    tc@units= "degC"</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    q  = mixhum_ptrh (p, tk, rh, 2)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    q@units = "kg/kg"</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    tdc = dewtemp_trh(tk,rh) - 273.15</p><p style="margin:0px;font-size:11px;font-family:Menlo">    tdc@units = "degC"</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    wspd = sqrt(u^2 + v^2)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    wdir = wind_direction(u,v,0)</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    itime= toint(time)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    skewtOpts@tiMainString  = "RUC: "+itime+": ("+lat(n)+","+lon(n)+")"</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">    ; each location will have a different file name</p><p style="margin:0px;font-size:11px;font-family:Menlo">    wks = gsn_open_wks ("png", "ruc2anl_skewt_"+itime+"_"+sprinti("%0.3i",n))</p><p style="margin:0px;font-size:11px;font-family:Menlo">    skewt_bkgd = skewT_BackGround (wks, skewtOpts)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    skewt_data = skewT_PlotData  (wks, skewt_bkgd, p,tc,tdc,z, wspd,wdir, dataOpts)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    draw (skewt_bkgd)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    draw (skewt_data)</p><p style="margin:0px;font-size:11px;font-family:Menlo">    frame(wks)</p><p style="margin:0px;font-size:11px;font-family:Menlo">  end do</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">
</p><p style="margin:0px;font-size:11px;font-family:Menlo">end</p></div><div style="font-size:13px"><br></div><div><u><font face="arial, helvetica, sans-serif">The error I get regards the lines in red:</font></u></div><div style="font-size:13px"><br></div><div style="font-size:13px"><p style="margin:0px;font-size:11px;font-family:Menlo">Either file (f) isn't defined or variable (lv_ISBL2) is not a variable in the file</p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px"><font face="arial, helvetica, sans-serif">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.</font></p><p style="margin:0px"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px"><font face="arial, helvetica, sans-serif"><a href="https://www.dropbox.com/s/rdfehu5geoy43mh/ruc2anl_252_20090605_2000_000.grb?dl=0" target="_blank">ruc2anl_252_20090605_2000_000.grb</a><br></font></p><p style="margin:0px"><font face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px"><font face="arial, helvetica, sans-serif">Best regards,</font></p><p style="margin:0px"><br></p></div><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Michelle Serino<div>M.S. Candidate</div><div><span style="font-size:small">Texas A&M University</span><br></div><div>Atmospheric Sciences Dept.</div><div>Eller O&M, Suite 1017</div><div>College Station, TX 77843<br></div><div>(484) 769-0949</div></div></div></div></div></div></div></div></div></div>
</div>
</div><br></div>