Mason,<br>I haven&#39;t looked at your script, but here are the answers to your questions.<br><br>You got the error from CDIFF when setting lev statically because it needs the vertical dimension to be varying in order to work.  On the other hand, typing the expression in manually does not require the vertical dimension to vary.  To see why this works, look through the <a href="http://www.iges.org/grads/gadoc/variable.html#names">top section of the variables page</a> on the Grads site.  Basically, you can use parentheses to tag a field with a spatiotemporal (and/or ensemble) offset or specification.  For example, &#39;d tmpprs(z+1)&#39; tells Grads to plot tmpprs one vertical level away from where the current vertical dimension is set (this works for both fixed and varying vertical dimension settings).  So if you have two pressure levels at 850 and 800 mb, if your lev is set to 850, &#39;d tmpprs(z+1)&#39; will plot temperatures at 800 mb.  &#39;d tmpprs(z-1)&#39; plots tmpprs one level down.  You can specify the level, too.  Say you want to plot 500 mb heights and MSLP.  The following lines of code to do that are equivalent:<br>
&#39;set lev 500&#39;<br>&#39;d hgtprs&#39;<br>&#39;set lev 1000&#39;<br>&#39;d mslmamsl&#39;<br><br>OR<br><br>&#39;set lev 500&#39;<br>&#39;d hgtprs&#39;<br>&#39;d mslmamsl(lev=1000)&#39;<br><br>OR<br>(assume lev is set to something other than 500 or 1000)<br>
&#39;d hgtprs(lev=500)&#39;<br>&#39;d mslmamsl(lev=1000)&#39;<br><br>Thus, this command: &#39;d (theta(z+1)-theta(z-1)) / (hgtprs(z+1)-hgtprs(z-1))&#39;, tells grads to plot an approximation of the vertical derivative of theta in the same way that CDIFF would do it.  It&#39;s just that CDIFF requires a varying vertical dimension if you use Z as the argument, which means you pretty much can&#39;t use it to display a vertical derivative on a single pressure surface in a horizontal cross section (sorry, that just came to me, so I apologize for the confusion).<br>
<br>To compute potential temperature using the formula you have, use the pow() function instead of the carrot.  Thus, potprs = tmpprs*pow(1000/lev,2/7) (with your vertical dimension varying over all the levels you want to have potential temperature defined) will give you a grid of potential temperatures.<br>
<br>Here&#39;s my suggestion for how to plot the vertical temperature gradient at 850 mb given NARR data (assuming I remember the variable names):<br><br>&#39;set x 1 (whatever last index is)&#39;<br>&#39;set y 1 (whatever last index is)&#39;<br>
&#39;set lev 1000 (however high you want, but make sure it includes the level above the one you want to view the gradient on)&#39;<br>&#39;define theta = tmpprs*pow(1000/lev,2/7)&#39;<br>&#39;set lev 850&#39;<br>&#39;d (theta(z+1)-theta(z-1)) / (hgtprs(z+1)-hgtprs(z-1))&#39;<br>
<br>Jeff<br><br><div class="gmail_quote">On Wed, Nov 23, 2011 at 12:44 AM, Rowell, Mason D. <span dir="ltr">&lt;<a href="mailto:Mason.D.Rowell-1@ou.edu">Mason.D.Rowell-1@ou.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">





<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">All,
<div><br>
</div>
<div>Well I appear to still have issues. I can define theta like I discovered I can, but then I can&#39;t just use this in Jeff&#39;s vertical derivative expression (the one that will work), given that its value at z+1 and z-1 is not defined. I thought I was being
 clever getting around that, but it claims I am not setting lev right, and I don&#39;t know why. Script is attached. Any ideas?</div>
<div><br>
</div>
<div>Mason <br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><div class="im"><b>From:</b> <a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a> [<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>] on behalf of Rowell, Mason D. [<a href="mailto:Mason.D.Rowell-1@ou.edu" target="_blank">Mason.D.Rowell-1@ou.edu</a>]<br>

</div><b>Sent:</b> Tuesday, November 22, 2011 11:21 PM<div><div></div><div class="h5"><br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Specialized Display Question<br>
</div></div></font><br>
</div><div><div></div><div class="h5">
<div></div>
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Apparently it won&#39;t take lev in my potential temp expression, even though it is set to the right lev I need, but If I define hgt = 850 for example, use that to set lev, then use hgt
 in my expression, it takes it. The issue with defining potential temp. from NARR data is solved then (I knew it shouldn&#39;t have been challenging). Now I just need to confirm that Jeff&#39;s second method for cdiff (given it still doesn&#39;t take the first method provided)
 does indeed approximate the vertical deriv. for the central level, as I would assume it does if I know the method like I think I do.
<div><br>
<div>Mason <br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>From:</b> <a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a> [<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>] on behalf of Rowell, Mason D. [<a href="mailto:Mason.D.Rowell-1@ou.edu" target="_blank">Mason.D.Rowell-1@ou.edu</a>]<br>

<b>Sent:</b> Tuesday, November 22, 2011 10:58 PM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Specialized Display Question<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Jeff,
<div><br>
</div>
<div>Well the expression given second will work with lev set statically before entering the command (doesn&#39;t make sense to me to enter it after given the level about which to compute a central difference would have to be known first), but the first expression
 (w/ lev first set) gives &#39;Error from CDIFF:  Specified dimension non varying&#39;, which is what I thought I would get out of cdiff given lev is set statically. Though the second command may suffice for my purposes. As I said I was able to get it to work, after
 having set lev, so I assume the display is appropriate for the lev I choose and no other (I&#39;d imagine it would have to be if the expression is working as it appears, that is the central difference about the set lev, with this approximation valid for the state
 of the derivative at the center, ie the level about which the central difference is computed). The syntax is new to me so it is good to learn. Now I just need to get a potential temperature expression to display for me.</div>

<div><br>
</div>
<div>Mason </div>
<div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>From:</b> <a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a> [<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>] on behalf of Jeff Duda [<a href="mailto:jeffduda319@gmail.com" target="_blank">jeffduda319@gmail.com</a>]<br>

<b>Sent:</b> Tuesday, November 22, 2011 8:41 PM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Specialized Display Question<br>
</font><br>
</div>
<div></div>
<div>Mason,<br>
You can use the cdiff command in the z direction to display variables (unfortunately, you can&#39;t use it to define variables).  However, you can approximate the vertical derivative by copying the method that cdiff uses.  If you have geopotential height, then
 you have all you need to compute a vertical derivative with respect to height coordinates.  You can display the vertical derivative of theta by either of the following:<br>
<br>
&#39;d cdiff(theta,z)&#39;<br>
&#39;d (theta(z+1)-theta(z-1)) / (hgtprs(z+1)-hgtprs(z-1))<br>
<br>
If you want to just view the gradient on one pressure surface, set the level that surface, then enter the command.<br>
<br>
Jeff<br>
<br>
<div class="gmail_quote">On Tue, Nov 22, 2011 at 7:54 PM, Rowell, Mason D. <span dir="ltr">
&lt;<a href="mailto:Mason.D.Rowell-1@ou.edu" target="_blank">Mason.D.Rowell-1@ou.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
All,<br>
<br>
Is it possible to display the vertical derivative of some quantity (like say temp or potential temp) on a pressure surface? I know I have height in my NARR data, but it is specific to a pressure level (i.e. HGTprs). What I would need is the height just above
 the current pressure level and below it in order to get cdiff of say theta and z. I&#39;m not sure how to set the dimensions to do this...I would be okay with just getting this quantity for display at some level height, it doesn&#39;t have to be on a pressure surface.<br>

<br>
Mason<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
Jeff Duda<br>
Grad student - PhD, Meteorology<br>
University of Oklahoma School of Meteorology - Center for Analysis and Prediction of Storms<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</div>
</div>

<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Jeff Duda<br>Grad student - PhD, Meteorology<br>University of Oklahoma School of Meteorology - Center for Analysis and Prediction of Storms<br><br>