<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&#39;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 &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;</p><p style="margin:0px;font-size:11px;font-family:Menlo">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</p><p style="margin:0px;font-size:11px;font-family:Menlo">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/skewt_func.ncl&quot;</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  = &quot;/atmomounts/home/grad/mserino/Desktop/&quot;</p><p style="margin:0px;font-size:11px;font-family:Menlo">    fil  = &quot;ruc2anl_252_20090605_2000_000.grb&quot;</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 &#39;time&#39; dimension</p><p style="margin:0px;font-size:11px;font-family:Menlo">    setfileoption(&quot;grb&quot;,&quot;SingleElementDimensions&quot;,&quot;Initial_time&quot;)</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,&quot;r&quot;)</font></p><p style="margin:0px;font-size:11px;font-family:Menlo">    <font color="#ff0000">p     = int2flt(f-&gt;lv_ISBL2)               ;  ( lv_ISBL2 )</font></p><p style="margin:0px;font-size:11px;font-family:Menlo">    time  = f-&gt;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-&gt;gridlat_252              ; ( ygrid_0, xgrid_0 )</p><p style="margin:0px;font-size:11px;font-family:Menlo">    lon2d = f-&gt;gridlon_252</p><p style="margin:0px;font-size:11px;font-family:Menlo">    print(&quot;lat2d: min=&quot;+min(lat2d)+&quot;  ;  max=&quot;+max(lat2d))</p><p style="margin:0px;font-size:11px;font-family:Menlo">    print(&quot;lon2d: min=&quot;+min(lon2d)+&quot;  ;  max=&quot;+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 = &quot;hPa&quot;                   ; 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(&quot;location=(&quot;+lat(n)+&quot;,&quot;+lon(n)+&quot;)  grid=(&quot;+lat2d(nn,mm)+&quot;,&quot;+lon2d(nn,mm)+&quot;)&quot;)</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-&gt;TMP_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">        z    = f-&gt;HGT_P0_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">        rh   = f-&gt;R_H_P0_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">        u    = f-&gt;U_GRD_252_ISBL(0,:,nn,mm)</p><p style="margin:0px;font-size:11px;font-family:Menlo">        v    = f-&gt;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= &quot;degC&quot;</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 = &quot;kg/kg&quot;</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 = &quot;degC&quot;</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    = &quot;RUC: &quot;+itime+&quot;: (&quot;+lat(n)+&quot;,&quot;+lon(n)+&quot;)&quot;</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 (&quot;png&quot;, &quot;ruc2anl_skewt_&quot;+itime+&quot;_&quot;+sprinti(&quot;%0.3i&quot;,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&#39;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 &quot;lv_ISBL2&quot; 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&amp;M University</span><br></div><div>Atmospheric Sciences Dept.</div><div>Eller O&amp;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>