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

Jeff Duda jeffduda319 at gmail.com
Thu Feb 18 15:36:37 EST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20160218/0a01cfc1/attachment.html 


More information about the gradsusr mailing list