<div>Dear Robert,</div>
<div>&nbsp;</div>
<div>I thank you for your suggestion.</div>
<div>&nbsp;</div>
<div>I did it&nbsp;the way shown below, but it did not work either!</div>
<div>Any other suggestion?</div>
<div>&nbsp;</div>
<div>Thanks in advance.</div>
<div>Eduardo.</div>
<div>__</div>
<div>&nbsp;</div>
<div>&#39;reinit&#39;</div>
<p>&#39;sdfopen d:\ncep-ncar\uwnd.mon.mean.nc&#39;<br>&#39;sdfopen d:\ncep-ncar\air.mon.mean.nc&#39;<br></p>
<p>&#39;set lon -180 0&#39; <br>&#39;set lat 0 90&#39; <br>&#39;set lev 1050 10&#39; <br>&#39;set t 1&#39; </p>
<p>&#39;define uisen=&#39;isen(uwnd.1,air.2,lev,320)</p>
<p>&quot;set z 1&quot;<br>&#39;set t 1&#39;</p>
<p>&quot;d uisen&quot;<br></p>
<div>___</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">2008/3/28, Robert Hart &lt;<a href="mailto:rhart@fsu.edu">rhart@fsu.edu</a>&gt;:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Eduardo,<br><br>The problem is possibly that you are defining&nbsp;&nbsp;PP, u, and v only at the lowest level, since<br>
the initial dimension environment opens the files with z=1, and you immediately define<br>the new variables in that environment.<br><br>Change your script to this, and it should work:<br><br>&#39;sdfopen d:\ncep-ncar\uwnd.mon.mean.nc&#39;<br>
&#39;sdfopen d:\air.mon.mean.nc&#39;<br><br>&quot;define uisen=&quot;isen(uwnd.1,air.2,lev,320)<br>&quot;d uisen&quot;<br><br>Bob Hart<br>FSU Meteorology<br><br><br>----- Original Message -----<br>From: Eduardo Agosta Scarel &lt;<a href="mailto:eduardo.agosta@GMAIL.COM">eduardo.agosta@GMAIL.COM</a>&gt;<br>
Date: Friday, March 28, 2008 5:56 pm<br>Subject: use of the script <a href="http://isen.gs">isen.gs</a><br>To: <a href="mailto:GRADSUSR@LIST.CINECA.IT">GRADSUSR@LIST.CINECA.IT</a><br><br>&gt; Hello everybody!<br>&gt;<br>&gt; I am trying to use the script <a href="http://isen.gs">isen.gs</a> to interpolate a variable field<br>
&gt; on isentropic surface but the final result is that&nbsp;&nbsp;there are no<br>&gt; griddedvalues to interpolate. Perhaps the problem is the use of<br>&gt; &#39;lev&#39; instead of<br>&gt; pressure values? How to solve it?<br>&gt;<br>
&gt; What did I do wrong?<br>&gt;<br>&gt; Please any suggestion to use the script will be much appreciated.<br>&gt;<br>&gt; Eduardo<br>&gt;<br>&gt; Below follows the main script used to test it.<br>&gt;<br>&gt;<br>&gt;<br>
&gt; &#39;reinit&#39;<br>&gt;<br>&gt; &#39;sdfopen d:\ncep-ncar\uwnd.mon.mean.nc&#39;<br>&gt; &#39;sdfopen d:\air.mon.mean.nc&#39;<br>&gt;<br>&gt;<br>&gt; &#39;define PP =&#39;lev<br>&gt; &#39;define u= uwnd.1&#39;<br>&gt; &#39;define v=vwnd.2&#39;<br>
&gt; &#39;define t= air.3&#39;<br>&gt;<br>&gt; &quot;set lev 1050 150&quot;<br>&gt;<br>&gt; &quot;define uisen=&quot;isen(u,t,PP,320)<br>&gt;<br>&gt; &quot;set z 1&quot;<br>&gt; &quot;d uisen&quot;<br>&gt;<br>&gt;<br>&gt;<br>
&gt; function isen(field,tgrid,pgrid,tlev)<br>&gt; *-------------------------------------------------------------------<br>&gt; ---<br>&gt; * Bob Hart (<a href="mailto:hart@ems.psu.edu">hart@ems.psu.edu</a>) /&nbsp;&nbsp;PSU Meteorology<br>
&gt; * 2/26/1999<br>&gt; *<br>&gt; * 2/26/99 - Fixed a bug that caused the script to crash on<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certain machines.<br>&gt; *<br>&gt; * GrADS function to interpolate within a 3-D grid to a specified<br>&gt; * isentropic level.&nbsp;&nbsp;Can also be used on non-pressure level data, such<br>
&gt; * as sigma or eta-coordinate output where pressure is a function<br>&gt; * of time and grid level.&nbsp;&nbsp;Can be used to create isentropic PV<br>&gt; surfaces* (examples are given at end of documentation just prior to<br>&gt; * function.)<br>
&gt; *<br>&gt; * Advantages:&nbsp;&nbsp;Easy to use, no UDFs.&nbsp;&nbsp;Disadvantages:&nbsp;&nbsp;Can take 5-20<br>&gt; secs.*<br>&gt; * Arguments:<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;field = name of 3-D grid to interpolate<br>&gt; *<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;tgrid = name of 3-D grid holding temperature values (deg K) at<br>
&gt; each*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gridpoint.<br>&gt; *<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;pgrid = name of 3-D grid holding pressure values (mb) at each<br>&gt; gridpoint*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If you are using regular pressure-level data,<br>&gt; this should be<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set to the builtin GrADS variable &#39;lev&#39;.<br>
&gt; *<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;tlev&nbsp;&nbsp;= theta-level (deg K) at which to interpolate<br>&gt; *<br>&gt; * Function returns:&nbsp;&nbsp;defined grid interp holding interpolated values<br>&gt; *<br>&gt; * NOTE:&nbsp;&nbsp;YOU NEED TO INCLUDE A COPY OF THIS FUNCTION IN YOUR SCRIPT<br>
&gt; *<br>&gt; * NOTE:&nbsp;&nbsp;Areas having tlev below bottom level or above upper level<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;will be undefined in output field. Extrapolation is NOT<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;performed!!<br>&gt; *<br>&gt; *-------------------------------------------------------------------<br>
&gt; -----<br>&gt; *<br>&gt; * EXAMPLE FUNCTION CALLS:<br>&gt; *<br>&gt; * Sample variables: u = u-wind in m/s<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v = v-wind in m/s<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; w = vertical velocity<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t = temperature in K<br>
&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PP = pressure data in mb<br>&gt; *<br>&gt; * 1) Display vertical velocity field on 320K surface:<br>&gt; *<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;d &quot;isen(w,t,PP,320)<br>&gt; *<br>&gt; * 2) Create &amp; Display colorized streamlines on 320K surface:<br>
&gt; *<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define u320=&quot;isen(u,t,PP,320)<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define v320=&quot;isen(v,t,PP,320)<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;set z 1&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;set gxout stream&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;d u320;v320;mag(u320,v320)&quot;<br>
&gt; *<br>&gt; * 3) Create &amp; display a 320K isentropic PV surface:<br>&gt; *<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;set lev 1050 150&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define coriol=2*7.29e-5*sin(lat*3.1415/180)&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define dudy=cdiff(u,y)/(111177*cdiff(lat,y))&quot;<br>
&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define<br>&gt; dvdx=cdiff(v,x)/(111177*cdiff(lon,x)*cos(lat*3.1415/180))&quot;*<br>&gt; &quot;define dt=t(z-1)*pow(1000/PP(z-1),0.286)-<br>&gt; t(z+1)*pow(1000/PP(z+1),0.286)&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define dp=100*(PP(z-1)-PP(z+1))&quot;<br>
&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define dtdp=dt/dp&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define part1=&quot;isen(dvdx,t,PP,320)<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define part2=&quot;isen(dudy,t,PP,320)<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define part3=&quot;isen(dtdp,t,PP,320)<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;define pv320=-9.8*(coriol+part1-part2)*part3&quot;<br>
&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;set z 1&quot;<br>&gt; *&nbsp;&nbsp;&nbsp;&nbsp;&quot;d pv320&quot;<br>&gt; *<br>&gt; * PROBLEMS:&nbsp;&nbsp;Send email to Bob Hart (<a href="mailto:hart@ems.psu.edu">hart@ems.psu.edu</a>)<br>&gt; *<br>&gt; *-------------------------------------------------------------------<br>
&gt; ----<br>&gt; *-------------------- BEGINNING OF FUNCTION ------------------------<br>&gt; ----<br>&gt; *-------------------------------------------------------------------<br>&gt; ----<br>&gt;<br>&gt; * Get initial dimensions of dataset so that exit dimensions will be<br>
&gt; * same<br>&gt;<br>&gt; &quot;q dims&quot;<br>&gt; rec=sublin(result,4)<br>&gt; ztype=subwrd(rec,3)<br>&gt; if (ztype = &quot;fixed&quot;)<br>&gt;&nbsp;&nbsp; zmin=subwrd(rec,9)<br>&gt;&nbsp;&nbsp; zmax=zmin<br>&gt; else<br>&gt;&nbsp;&nbsp; zmin=subwrd(rec,11)<br>
&gt;&nbsp;&nbsp; zmax=subwrd(rec,13)<br>&gt; endif<br>&gt;<br>&gt; * Get full z-dimensions of dataset.<br>&gt;<br>&gt; &quot;q file&quot;<br>&gt; rec=sublin(result,5)<br>&gt; zsize=subwrd(rec,9)<br>&gt;<br>&gt; * Determine spatially varying bounding pressure levels for isen<br>
&gt; surface* tabove = theta-value at level above ; tbelow = theta value<br>&gt; at level<br>&gt; * below for each gridpoint<br>&gt;<br>&gt; &quot;set z 1 &quot;zsize<br>&gt; &quot;define theta=&quot;tgrid&quot;*pow(1000/&quot;pgrid&quot;,0.286)&quot;<br>
&gt; &quot;set z 2 &quot;zsize<br>&gt; &quot;define thetam=&quot;tgrid&quot;(z-1)*pow(1000/&quot;pgrid&quot;(z-1),0.286)&quot;<br>&gt; &quot;set z 1 &quot;zsize-1<br>&gt; &quot;define thetap=&quot;tgrid&quot;(z+1)*pow(1000/&quot;pgrid&quot;(z+1),0.286)&quot;<br>
&gt;<br>&gt; &quot;define tabove=0.5*maskout<br>&gt; (theta,theta-&quot;tlev&quot;)+0.5*maskout(theta,&quot;tlev&quot;-thetam)&quot;<br>&gt; &quot;define tbelow=0.5*maskout<br>&gt; (theta,thetap-&quot;tlev&quot;)+0.5*maskout(theta,&quot;tlev&quot;-theta)&quot;<br>
&gt;<br>&gt; * Isolate field values at bounding pressure levels<br>&gt; * fabove = requested field value above isen surface<br>&gt; * fbelow = requested field value below isen surface<br>&gt;<br>&gt; &quot;define fabove=tabove*0+&quot;field<br>
&gt; &quot;define fbelow=tbelow*0+&quot;field<br>&gt;<br>&gt; &quot;set z 1&quot;<br>&gt;<br>&gt; * Turn this 3-D grid of values (mostly undefined) into a 2-D isen<br>&gt; layer<br>&gt; * If more than one layer is valid (rare), take the mean of all the<br>
&gt; * valid levels. Not the best way to deal with the multi-layer issue,<br>&gt; * but works well, rarely if ever impacts output, and is quick.<br>&gt; * Ideally, only the upper most level would be used.&nbsp;&nbsp;However, this<br>
&gt; * is not easily done using current GrADS intrinsic functions.<br>&gt;<br>&gt; &quot;define fabove=mean(fabove,z=1,z=&quot;zsize&quot;)&quot;<br>&gt; &quot;define fbelow=mean(fbelow,z=1,z=&quot;zsize&quot;)&quot;<br>&gt; &quot;define tabove=mean(tabove,z=1,z=&quot;zsize&quot;)&quot;<br>
&gt; &quot;define tbelow=mean(tbelow,z=1,z=&quot;zsize&quot;)&quot;<br>&gt;<br>&gt; * Finally, interpolate linearly in theta and create isen surface.<br>&gt; * Linear interpolation in theta works b/c it scales as height,<br>
&gt; * or log-P, from Poisson equation for pot temp.<br>&gt;<br>&gt; &quot;set z &quot;zmin &quot; &quot; zmax<br>&gt;<br>&gt; &quot;define slope=(fabove-fbelow)/(tabove-tbelow)&quot;<br>&gt; &quot;define b=fbelow-slope*tbelow&quot;<br>
&gt; &quot;define interp=slope*&quot;tlev&quot;+b&quot;<br>&gt;<br>&gt; * variable interp now holds isentropic field and its named it returned<br>&gt; * for use by the user.<br>&gt;<br>&gt; say &quot;Done.&nbsp;&nbsp;Newly defined variable interp has &quot;tlev&quot;K &quot;field&quot;-field.&quot;<br>
&gt;<br>&gt; return(interp)<br>&gt;<br></blockquote></div><br>