[gradsusr] Specialized Display Question

Jeff Duda jeffduda319 at gmail.com
Wed Nov 23 13:01:40 EST 2011


To  figure out why you might get a constant 0 field, break the problem
down.  First display theta alone and see what you get.  If that doesn't
look right, perhaps there is an error in the definition (although I would
think the error would pop up in that stage before you could advance).  Then
move onto the last command.  Try displaying just the numerator and just the
denominator.  See what you can find out.

Jeff

On Wed, Nov 23, 2011 at 11:45 AM, Rowell, Mason D.
<Mason.D.Rowell-1 at ou.edu>wrote:

>  Jeff,
>
>  Thanks for the explanation. Your reasons for why CDIFF didn't work was
> exactly what I thought was the problem, and what I anticipated would be the
> problem all along, which is why I came to this user group wondering if it
> would even be possible with grads to display a vertical derivative along
> some fixed level, specific to that level. Your second coding scheme is new
> to me and very useful to know, it certainly opens a lot more windows of
> opportunity having the knowledge.
>
>  I will give your script a whirl, I'm sure the syntax corrections will
> fix the problem. FYI, I tried something like
>
>  'define theta = tmpprs*pow(1000/lev,2/7)'
> 'set lev 850'
> 'd (theta(z+1)-theta(z-1)) / (hgtprs(z+1)-hgtprs(z-1))
>
>  at first but it gave me a constant field of zero. I figured it was
> because theta at the upper level and the lower level was not defined, which
> is why I tried coding it in the way you see provided in my script, where
> I explicitly define theta at the top, bottom, and center. Didn't seem as if
> the vertical deriv. appox. you provide could work without doing it this way.
>
>  Mason
>  ------------------------------
> *From:* gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on
> behalf of Jeff Duda [jeffduda319 at gmail.com]
> *Sent:* Wednesday, November 23, 2011 11:22 AM
>
> *To:* GrADS Users Forum
> *Subject:* Re: [gradsusr] Specialized Display Question
>
>  Mason,
> I "corrected" your script file and reattached it here.  Basically you were
> a little quote-happy with your definitions in the first half of the
> script.  Other than that you coded it in a way that would work.  Hopefully
> you understand why certain variables don't need to be in quotes.
>
> Jeff
>
> On Wed, Nov 23, 2011 at 11:17 AM, Jeff Duda <jeffduda319 at gmail.com> wrote:
>
>> Mason,
>> I haven't looked at your script, but here are the answers to your
>> questions.
>>
>> 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 top section of the
>> variables page <http://www.iges.org/grads/gadoc/variable.html#names> on
>> the Grads site.  Basically, you can use parentheses to tag a field with a
>> spatiotemporal (and/or ensemble) offset or specification.  For example, 'd
>> tmpprs(z+1)' 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, 'd tmpprs(z+1)' will plot
>> temperatures at 800 mb.  'd tmpprs(z-1)' 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:
>> 'set lev 500'
>> 'd hgtprs'
>> 'set lev 1000'
>> 'd mslmamsl'
>>
>> OR
>>
>> 'set lev 500'
>> 'd hgtprs'
>> 'd mslmamsl(lev=1000)'
>>
>> OR
>> (assume lev is set to something other than 500 or 1000)
>> 'd hgtprs(lev=500)'
>> 'd mslmamsl(lev=1000)'
>>
>> Thus, this command: 'd (theta(z+1)-theta(z-1)) /
>> (hgtprs(z+1)-hgtprs(z-1))', tells grads to plot an approximation of the
>> vertical derivative of theta in the same way that CDIFF would do it.  It's
>> just that CDIFF requires a varying vertical dimension if you use Z as the
>> argument, which means you pretty much can'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).
>>
>> 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.
>>
>> Here's my suggestion for how to plot the vertical temperature gradient at
>> 850 mb given NARR data (assuming I remember the variable names):
>>
>> 'set x 1 (whatever last index is)'
>> 'set y 1 (whatever last index is)'
>> 'set lev 1000 (however high you want, but make sure it includes the level
>> above the one you want to view the gradient on)'
>> 'define theta = tmpprs*pow(1000/lev,2/7)'
>> 'set lev 850'
>> 'd (theta(z+1)-theta(z-1)) / (hgtprs(z+1)-hgtprs(z-1))'
>>
>> Jeff
>>
>>
>> On Wed, Nov 23, 2011 at 12:44 AM, Rowell, Mason D. <
>> Mason.D.Rowell-1 at ou.edu> wrote:
>>
>>>  All,
>>>
>>>  Well I appear to still have issues. I can define theta like I
>>> discovered I can, but then I can't just use this in Jeff'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't know why. Script is
>>> attached. Any ideas?
>>>
>>>  Mason
>>>  ------------------------------
>>>  *From:* gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org]
>>> on behalf of Rowell, Mason D. [Mason.D.Rowell-1 at ou.edu]
>>>  *Sent:* Tuesday, November 22, 2011 11:21 PM
>>>
>>> *To:* GrADS Users Forum
>>> *Subject:* Re: [gradsusr] Specialized Display Question
>>>
>>>    Apparently it won'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't have been challenging). Now I just need to confirm that
>>> Jeff's second method for cdiff (given it still doesn'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.
>>>
>>> Mason
>>>  ------------------------------
>>> *From:* gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org]
>>> on behalf of Rowell, Mason D. [Mason.D.Rowell-1 at ou.edu]
>>> *Sent:* Tuesday, November 22, 2011 10:58 PM
>>> *To:* GrADS Users Forum
>>> *Subject:* Re: [gradsusr] Specialized Display Question
>>>
>>>   Jeff,
>>>
>>>  Well the expression given second will work with lev set statically
>>> before entering the command (doesn'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 'Error
>>> from CDIFF:  Specified dimension non varying', 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'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.
>>>
>>>  Mason
>>>  ------------------------------
>>> *From:* gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org]
>>> on behalf of Jeff Duda [jeffduda319 at gmail.com]
>>> *Sent:* Tuesday, November 22, 2011 8:41 PM
>>> *To:* GrADS Users Forum
>>> *Subject:* Re: [gradsusr] Specialized Display Question
>>>
>>>  Mason,
>>> You can use the cdiff command in the z direction to display variables
>>> (unfortunately, you can'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:
>>>
>>> 'd cdiff(theta,z)'
>>> 'd (theta(z+1)-theta(z-1)) / (hgtprs(z+1)-hgtprs(z-1))
>>>
>>> If you want to just view the gradient on one pressure surface, set the
>>> level that surface, then enter the command.
>>>
>>> Jeff
>>>
>>> On Tue, Nov 22, 2011 at 7:54 PM, Rowell, Mason D. <
>>> Mason.D.Rowell-1 at ou.edu> wrote:
>>>
>>>> All,
>>>>
>>>> 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'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't have to be on a
>>>> pressure surface.
>>>>
>>>> Mason
>>>> _______________________________________________
>>>> gradsusr mailing list
>>>> gradsusr at gradsusr.org
>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>
>>>
>>>
>>>
>>> --
>>> Jeff Duda
>>> Grad student - PhD, Meteorology
>>> University of Oklahoma School of Meteorology - Center for Analysis and
>>> Prediction of Storms
>>>
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>
>>
>> --
>> Jeff Duda
>> Grad student - PhD, Meteorology
>> University of Oklahoma School of Meteorology - Center for Analysis and
>> Prediction of Storms
>>
>>
>
>
> --
> Jeff Duda
> Grad student - PhD, Meteorology
> University of Oklahoma School of Meteorology - Center for Analysis and
> Prediction of Storms
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Grad student - PhD, Meteorology
University of Oklahoma School of Meteorology - Center for Analysis and
Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111123/f6d190d5/attachment-0003.html 


More information about the gradsusr mailing list