[gradsusr] Setting z level based on 'if' statements

Jeff Duda jeffduda319 at gmail.com
Thu Feb 18 16:44:51 EST 2016


Ah, I see I missed something before.

You have defined inHgt as a field rather than a scalar. It's not a script
variable since you enclosed it in quotes. You'd have to display minHgt at a
single point to get a single value, then use sublin and subwrd to extract
that value and save it as a script variable. Then proceed as before
(keeping the if statements out of quotes).

Jeff

On Thu, Feb 18, 2016 at 3:03 PM, L.B. <bcbass2989 at gmail.com> wrote:

> Jeff, Yes, things are progressing well.
>
> I tried removing the quotes but that didn't seem to work either. I set the
> minHgt to a value myself and tried running the script (that way I knew
> which level it should be), but when I did 'q dims', the z level was still
> at 1. When I ran 'q define', the only defined variable was minHgt. botzlev
> wasn't in the list. That SET error went away, but im not sure if that line
> even ran because the level was still at 1.
>
> *-------*
>
> *William (L.B.) LaForce*Meteorologist
> www.tornadoinsanity.com
>
> On Thu, Feb 18, 2016 at 3:36 PM, Jeff Duda <jeffduda319 at gmail.com> wrote:
>
>> Hey, L.B., glad to see you are back in the game! Hope all is well.
>>
>> If you remove the quotes around the commands within each if statement, I
>> think that will solve your problem. As you have written the code, you are
>> telling grads to define a new field with a constant value of 1, 2, 3,...
>> rather than defining a script variable, which is what you appear to want.
>>
>> Jeff
>>
>> On Thu, Feb 18, 2016 at 2:32 PM, L.B. <bcbass2989 at gmail.com> wrote:
>>
>>> Hello all,
>>>
>>> I am attempting to set the z level from a set of if statements.
>>> Basically I am finding the lowest pressure level of a variable, then using
>>> if statements to match it to the closest level available in the model
>>> output and setting the z level based on that value. I am getting a SET
>>> error when I try to do this. Can I not do it this way? I have posted my
>>> script below:
>>>
>>>
>>> 'minHgt=max(max(PRES0C,lon='lonmin',lon='lonmax'),lat='latmin',lat='latmax')'
>>> 'minHgt=minHgt/100'
>>>
>>> if (minHgt > 1011.63)
>>> 'botzlev = 1'
>>> endif
>>> if (minHgt <= 1011.63 & minHgt > 1005)
>>> 'botzlev = 2'
>>> endif
>>> if (minHgt <= 1005 & minHgt > 995)
>>> 'botzlev = 3'
>>> endif
>>> if (minHgt <= 995 & minHgt > 985)
>>> 'botzlev = 4'
>>> endif
>>> if (minHgt <= 985 & minHgt > 977.5)
>>> 'botzlev = 5'
>>> endif
>>> if (minHgt <= 977.5 & minHgt > 972.5)
>>> 'botzlev = 6'
>>> endif
>>>
>>> .
>>> .
>>> .
>>> .
>>>
>>>
>>> 'set z 'botzlev
>>>
>>>
>>> Any help would be appreciated. Thank You!
>>> *-------*
>>>
>>> *William (L.B.) LaForce*Meteorologist
>>> www.tornadoinsanity.com
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>
>>
>> --
>> Jeff Duda
>> Graduate research assistant
>> 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
>>
>>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Graduate research assistant
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/20160218/8faad646/attachment-0001.html 


More information about the gradsusr mailing list