Jeff,<br>Try using a two-digit color number (i.e., 00) in the printim command as per the recommendation on the index page for the printim command: <a href="http://www.iges.org/grads/gadoc/gradcomdprintim.html">http://www.iges.org/grads/gadoc/gradcomdprintim.html</a><br>
<br>Jeff<br><br><div class="gmail_quote">On Mon, Nov 8, 2010 at 1:41 PM, Jeff Chabot <span dir="ltr">&lt;<a href="mailto:jsc219@gmail.com">jsc219@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I am using two separate color tables.  For precip:<br><br>*Categorical Rain<br>set rgb 30 210 180 140<br>set rgb 16 107 159 91<br>set rgb 17 90 142 75<br>set rgb 18 74 125 60<br>set rgb 19 58 109 45<br>set rgb 20 41 92 19<br>

set rgb 21 25 75 14<br>set rgb 22 253 248 2<br>set rgb 23 229 188 0<br>set rgb 24 253 149 0<br>set rgb 25 253 0 0<br>set rgb 26 212 0 0<br>set rgb 27 255 0 153<br><br>set clevs 0.01 0.05 0.10 0.25 0.50 1.00 2.00 3.00 4.00 5.00<br>

set ccols 0 16 18 19 20 22 23 24 25 26 27<br><br>For precip type:<br><br>*Categorical Rain<br>set rgb 16 107 159 91<br>set rgb 17 90 142 75<br>set rgb 18 74 125 60<br>set rgb 19 58 109 45<br>set rgb 20 41 92 19<br>set rgb 21 25 75 14<br>

set rgb 22 253 248 2<br>set rgb 23 229 188 0<br>set rgb 24 253 149 0<br>set rgb 25 253 0 0<br>set rgb 26 212 0 0<br>set rgb 27 255 0 153<br><br>*Categorical Freezing Rain<br>set rgb 28 255 188 188<br>set rgb 29 255 172 172<br>

set rgb 30 255 156 156<br>set rgb 31 253 140 140<br>set rgb 32 255 124 124<br>set rgb 33 255 108 108<br>set rgb 34 255 96 96<br>set rgb 35 255 80 80<br>set rgb 36 255 64 56<br>set rgb 37 240 32 128<br>set rgb 38 240 16 255<br>

<br>*Categorical Ice Pellets / Mix<br>set rgb 39 255 200 0<br>set rgb 40 255 180 0<br>set rgb 41 255 160 0<br>set rgb 42 255 140 0<br>set rgb 43 255 124 0<br>set rgb 44 255 108 0<br>set rgb 45 255 96 0<br>set rgb 46 255 80 0<br>

set rgb 47 255 64 0<br>set rgb 48 255 32 0<br>set rgb 49 255 16 0<br><br>*Categorical Snow<br>set rgb 50 4 233 231<br>set rgb 51 0 173 255<br>set rgb 52 0 148 255<br>set rgb 53 0 123 255<br>set rgb 54 0 104 255<br>set rgb 55 0 85 255<br>

set rgb 56 4 67 245<br>set rgb 57 0 38 255<br>set rgb 58 0 14 255<br>set rgb 59 0 0 255<br>set rgb 60 0 0 223<br>set rgb 61 255 255 255<br><br>set clevs 0.01 0.05 0.1 0.25 0.5 1 2 3 4 5 10 10.01 10.05 10.1 10.25 10.5 11 12<br>

13 14 15 20 20.01 20.05 20.1 20.25 20.5 21 22 23 24 25 30 30.01 30.05 30.1 30.25<br> 30.5 31 32 33 34 35<br>set ccols 0 16 18 19 20 22 23 24 25 26 27 0 39 40 41 42 43 44 45 46 47 0 0 28 29<br> 30 31 32 33 34 35 36 0 0 50 51 52 53 54 55 56 57 58 59<br>

<br>So, Jeff, I believe that I am using #0 correctly.  But, when I do, it just uses white or black as the background as in this example:<br><br><a href="http://jeffsweatherservice.com/grads/nam/ptype_NE_2.gif" target="_blank">http://jeffsweatherservice.com/grads/nam/ptype_NE_2.gif</a>  <br>

<br>Thanks,<br><br><br>Jeff<br><br><br><br><div class="gmail_quote">On Mon, Nov 8, 2010 at 10:18 AM,  <span dir="ltr">&lt;<a href="mailto:gradsusr-request@gradsusr.org" target="_blank">gradsusr-request@gradsusr.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Send gradsusr mailing list submissions to<br>
        <a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<div class="im"><br>
        <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br></div>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:gradsusr-request@gradsusr.org" target="_blank">gradsusr-request@gradsusr.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:gradsusr-owner@gradsusr.org" target="_blank">gradsusr-owner@gradsusr.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of gradsusr digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. GrADS help,       plotting shaded contour precip/ptype products<br>
      over a    basemap/background (Jeff Chabot)<br>
   2. Re: GrADS help, plotting shaded contour precip/ptype products<br>
      over a basemap/background (Jeffrey Duda)<br>
   3. Problem with skewt plot using WRF output (Cristian ...)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 8 Nov 2010 13:51:33 -0500<br>
From: Jeff Chabot &lt;<a href="mailto:jsc219@gmail.com" target="_blank">jsc219@gmail.com</a>&gt;<br>
Subject: [gradsusr] GrADS help, plotting shaded contour precip/ptype<br>
        products over a basemap/background<br>
To: <a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
Message-ID:<br>
        &lt;AANLkTinKn=<a href="mailto:eTr6myE00LdycRWRxdyy5e8hpBtf%2BFgLPz@mail.gmail.com" target="_blank">eTr6myE00LdycRWRxdyy5e8hpBtf+FgLPz@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<div class="im"><br>
<br>
Dear GrADS Users,<br>
I have been trying to apply a basemap to my precip/ptype shaded contour<br>
products on my personal website for some time now.  I have brainstormed and<br>
searched the GrADS online documents and have come up with ideas, but they<br>
have never worked.  My latest idea was to use Google Maps terrain data as a<br>
background to the map.  I thought it was a good idea, but I discovered that<br>
I still cannot resolve the issue in that precip = 0 shows either all white<br>
or all black depending on what I choose for the background, covering up my<br>
basemap.  I really thought the following command would have resolved that<br>
issue, but it did not:<br>
<br>
printim precip_NE_1.png png x570 y435 -b NE.png -t 0 Versions:GrADS: 2.0a9<br>
OS: Fedora 13<br>
Sample: <a href="http://jeffsweatherservice.com/grads/nam/ptype_NE_2.png" target="_blank">http://jeffsweatherservice.com/grads/nam/ptype_NE_2.png</a><br>
<br>
I know this can be done because of the example:<br>
<br>
<a href="http://wxmaps.org/pix/ez.east.html" target="_blank">http://wxmaps.org/pix/ez.east.html</a><br>
<br>
Any assistance here would be much appreciated.Sincerely,<br>
<br>
<br>
Jeff Chabot<br>
Email: <a href="mailto:jsc219@gmail.com" target="_blank">jsc219@gmail.com</a><br>
Web: <a href="http://jeffsweatherservice.com" target="_blank">http://jeffsweatherservice.com</a><br></div>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://gradsusr.org/pipermail/gradsusr/attachments/20101108/93f97642/attachment-0001.html" target="_blank">http://gradsusr.org/pipermail/gradsusr/attachments/20101108/93f97642/attachment-0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Mon, 8 Nov 2010 12:57:30 -0600<br>
From: Jeffrey Duda &lt;<a href="mailto:jdduda@iastate.edu" target="_blank">jdduda@iastate.edu</a>&gt;<br>
Subject: Re: [gradsusr] GrADS help, plotting shaded contour<br>
        precip/ptype products over a basemap/background<br>
To: GrADS Users Forum &lt;<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a>&gt;<br>
Message-ID:<br>
        &lt;<a href="mailto:AANLkTikPmH-Og0-6uNAi4tpUMCoZbAZ3YTqm_HXkndpV@mail.gmail.com" target="_blank">AANLkTikPmH-Og0-6uNAi4tpUMCoZbAZ3YTqm_HXkndpV@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<div><div></div><div class="h5"><br>
<br>
Jeff,<br>
What color table are you using?  Are you sure you have a #0 color?  I know<br>
that&#39;s supposed to be the background, but perhaps you are overwriting it<br>
with some other color that has the same color as your background but a<br>
different color number.<br>
<br>
Jeff Duda<br></div></div></blockquote><div><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">
<br>
On Mon, Nov 8, 2010 at 12:51 PM, Jeff Chabot &lt;<a href="mailto:jsc219@gmail.com" target="_blank">jsc219@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Dear GrADS Users,<br>
&gt; I have been trying to apply a basemap to my precip/ptype shaded contour<br>
&gt; products on my personal website for some time now.  I have brainstormed and<br>
&gt; searched the GrADS online documents and have come up with ideas, but they<br>
&gt; have never worked.  My latest idea was to use Google Maps terrain data as a<br>
&gt; background to the map.  I thought it was a good idea, but I discovered that<br>
&gt; I still cannot resolve the issue in that precip = 0 shows either all white<br>
&gt; or all black depending on what I choose for the background, covering up my<br>
&gt; basemap.  I really thought the following command would have resolved that<br>
&gt; issue, but it did not:<br>
&gt;<br>
&gt; printim precip_NE_1.png png x570 y435 -b NE.png -t 0 Versions:GrADS: 2.0a9<br>
&gt; OS: Fedora 13<br>
&gt; Sample: <a href="http://jeffsweatherservice.com/grads/nam/ptype_NE_2.png" target="_blank">http://jeffsweatherservice.com/grads/nam/ptype_NE_2.png</a><br>
&gt;<br>
&gt; I know this can be done because of the example:<br>
&gt;<br>
&gt; <a href="http://wxmaps.org/pix/ez.east.html" target="_blank">http://wxmaps.org/pix/ez.east.html</a><br>
&gt;<br>
&gt; Any assistance here would be much appreciated. Sincerely,<br>
&gt;<br>
&gt;<br>
&gt; Jeff Chabot<br>
&gt; Email: <a href="mailto:jsc219@gmail.com" target="_blank">jsc219@gmail.com</a><br>
&gt; Web: <a href="http://jeffsweatherservice.com" target="_blank">http://jeffsweatherservice.com</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; gradsusr mailing list<br>
&gt; <a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
&gt; <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
--<br>
Jeff Duda<br>
Iowa State University<br>
Meteorology Graduate Student<br>
3134 Agronomy Hall<br>
<a href="http://www.meteor.iastate.edu/%7Ejdduda" target="_blank">www.meteor.iastate.edu/~jdduda</a><br></div></div>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://gradsusr.org/pipermail/gradsusr/attachments/20101108/159827b2/attachment-0001.html" target="_blank">http://gradsusr.org/pipermail/gradsusr/attachments/20101108/159827b2/attachment-0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Mon, 8 Nov 2010 16:23:09 -0300<br>
From: &quot;Cristian ...&quot; &lt;<a href="mailto:galenso85@hotmail.com" target="_blank">galenso85@hotmail.com</a>&gt;<br>
Subject: [gradsusr] Problem with skewt plot using WRF output<br>
To: &lt;<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a>&gt;<br>
Message-ID: &lt;SNT112-W63DF5D09C452E1C6FB44FBF4F0@phx.gbl&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
<br>
Hello,<br>
<br>
My name is Cristian. I am having some troubles to perform some skewt graphics using WRF output.<br>
I have created a binary and .ctl archives using ARWpost.<br>
The file is OK, and no troubles are expected.<br>
<br>
The problem starts when I want to create a skewt graphic.<br>
The temperature and dewpoint profiles are OK, but no information about wind is shown. Neither the Hodograpf, nor the wind speed and direction profiles are shown.<br>
<br>
No message of an error apears, and i have no idea what is happening.<br>
Even the undef value is th same as the .ctl archive.<br>
<br>
I am using Grads version 1.a8, in UBUNTU 9.04.<br>
<br>
Here is the script. I only changed parameters at the top of the archive.<br>
<br>
I really appreciate your help.<br>
<br>
Thanks<br>
<br>
-----------------------------------------------------------------------------------------------------------------------------------------<br>
* Script para construir radiosondeos<br>
<br>
&#39;reinit&#39;<br>
&#39;run /home/cristian/Escritorio/Experimentos/lib/jaecol&#39;<br>
&#39;set display color white&#39;<br>
&#39;reset&#39;<br>
<br>
* Defino el archivo a utilizar<br>
<br>
&#39;open 20081004_YSU.ctl&#39;<br>
*path=&#39;&#39;<br>
<br>
* Latitud Longitud y tiempo<br>
<br>
lat=-46<br>
lon=-68<br>
time=12z04Oct2008<br>
<br>
<br>
&#39;set time &#39;time<br>
&#39;set lon &#39;lon<br>
&#39;set lat &#39;lat<br>
<br>
*Entre que niveles hace el perfil hacerlo entre 1000 y 600<br>
<br>
levmax=925<br>
levmin=500<br>
<br>
&#39;set lev  &#39;levmax &#39; &#39; levmin<br>
<br>
*calculo Td a partir de HR, P y T<br>
*&#39;define et=(-2937.4/(t))-(4.9283*log10(t))+22.5518&#39;<br>
*&#39;define es=pow(10,et)*10&#39;<br>
*&#39;define e=es*0.01*hr&#39;<br>
*&#39;define q=0.622*e/(lev-e)&#39;<br>
*&#39;define aux1=q*1000*(1.+0.81*q)&#39;<br>
*&#39;define aux2=0.2854*(1.-0.28*q)&#39;<br>
*&#39;define aux3=(1000/lev)&#39;<br>
*&#39;define td=243.5/((17.67/(log(e/6.11)))-1)&#39;<br>
*&#39;define tc=t-273&#39;<br>
<br>
&#39;set ylopts 1 5 0.18&#39;<br>
<br>
plotskew(tc,td,u,v)<br>
<br>
&#39;q dims&#39;<br>
line1=sublin(result,4)<br>
line2=sublin(result,5)<br>
itime1=subwrd(line1,6)<br>
itit=substr(itime1,1,6)<br>
itime1=subwrd(line2,6)<br>
itime=substr(itime1,1,12)<br>
d=substr(itime1,4,2)<br>
m=substr(itime1,6,3)<br>
y=substr(itime1,9,4)<br>
h=substr(itime1,1,2)<br>
lati=-1*lat<br>
loni=-1*lon<br>
<br>
&#39;draw title Perfil vertical de T y Td en &#39;lati&#39;S y &#39;loni&#39;W\&#39;itime<br>
&#39;printim &#39;d&#39;.&#39;h&#39;sondeo.png png x600 y800 white&#39;<br>
<br>
function plotskew(sndtemp,snddewp,u,v)<br>
<br>
*El valor Undef que se coloca ac? debe coincidir con el valor undef del CTL, sin? hay problemas<br>
*en la construcci?n de la hod?grafa y del perfil vertical de viento.<br>
undef=1.e30<br>
*************************************************************************<br>
*<br>
* GrADS Script to Plot a SkewT/LogP Diagram<br>
*<br>
* Bob Hart<br>
* Penn State University / Dept of Meteorology<br>
* Last Update:  January 23, 2001<br>
*<br>
* Recent Changes:<br>
*<br>
* 01/23/01 - Fixed a small bug in the theta-e calculation.<br>
*            Errors averaged 0.5-3K.  Thank you George Bryan.<br>
*<br>
* 11/10/99 - Change in calculation method for CAPE/CIN.  Trapezoid<br>
*            integration method is now used.  Speeds up execution<br>
*            by 25%, and increases accuracy by 5-10%.<br>
*<br>
* 10/18/99 - Minor glitch fixed that occasionally caused crash.<br>
*<br>
*  8/26/99 - Datasets with missing data can now be used.<br>
*<br>
* Features:<br>
*   - All features of standard skewt/logp plot<br>
*   - RH sounding<br>
*   - LCL location<br>
*   - Parcel trajectory for both sfc based convection and elevated from<br>
*     most unstable level (highest theta-e level reported)<br>
*   - Stability indices and precipitable water calculations<br>
*   - CAPE &amp; CIN Calculations<br>
*   - Wind Profile<br>
*   - Hodograph / Hodograph scaling<br>
*   - Helicity and SR Helicity Calculations and Display<br>
*   - Color aspects of output<br>
*   - Line Thickness, style aspects of output<br>
*   - Can be run in either PORTRAIT or LANDSCAPE mode.<br>
*<br>
* There are numerous tunable parameters below to change the structure<br>
* and output for the diagram.<br>
*<br>
* Function Arguments:<br>
*    sndtemp - temperature data (Celsius) as a function of pressure<br>
*    snddewp - dewpoint data (Celsius) as a function of pressure<br>
*    sndspd  - wind speed data (knots) as a function of pressure<br>
*    snddir  - wind direction data as a function of pressure<br>
*<br>
* Use &#39;-1&#39; for any of the above 4 arguments to indicate that you<br>
* are not passing that variable.  The appropriate options will<br>
* be ignored based on your specifying &#39;-1&#39; for that variable.<br>
*<br>
* NOTE:  Make sure to set the vertical range of the plot before running.<br>
*        I.e., &quot;SET LEV 1050 150&quot;, for example.   This does not have to<br>
*        be limited to the pressure range of your data.<br>
*<br>
* Labelling:  Pressure/Height is labelled along left side.  Temperature is<br>
*             labelled along bottom.  Mixing ratio is labelled along right<br>
*             side/top.<br>
*<br>
*<br>
* PROBLEMS:  First check out the web page for the script (which also<br>
*            has a link to a FAQ with answers to many common questions<br>
*            about using the script):<br>
*            <a href="http://www.ems.psu.edu/%7Ehart/skew.html" target="_blank">http://www.ems.psu.edu/~hart/skew.html</a><br>
*<br>
* Please send any further problems, comments, or suggestions to<br>
* &lt;<a href="mailto:hart@ems.psu.edu" target="_blank">hart@ems.psu.edu</a>&gt;<br>
*<br>
* ACKNOWLEDGMENTS:  Thanks go to the innumerable users who have helped<br>
* fine tune the script from the horrible mess from which it began.<br>
* In particular, thanks go out to Steve Lord (NCEP), Mike Fiorino (ECMWF),<br>
* George Bryan (PSU), Davide Sacchetti (CMIRL), and Enrico Minguzzi (CMIRL).<br>
*<br>
**************************************************************************<br>
*           !!!!!   BEGINNING OF USER-SPECIFIED OPTIONS  !!!!!!<br>
**************************************************************************<br>
*<br>
* --------------------- Initialization options  ----------------------<br>
*<br>
* ClrScrn = Whether to clear the screen before drawing diagram<br>
*           [1 = yes, 0 = no]<br>
<br>
ClrScrn = 1<br>
<br>
*<br>
* ------------------- Define Skew-T Diagram Shape/Slope-----------------<br>
*<br>
* (P1,T1) = Pres, Temp of some point on left-most side<br>
* (P2,T2) = Pres, Temp of some point on right-most side<br>
* (P3,T3) = Pres, Temp of some point in diagram which is mid-point<br>
*           in the horizontal between 1 and 2.<br>
*<br>
* P1, P2, P3 are in mb ; T1, T2, T3 are in Celsius<br>
*<br>
* These define the SLOPE and WIDTH of the diagram as you see it but DO NOT<br>
* DEFINE THE HEIGHT of the diagram as you see it.  In other words,<br>
* 1 and 2 do NOT necessarily need to be at the bottom of the diagram and<br>
* 3 does NOT necessarily need to be at the top.  THE VERTICAL PRESSURE<br>
* RANGE OF THE SKEWT AS YOU SEE IT IS DETERMINED BY YOUR &#39;SET Z ...&#39;<br>
* COMMAND OR THE &#39;SET LEV ...&#39; COMMAND BEFORE RUNNING THIS SCRIPT.<br>
*<br>
*    _______________________<br>
*   |                       |<br>
*   |                       |<br>
*   |           3           |<br>
*   |                       |<br>
*   |                       |<br>
*   |                       |<br>
*   |                       |<br>
*   |                       |<br>
*   |                       |<br>
*   |                       |<br>
*   |                       |<br>
*   |1                     2|<br>
*   |                       |<br>
*   |_______________________|<br>
*<br>
*<br>
* A good set of defining points are given below.   Feel free<br>
* to experiment with variations.<br>
<br>
<br>
*P1 = 1000<br>
*T1 = -40<br>
<br>
*P2 = 1000<br>
*T2 = 40<br>
<br>
*P3 = 200<br>
*T3 = 0<br>
<br>
* Another good set of defining points suggested by Juan Ruiz (Emagrama)<br>
* are:<br>
*<br>
 P1 = 1000<br>
 T1 = -80<br>
*<br>
 P2 = 1000<br>
 T2 = 40<br>
*<br>
 P3 = 500<br>
 T3 = -20<br>
<br>
* ------------------- Contour Intervals / Levels --------------------------<br>
*<br>
* All variables below are contour intervals/levels for diagram<br>
*<br>
* Thetaint = interval for potential temperature lines<br>
* Thetwint = interval for moist pseudo adiabats<br>
* tempint  = interval for temperature lines<br>
* wsclevs  = contour LEVELS for mixing ratio lines<br>
*<br>
*<br>
thetaint= 20<br>
thetwint= 10<br>
tempint = 10<br>
wsclevs = &quot;.1 .5 1 3 6 10 15 20 25 30&quot;<br>
*<br>
*<br>
* ------------------------ Output Options --------------------------------<br>
*<br>
* All variables below are logical .. 1=yes, 0=no, unless otherwise<br>
* specified.<br>
*<br>
* DrawBarb = Draw wind barbs along right side of plot<br>
* DrawThet = Draw dry adiabats<br>
* DrawThtw = Draw moist pseudo-adiabats<br>
* DrawTemp = Draw temperature lines<br>
* DrawMix  = Draw mixing ratio lines<br>
* DrawTSnd = Draw temperature sounding<br>
* DrawDSnd = Draw dewpoint sounding<br>
* DrawRH   = Draw relative humidity sounding<br>
* DrawPrcl = Draw parcel path from surface upward<br>
* DrawPMax = Draw parcel path from most unstable level upward<br>
* DrawIndx = Display stability indices &amp; CAPE<br>
* DrawHeli = Calculate and display absolute and storm-relative helicity<br>
* DrawHodo = Draw hodograph<br>
* DrawPLev = Draw Pressure Levels<br>
* DrawZLev = Draw height levels and lines<br>
*            0 = no lines<br>
*            1 = above ground level (AGL)<br>
*            2 = above sea level (ASL)<br>
* DrawZSTD = Draw Height levels using standard atm lapse rate<br>
* LblAxes  = Label the x,y axes (temperature, pressure,mixing ratio)<br>
*<br>
* ThtwStop = Pressure level at which to stop drawing Theta-w lines<br>
* MixStop  = Pressure level at which to stop drawing Mixratio lines<br>
<br>
DrawBarb= 1<br>
DrawThet= 1<br>
DrawThtw= 1<br>
DrawTemp= 1<br>
DrawMix = 1<br>
DrawTSnd= 1<br>
DrawDSnd= 1<br>
DrawRH  = 0<br>
DrawPrcl= 1<br>
DrawPMax= 1<br>
DrawIndx= 1<br>
DrawHeli= 0<br>
DrawHodo= 1<br>
DrawPLev= 1<br>
DrawZLev= 0<br>
DrawZSTD= 0<br>
LblAxes = 1<br>
<br>
ThtwStop = 200<br>
MixStop  = 400<br>
<br>
<br>
*<br>
* -----------------  Sounding Geography options ------------------------<br>
*<br>
* SfcElev = Elevation above sea-level (meters) of lowest level reported<br>
*           in sounding.  Used only if DrawZLev = 2<br>
<br>
SfcElev = 0<br>
<br>
<br>
*<br>
* ------------------ Thermodynamic Index Options --------------------<br>
*<br>
* All variables here are in inches.  Use -1 for the default values.<br>
*<br>
*  Text1XC = X-location of midpoint of K,TT,PW output box<br>
*  Text1YC = Y-location of midpoint of K,TT,PW output box<br>
*  Text2XC = X-Location of midpoint of surface indices output box<br>
*  Text2YC = Y-location of midpoint of surface indices output box<br>
*  Text3XC = X-Location of midpoint of most unstable level-based indices<br>
*            output box<br>
*  Text3YC = Y-location of midpoint of most unstable level-based indices<br>
*            output box<br>
<br>
Text1XC = -1<br>
Text1YC = -1<br>
Text2XC = -1<br>
Text2YC = -1<br>
Text3XC = -1<br>
Text3YC = -1<br>
<br>
*<br>
* ----------------- Wind Barb Profile Options ----------------------------<br>
*<br>
* All variables here are in units of inches, unless otherwise specified<br>
*<br>
*  barbint = Interval for plotting barbs (in units of levels)<br>
*  poleloc = X-Location of profile.  Choose -1 for the default.<br>
*  polelen = Length of wind-barb pole<br>
*  Len05   = Length of each 5-knot barb<br>
*  Len10   = Length of each 10-knot barb<br>
*  Len50   = Length of each 50-knot flag<br>
*  Wid50   = Width of base of 50-knot flag<br>
*  Spac50  = Spacing between 50-knot flag and next ror occurred on libarb/flag<br>
*  Spac10  = Spacing between 10-knot flag and next flag<br>
*  Spac05  = Spacing between 5-knot flag and next flag<br>
*  Flagbase= Draw flagbase (filled circle) for each windbarb [1=yes, 0 =no]<br>
*  Fill50  = Solid-fill 50-knot flag [1=yes, 0=no]<br>
*  barbline= Draw a vertical line connecting all the wind barbs [1=yes, 0=no]<br>
*<br>
barbint = 1<br>
poleloc = -1<br>
polelen = 0.35<br>
len05   = 0.07<br>
len10   = 0.15<br>
len50   = 0.15<br>
wid50   = 0.06<br>
spac50  = 0.07<br>
spac10  = 0.05<br>
spac05  = 0.05<br>
Fill50  = 1<br>
flagbase= 1<br>
barbline= 1<br>
<br>
*<br>
*<br>
*---------------- Hodograph Options -------------------------------------<br>
*<br>
* All variables here are in units of inches, unless otherwise specified<br>
*<br>
* HodXcent= x-location of hodograph center.  Use -1 for default location.<br>
* HodYcent= y-location of hodograph center.  Use -1 for default location.<br>
* HodSize = Size of hodograph in inches<br>
* NumRing = Number of rings to place in hodograph (must be at least 1)<br>
* HodRing = Wind speed increment of each hodograph ring<br>
* HodoDep = Depth (above lowest level in mb) of end of hodograph trace<br>
* TickInt = Interval (in kts) at which tick marks are drawn along the axes<br>
*           Use 0 for no tick marks.<br>
* TickSize= Size of tick mark in inches<br>
* Text4XC = X-location of midpoint of hodograph text output. Use -1 for default.<br>
* Text4YC = Y-location of midpoint of hodograph text output. Use -1 for default.<br>
<br>
HodXcent= 6<br>
HodYcent= 9<br>
HodSize = 2<br>
NumRing = 3<br>
HodRing = 10<br>
HodoDep = 500<br>
TickInt = 5<br>
TickSize= 0.1<br>
Text4XC = -1<br>
Text4YC = -1<br>
<br>
*--------------- Helicity Options ---------------------------------------<br>
*<br>
* MeanVTop = Top pressure level (mb) of mean-wind calculation<br>
* MeanVBot = Bottom pressure level (mb) of mean-wind calculation<br>
* HelicDep = Depth in mb (above ground) of helicity integration<br>
* StormMot = Type of storm motion estimation scheme.  Use following:<br>
*            0 = No departure from mean wind.<br>
*            1 = Davies-Jones (1990) approach<br>
* FillArrw = Whether to fill the arrowhead of the storm motion vector<br>
*            [1 = yes, 0 = no]<br>
<br>
MeanVTop= 300<br>
MeanVBot= 850<br>
HelicDep= 300<br>
StormMot= 0<br>
FillArrw= 1<br>
<br>
*<br>
*---------------- Color Options ------------------------------------------<br>
*<br>
* ThetCol = Color of dry adiabats<br>
* TempCol = Color of temperature lines<br>
* MixCol  = Color of mixing ratio lines<br>
* ThtwCol = Color of moist adiabats<br>
* TSndCol = Color of Temperature Sounding<br>
* DSndCol = Color of Dewpoint Sounding<br>
* RHCol   = Color of RH Sounding<br>
* PrclCol = Color of parcel trace<br>
* BarbCol = Color of wind barbs (choose -1 for color according to speed)<br>
* HodoCol = Color of hodograph trace<br>
<br>
ThetCol = 23<br>
TempCol = 79<br>
MixCol  = 38<br>
ThtwCol = 39<br>
TSndCol = 29<br>
DSndCol = 49<br>
RHCol   = 3<br>
PrclCol = 1<br>
BarbCol = 1<br>
HodoCol = 2<br>
<br>
*<br>
*-------------------- Line Style Options ------------------------------------<br>
*<br>
* GrADS Styles: 1=solid;2=long dash;3=short dash;4=long,short dashed;<br>
*               5=dotted;6=dot dash;7=dot dot dash<br>
*<br>
* ThetLine = Line Style of dry adiabats<br>
* TempLine = Line Style of temperature lines<br>
* MixLine  = Line Style of mixing ratio lines<br>
* ThtwLine = Line Style of moist adiabats<br>
* TSndLine = Line Style of Temperature Sounding<br>
* DSndLine = Line Style of Dewpoint Sounding<br>
* RHLine   = Line Style of RH sounding<br>
* PrclLine = Line Style of parcel trace<br>
* HodoLine = Line Style of hodograph trace<br>
*<br>
<br>
ThetLine = 1<br>
TempLine = 1<br>
MixLine  = 5<br>
ThtwLine = 2<br>
TSndLine = 1<br>
DSndLine = 2<br>
RHLine   = 1<br>
PrclLine = 3<br>
HodoLine = 1<br>
<br>
*<br>
*------------------- Line Thickness Options---------------------------------<br>
* GrADS Line Thickness: increases with increasing number. Influences<br>
*                       hardcopy output more strongly than screen output.<br>
*<br>
*<br>
* ThetThk = Line Thickness of dry adiabats<br>
* TempThk = Line Thickness of temperature lines<br>
* MixThk  = Line Thickness of mixing ratio lines<br>
* ThtwThk = Line Thickness of moist adiabats<br>
* TSndThk = Line Thickness of temperature sounding<br>
* DSndThk = Line thickness of dewpoint sounding<br>
* RHThk   = Line thickness of RH sounding<br>
* PrclThk = Line thickness of parcel trace<br>
* HodoThk = Line thickness of hodograph trace<br>
* BarbThk = Line thickness of wind barbs<br>
<br>
ThetThk = 3<br>
TempThk = 1<br>
MixThk  = 7<br>
ThtwThk = 3<br>
TSndThk = 12<br>
DSndThk = 12<br>
RHThk   = 8<br>
PrclThk = 6<br>
HodoThk = 6<br>
BarbThk = 2<br>
<br>
*<br>
*------------------- Data Point Marker Options -----------------------------<br>
* GrADS Marker Types: 0 = none ; 1 = cross ; 2 = open circle ;<br>
*                     3 = closed circle ; 4 = open square ; 5 = closed square<br>
*                     6 = X ; 7 = diamond ; 8 = triangle ; 9 = none<br>
*                    10 = open circle with vertical line ; 11 = open oval<br>
*<br>
* TSndMrk = Mark type of data point marker for temperature sounding<br>
* DSndMrk = Mark type of data point marker for dewpoint sounding<br>
* RHMrk   = Mark type of data point marker for relative humidity sounding<br>
* MrkSize = Mark size (inches) of each data marker<br>
<br>
TSndMrk = 3<br>
DSndMrk = 3<br>
RHMrk   = 0<br>
MrkSize = 0.1<br>
<br>
<br>
* !!!!! YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW HERE !!!!!<br>
****************************************************************************<br>
<br>
*-------------------------------------------<br>
* grab user-specified environment dimensions<br>
*-------------------------------------------<br>
<br>
&quot;q dims&quot;<br>
rec=sublin(result,2)<br>
_xtype=subwrd(rec,3)<br>
_xval=subwrd(rec,9)<br>
rec=sublin(result,3)<br>
_yval=subwrd(rec,9)<br>
_ytype=subwrd(rec,3)<br>
rec=sublin(result,4)<br>
_ptype=subwrd(rec,3)<br>
_pmax=subwrd(rec,6)<br>
_pmin=subwrd(rec,8)<br>
_zmin=subwrd(rec,11)<br>
_zmax=subwrd(rec,13)<br>
rec=sublin(result,5)<br>
_ttype=subwrd(rec,3)<br>
_tval=subwrd(rec,9)<br>
<br>
&quot;q file&quot;<br>
rec=sublin(result,5)<br>
_zmaxfile=subwrd(rec,9)<br>
<br>
*-------------------------------------------------------------<br>
* Check to ensure that dimensions are valid.  Warn &amp; exit if not.<br>
*--------------------------------------------------------------<br>
<br>
dimrc=0<br>
If (_xtype != &quot;fixed&quot;)<br>
  say &quot;X-Dims Error:  Not fixed.  Use &#39;set lon&#39; or &#39;set x&#39; to specify a value.&quot;<br>
  dimrc=-1<br>
Endif<br>
<br>
If (_ytype != &quot;fixed&quot;)<br>
  say &quot;Y-Dims Error:  Not fixed.  Use &#39;set lat&#39; or &#39;set y&#39; to specify a value&quot;<br>
  dimrc=-1<br>
Endif<br>
<br>
If (_ptype != &quot;varying&quot;)<br>
   say &quot;Z-Dims Error:  Not varying.  Use &#39;set lev&#39; or &#39;set z&#39; to specify a range.&quot;<br>
   dimrc=-1<br>
Endif<br>
<br>
If (_ttype != &quot;fixed&quot;)<br>
  say &quot;Time Error:     Not fixed.  Use &#39;set time&#39; or &#39;set t&#39; to specify a value&quot;<br>
  dimrc=-1<br>
Endif<br>
<br>
<br>
If (dimrc &lt; 0)<br>
  Return(-1)<br>
Endif<br>
<br>
<br>
*<br>
* A few global variables used in units conversion<br>
*<br>
<br>
_pi=3.14159265<br>
_dtr=_pi/180<br>
_rtd=1/_dtr<br>
_ktm=0.514444<br>
_mtk=1/_ktm<br>
<br>
* A few global constants used in thermo calcs<br>
<br>
_C0=0.99999683<br>
_C1=-0.90826951/100<br>
_C2= 0.78736169/10000<br>
_C3=-0.61117958/1000000<br>
_C4= 0.43884187/pow(10,8)<br>
_C5=-0.29883885/pow(10,10)<br>
_C6= 0.21874425/pow(10,12)<br>
_C7=-0.17892321/pow(10,14)<br>
_C8= 0.11112018/pow(10,16)<br>
_C9=-0.30994571/pow(10,19)<br>
<br>
*Calculo la direcci?n e intensidad del viento usando las funciones GetWdir y GetWsp<br>
<br>
<br>
<br>
<br>
<br>
<br>
* A pressure array of power calculations which should be performed<br>
* only once to reduce execution time.<br>
<br>
zz=1100<br>
while (zz &gt; 10)<br>
    subscr=zz/10<br>
    _powpres.subscr=pow(zz,0.286)<br>
    zz=zz-10<br>
endwhile<br>
<br>
*<br>
* Turn off options not available due to user data limitations<br>
*<br>
<br>
If (ClrScrn = 1)<br>
  &quot;clear&quot;<br>
Endif<br>
<br>
If (sndspd = -1 | snddir = -1)<br>
  DrawBarb = 0<br>
  DrawHodo = 0<br>
  DrawHeli = 0<br>
Endif<br>
<br>
If (snddewp = -1)<br>
  DrawDSnd = 0<br>
  DrawRH   = 0<br>
  DrawPrcl = 0<br>
  DrawPMax = 0<br>
  DrawIndx = 0<br>
Endif<br>
<br>
If (sndtemp = -1)<br>
  DrawTSnd = 0<br>
  DrawRH   = 0<br>
  DrawPrcl = 0<br>
  DrawPMax = 0<br>
  DrawIndx = 0<br>
  DrawZLev = 0<br>
Endif<br>
<br>
If (NumRing &lt; 1)<br>
  DrawHodo = 0<br>
Endif<br>
<br>
&quot;q gxinfo&quot;<br>
rec=sublin(result,2)<br>
xsize=subwrd(rec,4)<br>
<br>
If (xsize = 11)<br>
   PageType = &quot;Landscape&quot;<br>
Else<br>
   PageType = &quot;Portrait&quot;<br>
Endif<br>
<br>
*------------------------------------------------------<br>
* calculate constants determining slope/shape of diagram<br>
* based on temp/pressure values given by user<br>
*-------------------------------------------------------<br>
<br>
&quot;set x 1&quot;<br>
&quot;set y 1&quot;<br>
&quot;set z 1&quot;<br>
&quot;set t 1&quot;<br>
_m1=(T1+T2-2*T3)/(2*log10(P2/P3))<br>
_m2=(T2-T3-_m1*log10(P2/P3))/50<br>
_m3=(T1-_m1*log10(P1))<br>
<br>
&quot;set z &quot;_zmin&quot; &quot;_zmax<br>
&quot;set zlog on&quot;<br>
&quot;set xlab off&quot;<br>
<br>
*-------------------------------------------------<br>
* perform coordinate transformation to Skew-T/LogP<br>
*-------------------------------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;set x &quot;_xval<br>
&quot;set y &quot;_yval<br>
&quot;set t &quot;_tval<br>
&quot;define tempx=(&quot;sndtemp&quot;-&quot;_m1&quot;*log10(lev)-&quot;_m3&quot;)/&quot;_m2<br>
&quot;define dewpx=(&quot;snddewp&quot;-&quot;_m1&quot;*log10(lev)-&quot;_m3&quot;)/&quot;_m2<br>
<br>
If (PageType = &quot;Portrait&quot;)<br>
   &quot;set parea 0.7 7 0.75 10&quot;<br>
Else<br>
   &quot;set parea 0.7 6.5 0.5 8&quot;<br>
Endif<br>
<br>
&quot;set axlim 0 100&quot;<br>
&quot;set lon 0 100&quot;<br>
&quot;set grid on 1 1&quot;<br>
<br>
&quot;set z &quot;_zmin &quot; &quot; _zmax<br>
&quot;set lon 0 100&quot;<br>
&quot;set clevs -900&quot;<br>
&quot;set gxout contour&quot;<br>
<br>
*-------------------------------------<br>
* Draw pressure lines<br>
*-------------------------------------<br>
<br>
If (DrawPLev = 0)<br>
   &quot;set ylab off&quot;<br>
Else<br>
   &quot;set ylab on&quot;<br>
   &quot;set ylopts 1 5 0.18&quot;<br>
   &quot;set xlopts 1 3 0.18&quot;<br>
Endif<br>
<br>
&quot;d lon&quot;<br>
<br>
*--------------------------------------<br>
* Determine corners of skewt/logp frame<br>
*--------------------------------------<br>
<br>
&quot;q w2xy 100 &quot;_pmin<br>
rxloc=subwrd(result,3)<br>
tyloc=subwrd(result,6)<br>
&quot;q w2xy 0 &quot;_pmax<br>
lxloc=subwrd(result,3)<br>
byloc=subwrd(result,6)<br>
<br>
If (DrawPLev = 1 &amp; LblAxes = 1)<br>
   &quot;set strsiz 0.15&quot;<br>
   &quot;set string 1 c 3 0&quot;<br>
   If (PageType = &quot;Portrait&quot;)<br>
* &quot;draw string 0.5 10.5 hPa.&quot;<br>
   Else<br>
      &quot;draw string 0.5 8.35 hPa.&quot;<br>
   Endif<br>
Endif<br>
<br>
*---------------------------------------------------<br>
* Calculate &amp; draw actual height lines using temp data<br>
*---------------------------------------------------<br>
<br>
If (DrawZLev &gt; 0)<br>
   say &quot;Calculating observed height levels from temp/pressure data.&quot;<br>
   zz=1<br>
   &quot;set gxout stat&quot;<br>
   &quot;set x &quot;_xval<br>
   &quot;set y &quot;_yval<br>
   &quot;set t &quot;_tval<br>
   count=0<br>
   while (zz &lt; _zmax)<br>
      &quot;set z &quot;zz<br>
      pp.zz=subwrd(result,4)<br>
      lpp.zz=log(pp.zz)<br>
      &quot;d &quot;sndtemp<br>
      rec=sublin(result,8)<br>
      tt=subwrd(rec,4)<br>
      if (tt &gt; -900)<br>
         tk=tt+273.15<br>
         count=count+1<br>
         zzm=zz-1<br>
         If (count = 1)<br>
            If (DrawZLev = 2)<br>
               htlb=&quot;ASL&quot;<br>
               height.zz=SfcElev<br>
            Else<br>
               htlb=&quot;AGL&quot;<br>
               height.zz=0<br>
            Endif<br>
            sfcz=height.zz<br>
         Else<br>
            DZ=29.2857*(lpp.zzm-lpp.zz)*(lpp.zz*tk+lpp.zzm*tkold)/(lpp.zz+lpp.zzm)<br>
            height.zz=height.zzm+DZ<br>
            highz=height.zz<br>
         Endif<br>
      else<br>
         height.zz = -9999<br>
      endif<br>
      tkold=tk<br>
      zz=zz+1<br>
   endwhile<br>
<br>
   maxht=int(highz/1000)<br>
   if (int(sfcz/1000) = sfcz/1000)<br>
      minht=int(sfcz/1000)<br>
   else<br>
      minht=1+int(sfcz/1000)<br>
   endif<br>
<br>
   ht=minht<br>
   &quot;set line 1 3 1&quot;<br>
   &quot;set strsiz 0.10&quot;<br>
   &quot;set string 1 l 3 0&quot;<br>
   while (ht &lt;= maxht)<br>
       zz=1<br>
       while (height.zz/1000 &lt;= ht)<br>
          zz=zz+1<br>
       endwhile<br>
       zzm=zz-1<br>
       PBelow=pp.zzm<br>
       PAbove=pp.zz<br>
       HBelow=height.zzm<br>
       HAbove=height.zz<br>
       DZ=HAbove-HBelow<br>
       DP=PAbove-PBelow<br>
       Del=ht*1000-HBelow<br>
       Est=PBelow+Del*DP/DZ<br>
       If (Est &gt;= _pmin &amp; Est &lt;= _pmax)<br>
          &quot;q w2xy 1 &quot; Est<br>
          yloc=subwrd(result,6)<br>
          &quot;draw line &quot; lxloc &quot; &quot; yloc &quot; &quot; rxloc &quot; &quot; yloc<br>
          &quot;draw string 0.22 &quot;yloc-0.05&quot; &quot;ht<br>
       Endif<br>
       ht=ht+1<br>
   endwhile<br>
   &quot;set strsiz 0.10&quot;<br>
   &quot;set string 1&quot;<br>
   If (LblAxes = 1)<br>
      If (PageType = &quot;Portrait&quot;)<br>
         &quot;draw string 0.25 10.85 km&quot;<br>
         &quot;draw string 0.25 10.75 &quot;htlb<br>
         &quot;draw string 0.25 10.65 OBS&quot;<br>
      Else<br>
         &quot;draw string 0.25 8.35 km&quot;<br>
         &quot;draw string 0.25 8.25 &quot;htlb<br>
         &quot;draw string 0.25 8.15 OBS&quot;<br>
      Endif<br>
   Endif<br>
Endif<br>
<br>
<br>
*---------------------------------------------------<br>
* Draw height levels (height above MSL using Std Atm)<br>
*---------------------------------------------------<br>
<br>
If (DrawZSTD = 1)<br>
   &quot;set strsiz 0.10&quot;<br>
   minht=30.735*(1-pow(_pmax/1013.26,0.287))<br>
   minht=int(minht+0.5)<br>
   maxht=30.735*(1-pow(_pmin/1013.26,0.287))<br>
   maxht=int(maxht)<br>
   &quot;set gxout stat&quot;<br>
   zcount=minht<br>
   while (zcount &lt;= maxht)<br>
      plev=1013.26*pow((1-zcount/30.735),3.4843)<br>
      &quot;q w2xy 0 &quot;plev<br>
      yloc=subwrd(result,6)<br>
      &quot;draw string 0 &quot;yloc-0.05&quot; &quot;zcount<br>
      zcount=zcount+1<br>
   endwhile<br>
   &quot;set strsiz 0.10&quot;<br>
   If (LblAxes = 1)<br>
      If (PageType = &quot;Portrait&quot;)<br>
         &quot;draw string 0 10.85 km&quot;<br>
         &quot;draw string 0 10.75 ASL&quot;<br>
         &quot;draw string 0 10.65 STD&quot;<br>
      Else<br>
         &quot;draw string 0 8.35 km&quot;<br>
         &quot;draw string 0 8.25 ASL&quot;<br>
         &quot;draw string 0 8.15 STD&quot;<br>
      Endif<br>
  Endif<br>
Endif<br>
<br>
<br>
*-----------------------<br>
* Plot temperature lines<br>
*-----------------------<br>
<br>
If (DrawTemp = 1)<br>
   &quot;set strsiz 0.1&quot;<br>
   &quot;set z &quot;_zmin &quot; &quot; _zmax<br>
   &quot;set line &quot;TempCol &quot; &quot; TempLine &quot; &quot;TempThk<br>
   &quot;set string 1 c 3 0&quot;<br>
   &quot;set gxout stat&quot;<br>
   maxtline=GetTemp(100,_pmax)<br>
   mintline=GetTemp(0,_pmin)<br>
<br>
   maxtline=tempint*int(maxtline/tempint)<br>
   mintline=tempint*int(mintline/tempint)<br>
<br>
   tloop=mintline<br>
   While (tloop &lt;= maxtline)<br>
       Botxtemp=GetXLoc(tloop,_pmax)<br>
       &quot;q w2xy &quot;Botxtemp &quot; &quot; _pmax<br>
       Botxloc=subwrd(result,3)<br>
       Botyloc=byloc<br>
       Topxtemp=GetXLoc(tloop,_pmin)<br>
        &quot;q w2xy &quot;Topxtemp &quot; &quot; _pmin<br>
       Topxloc=subwrd(result,3)<br>
       Topyloc=tyloc<br>
       If (Botxtemp &lt;= 100 | Topxtemp &lt;= 100)<br>
          If (Topxtemp &gt; 100)<br>
             Slope=(Topyloc-Botyloc)/(Topxtemp-Botxtemp)<br>
             b=Topyloc-Slope*Topxtemp<br>
             Topyloc=Slope*100+b<br>
             Topxloc=rxloc<br>
          Endif<br>
          If (Botxtemp &lt; 0)<br>
             Slope=(Topyloc-Botyloc)/(Topxtemp-Botxtemp)<br>
             b=Botyloc-Slope*Botxtemp<br>
             Botyloc=b<br>
             Botxloc=lxloc<br>
          Else<br>
             &quot;set strsiz 0.15&quot;<br>
             &quot;draw string &quot; Botxloc-0.05 &quot; &quot; Botyloc-0.15 &quot; &quot; tloop<br>
          Endif<br>
          &quot;draw line &quot;Botxloc &quot; &quot; Botyloc &quot; &quot; Topxloc &quot; &quot; Topyloc<br>
       Endif<br>
       tloop=tloop+tempint<br>
   EndWhile<br>
   If (LblAxes = 1)<br>
      &quot;set strsiz 0.15&quot;<br>
      &quot;set string 1 c&quot;<br>
      If (PageType = &quot;Portrait&quot;)<br>
         &quot;draw string 4.0 0.35 Temperatura (`3.`0C)&quot;<br>
         &quot;draw string 7.7 0.35 Viento m/s &quot;<br>
      Else<br>
         &quot;draw string 3.5 0.15 Temperatura (`3.`0C)&quot;<br>
      Endif<br>
   Endif<br>
Endif<br>
<br>
<br>
*------------------<br>
* Plot dry adiabats<br>
*------------------<br>
<br>
If (DrawThet = 1)<br>
   temp=GetTemp(100,_pmin)<br>
   maxtheta=GetThet2(temp,-100,_pmin)<br>
   maxtheta=thetaint*int(maxtheta/thetaint)<br>
   temp=GetTemp(0,_pmax)<br>
   mintheta=GetThet2(temp,-100,_pmax)<br>
   mintheta=thetaint*int(mintheta/thetaint)<br>
<br>
   &quot;set lon 0 100&quot;<br>
   &quot;set y 1&quot;<br>
   &quot;set z 1&quot;<br>
   tloop=mintheta<br>
   &quot;set line &quot;ThetCol&quot; &quot;ThetLine &quot; &quot;ThetThk<br>
   While (tloop &lt;= maxtheta)<br>
     PTemp=LiftDry(tloop,1000,_pmin,1,_pmin,_pmax)<br>
     tloop=tloop+thetaint<br>
   Endwhile<br>
Endif<br>
<br>
*------------------------<br>
* Plot mixing ratio lines<br>
*------------------------<br>
<br>
If (DrawMix = 1)<br>
   If (MixStop &lt; _pmin)<br>
      MixStop = _pmin<br>
   Endif<br>
   &quot;set string 1 l&quot;<br>
   &quot;set z &quot;_zmin &quot; &quot; _zmax<br>
   &quot;set cint 1&quot;<br>
   &quot;set line &quot;MixCol&quot; &quot; MixLine &quot; &quot;MixThk<br>
   cont = 1<br>
   mloop=subwrd(wsclevs,1)<br>
   count = 1<br>
   While (cont = 1)<br>
       BotCoef=log(mloop*_pmax/3801.66)<br>
       BotTval=-245.5*BotCoef/(BotCoef-17.67)<br>
       Botxtemp=GetXLoc(BotTval,_pmax)<br>
       &quot;q w2xy &quot;Botxtemp &quot; &quot; _pmax<br>
       Botxloc=subwrd(result,3)<br>
       Botyloc=byloc<br>
       TopCoef=log(mloop*MixStop/3801.66)<br>
       TopTval=-245.5*TopCoef/(TopCoef-17.67)<br>
       Topxtemp=GetXLoc(TopTval,MixStop)<br>
       &quot;q w2xy &quot;Topxtemp &quot; &quot; MixStop<br>
       Topxloc=subwrd(result,3)<br>
       Topyloc=subwrd(result,6)<br>
       &quot;set string &quot;MixCol&quot; l 3&quot;<br>
       &quot;set strsiz 0.09&quot;<br>
       If (Botxtemp &lt;= 100 | Topxtemp &lt;= 100)<br>
          If (Topxtemp &gt; 100)<br>
             Slope=(Topyloc-Botyloc)/(Topxtemp-Botxtemp)<br>
             b=Topyloc-Slope*Topxtemp<br>
             Topyloc=Slope*100+b<br>
             Topxloc=rxloc<br>
             &quot;draw string &quot; Topxloc+0.05 &quot; &quot; Topyloc  &quot; &quot; mloop<br>
          Else<br>
             &quot;draw string &quot; Topxloc &quot; &quot; Topyloc+0.1 &quot; &quot; mloop<br>
          Endif<br>
          If (Botxtemp &lt; 0)<br>
             Slope=(Topyloc-Botyloc)/(Topxtemp-Botxtemp)<br>
             b=Botyloc-Slope*Botxtemp<br>
             Botyloc=b<br>
             Botxloc=lxloc<br>
          Endif<br>
          &quot;draw line &quot;Botxloc &quot; &quot; Botyloc &quot; &quot; Topxloc &quot; &quot; Topyloc<br>
       Endif<br>
       count=count+1<br>
       mloop=subwrd(wsclevs,count)<br>
       If (mloop = &quot;&quot; | count &gt; 50)<br>
          cont = 0<br>
       Endif<br>
   EndWhile<br>
   If (LblAxes = 1)<br>
      &quot;set strsiz 0.15&quot;<br>
      &quot;set string 1 c 3 90&quot;<br>
      If (PageType = &quot;Portrait&quot;)<br>
*         &quot;draw string 7.40 4.75 Relacion de Mezcla (g/kg)&quot;<br>
      Else<br>
*         &quot;draw string 6.90 4.25 Mixing Ratio (g/kg)&quot;<br>
      Endif<br>
      &quot;set string 1 c 3 0&quot;<br>
   Endif<br>
Endif<br>
<br>
*-----------------------------<br>
* Plot moist (pseudo) adiabats<br>
*-----------------------------<br>
<br>
If (DrawThtw = 1)<br>
   &quot;set lon 0 100&quot;<br>
   &quot;set y 1&quot;<br>
   &quot;set z 1&quot;<br>
   &quot;set gxout stat&quot;<br>
   tloop=80<br>
   &quot;set line &quot;ThtwCol&quot; &quot;ThtwLine &quot; &quot;ThtwThk<br>
   While (tloop &gt; -80)<br>
     PTemp=LiftWet(tloop,1000,ThtwStop,1,_pmin,_pmax)<br>
     tloop=tloop-thetwint<br>
   Endwhile<br>
Endif<br>
<br>
<br>
*-----------------------------------------------------<br>
* Plot transformed user-specified temperature sounding<br>
*-----------------------------------------------------<br>
<br>
If (DrawTSnd = 1)<br>
   say &quot;Drawing temperature sounding.&quot;<br>
   &quot;set gxout line&quot;<br>
   &quot;set x &quot;_xval<br>
   &quot;set y &quot;_yval<br>
   &quot;set z &quot;_zmin&quot; &quot;_zmax<br>
   &quot;set ccolor &quot;TSndCol<br>
   &quot;set cstyle &quot;TSndLine<br>
   &quot;set cmark &quot;TSndMrk<br>
   &quot;set digsiz &quot;MrkSize<br>
   &quot;set cthick &quot;TSndThk<br>
   &quot;set missconn on&quot;<br>
   &quot;d tempx&quot;<br>
Endif<br>
<br>
*---------------------------------------------------<br>
* Plot transformed user-specified dewpoint sounding<br>
*---------------------------------------------------<br>
<br>
If (DrawDSnd = 1)<br>
   say &quot;Drawing dewpoint sounding.&quot;<br>
   &quot;set gxout line&quot;<br>
   &quot;set x &quot;_xval<br>
   &quot;set y &quot;_yval<br>
   &quot;set z &quot;_zmin&quot; &quot;_zmax<br>
   &quot;set cmark &quot;DSndMrk<br>
   &quot;set digsiz &quot;MrkSize<br>
   &quot;set ccolor &quot;DSndCol<br>
   &quot;set cstyle &quot;DSndLine<br>
   &quot;set cthick &quot;DSndThk<br>
   &quot;set missconn on&quot;<br>
   &quot;d dewpx&quot;<br>
Endif<br>
<br>
*----------------------------------------<br>
* Determine lowest level of reported  data<br>
*----------------------------------------<br>
<br>
If (DrawTSnd = 1)<br>
   field=sndtemp<br>
Else<br>
   field=sndspd<br>
Endif<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;set x &quot;_xval<br>
&quot;set y &quot;_yval<br>
&quot;set t &quot;_tval<br>
&quot;set lev &quot; _pmax &quot; &quot; _pmin<br>
&quot;d maskout(lev,&quot;field&quot;+300)&quot;<br>
rec=sublin(result,1)<br>
check=substr(rec,1,6)<br>
If (check = &quot;Notice&quot;)<br>
    rec=sublin(result,9)<br>
Else<br>
    rec=sublin(result,8)<br>
Endif<br>
SfcPlev=subwrd(rec,5)<br>
<br>
If (DrawTSnd = 1 &amp; DrawDSnd = 1)<br>
   &quot;set lev &quot;SfcPlev<br>
   &quot;d &quot;sndtemp<br>
   rec=sublin(result,8)<br>
   Sfctemp=subwrd(rec,4)<br>
   &quot;d &quot;snddewp<br>
   rec=sublin(result,8)<br>
   Sfcdewp=subwrd(rec,4)<br>
   SfcThee=Thetae(Sfctemp,Sfcdewp,SfcPlev)<br>
<br>
*------------------------------------------<br>
* Calculate temperature and pressure of LCL<br>
*------------------------------------------<br>
<br>
   TLcl=Templcl(Sfctemp,Sfcdewp)<br>
   PLcl=Preslcl(Sfctemp,Sfcdewp,SfcPlev)<br>
Endif<br>
<br>
*----------------------------------------------------------<br>
* Plot parcel path from surface to LCL and up moist adiabat<br>
*----------------------------------------------------------<br>
<br>
If (DrawPrcl = 1)<br>
   say &quot;Drawing parcel path from surface upward.&quot;<br>
   If (PageType = &quot;Portrait&quot;)<br>
      xloc=7.15<br>
   Else<br>
      xloc=6.65<br>
   Endif<br>
   &quot;q w2xy 1 &quot;PLcl<br>
   rec=sublin(result,1)<br>
   yloc=subwrd(rec,6)<br>
   &quot;set strsiz 0.1&quot;<br>
   If (PLcl &lt; _pmax)<br>
      &quot;set string 1 l&quot;<br>
      &quot;draw string &quot;xloc&quot; &quot;yloc&quot; LCL&quot;<br>
      &quot;set line 1 1 1&quot;<br>
      &quot;draw line &quot;xloc-0.15&quot; &quot;yloc&quot; &quot;xloc-0.05&quot; &quot;yloc<br>
   Endif<br>
   &quot;set lon 0 100&quot;<br>
   &quot;set gxout stat&quot;<br>
   &quot;set line &quot;PrclCol&quot; &quot;PrclLine &quot; &quot; PrclThk<br>
   PTemp=LiftDry(Sfctemp,SfcPlev,PLcl,1,_pmin,_pmax)<br>
   Ptemp=LiftWet(TLcl,PLcl,_pmin,1,_pmin,_pmax)<br>
Endif<br>
<br>
*-------------------------------------------------------<br>
* Determine level within lowest 250mb having highest<br>
* theta-e value<br>
*-------------------------------------------------------<br>
<br>
If (DrawTSnd = 1 &amp; DrawDSnd = 1)<br>
  &quot;set x &quot;_xval<br>
  &quot;set y &quot;_yval<br>
  &quot;set t &quot;_tval<br>
   zz=1<br>
   MaxThee=-999<br>
   &quot;set gxout stat&quot;<br>
   while (zz &lt;= _zmax &amp; pp &gt; _pmax-250)<br>
       &quot;set z &quot;zz<br>
       pp=subwrd(result,4)<br>
       &quot;d &quot;sndtemp<br>
       rec=sublin(result,8)<br>
       tt=subwrd(rec,4)<br>
       &quot;d &quot;snddewp<br>
       rec=sublin(result,8)<br>
       dd=subwrd(rec,4)<br>
       If (abs(tt) &lt; 130 &amp; abs(dd) &lt; 130)<br>
          Thee=Thetae(tt,dd,pp)<br>
          If (Thee &gt; MaxThee)<br>
             MaxThee=Thee<br>
             TMaxThee=tt<br>
             DMaxThee=dd<br>
             PMaxThee=pp<br>
          Endif<br>
       endif<br>
       zz=zz+1<br>
   Endwhile<br>
   If (PMaxThee = SfcPlev-250)<br>
      PMaxThee = SfcPlev<br>
   Endif<br>
*------------------------------------------------------<br>
* Calculate temperature and pressure of LCL from highest<br>
* theta-e level<br>
*------------------------------------------------------<br>
   If (SfcPlev != PMaxThee)<br>
      TLclMax=Templcl(TMaxThee,DMaxThee)<br>
      PLclMax=Preslcl(TMaxThee,DMaxThee,PMaxThee)<br>
   Endif<br>
Endif<br>
<br>
*----------------------------------------------------------<br>
* Plot parcel path from highest theta-e level to LCL and up<br>
* moist adiabat<br>
*----------------------------------------------------------<br>
<br>
If (DrawPMax = 1 &amp; SfcPlev != PMaxThee)<br>
   say &quot;Drawing parcel path from most unstable level upward.&quot;<br>
   If (PageType = &quot;Portrait&quot;)<br>
      xloc=7.15<br>
   Else<br>
      xloc=6.65<br>
   Endif<br>
   &quot;q w2xy 1 &quot;PLclMax<br>
   rec=sublin(result,1)<br>
   yloc=subwrd(rec,6)<br>
   &quot;set strsiz 0.1&quot;<br>
   If (PLclMax &lt; _pmax)<br>
      &quot;set string 1 l&quot;<br>
      &quot;draw string &quot;xloc&quot; &quot;yloc&quot; LCL&quot;<br>
      &quot;set line 1 1 1&quot;<br>
      &quot;draw line &quot;xloc-0.15&quot; &quot;yloc&quot; &quot;xloc-0.05&quot; &quot;yloc<br>
   Endif<br>
   &quot;set lon 0 100&quot;<br>
   &quot;set gxout stat&quot;<br>
   &quot;set line &quot;PrclCol&quot; &quot;PrclLine &quot; &quot; PrclThk<br>
   PTemp=LiftDry(TMaxThee,PMaxThee,PLclMax,1,_pmin,_pmax)<br>
   Ptemp=LiftWet(TLclMax,PLclMax,_pmin,1,_pmin,_pmax)<br>
Endif<br>
<br>
*--------------------------------<br>
* Draw thermodynamic indices<br>
*--------------------------------<br>
<br>
If (DrawIndx = 1)<br>
   &quot;set string 1 l&quot;<br>
   &quot;set strsiz 0.10&quot;<br>
   &quot;set x &quot;_xval<br>
   &quot;set y &quot;_yval<br>
   &quot;set t &quot;_tval<br>
   say &quot;Calculating precipitable water.&quot;<br>
   pw=precipw(sndtemp,snddewp,_pmax,_pmin)<br>
   say &quot;Calculating thermodynamic indices.&quot;<br>
   Temp850=interp(sndtemp,850)<br>
   Temp700=interp(sndtemp,700)<br>
   Temp500=interp(sndtemp,500)<br>
   Dewp850=interp(snddewp,850)<br>
   Dewp700=interp(snddewp,700)<br>
   Dewp500=interp(snddewp,500)<br>
   If (Temp850&gt;-900 &amp; Dewp850&gt;-900 &amp; Dewp700&gt;-900 &amp; Temp700&gt;-900 &amp; Temp500&gt;-900)<br>
      K=Temp850+Dewp850+Dewp700-Temp700-Temp500<br>
   Else<br>
      K=-999<br>
   Endif<br>
   If (Temp850 &gt; -900 &amp; Dewp850 &gt; -900 &amp; Temp500 &gt; -900)<br>
      tt=Temp850+Dewp850-2*Temp500<br>
   Else<br>
      tt=-999<br>
   Endif<br>
   Temp500V=virtual2(Temp500+273.15,Dewp500+273.15,500)-273.15<br>
   PclTemp=LiftWet(TLcl,PLcl,500,0)<br>
   PclTempV=virtual2(PclTemp+273.15,PclTemp+273.15,500)-273.15<br>
   SLI=Temp500V-PclTempV<br>
   rec=CAPE(TLcl,PLcl,200,sndtemp,snddewp)<br>
   Pos=subwrd(rec,1)<br>
   CIN=subwrd(rec,2)<br>
<br>
   If (SfcPlev != PMaxThee)<br>
      PclTemp=LiftWet(TLclMax,PLclMax,500,0)<br>
      PclTempV=virtual2(PclTemp+273.15,PclTemp+273.15,500)-273.15<br>
      LIMax=Temp500V-PclTempV<br>
      rec=CAPE(TLclMax,PLclMax,100,sndtemp,snddewp)<br>
      PosMax=subwrd(rec,1)<br>
      CINMax=subwrd(rec,2)<br>
   Else<br>
      LIMax=SLI<br>
      PosMax=Pos<br>
      CINMax=CIN<br>
      MaxThee=SfcThee<br>
   Endif<br>
<br>
   If (PageType = &quot;Portrait&quot;)<br>
      If (Text1XC = -1)<br>
         Text1XC=rxloc-0.75<br>
      Endif<br>
      If (Text1YC = -1)<br>
         Text1YC=tyloc-2.25<br>
      Endif<br>
      If (Text2XC = -1)<br>
         Text2XC=rxloc-0.75<br>
      Endif<br>
      If (Text2YC = -1)<br>
         Text2YC=tyloc-3.25<br>
      Endif<br>
      If (Text3XC = -1)<br>
          Text3XC=rxloc-0.75<br>
      Endif<br>
      If (Text3YC = -1)<br>
         Text3YC=tyloc-4.40<br>
      Endif<br>
   Else<br>
      If (Text1XC = -1)<br>
         Text1XC=rxloc+2.50<br>
      Endif<br>
      If (Text1YC = -1)<br>
         Text1YC=tyloc-3.00<br>
      Endif<br>
      If (Text2XC = -1)<br>
         Text2XC=rxloc+2.50<br>
      Endif<br>
      If (Text2YC = -1)<br>
         Text2YC=tyloc-4.00<br>
      Endif<br>
      If (Text3XC = -1)<br>
         Text3XC=rxloc+2.50<br>
      Endif<br>
      If (Text3YC = -1)<br>
         Text3YC=tyloc-5.10<br>
      Endif<br>
   Endif<br>
   &quot;set string 1 l 3&quot;<br>
   &quot;set line 0 1 3&quot;<br>
   &quot;draw recf  &quot;Text1XC-0.75 &quot; &quot; Text1YC-0.40 &quot; &quot; Text1XC+0.75 &quot; &quot; Text1YC+0.25<br>
   &quot;set line 1 1 3&quot;<br>
   &quot;draw rec  &quot;Text1XC-0.75 &quot; &quot; Text1YC-0.40 &quot; &quot; Text1XC+0.75 &quot; &quot; Text1YC+0.25<br>
   &quot;draw string &quot;Text1XC-0.70 &quot; &quot; Text1YC+0.10&quot;  K&quot;<br>
   &quot;draw string &quot;Text1XC+0.25 &quot; &quot; Text1YC+0.10&quot; &quot; int(K)<br>
   &quot;draw string &quot;Text1XC-0.70 &quot; &quot; Text1YC-0.10 &quot;  TT&quot;<br>
   &quot;draw string &quot;Text1XC+0.25 &quot; &quot; Text1YC-0.10 &quot; &quot; int(tt)<br>
   &quot;draw string &quot;Text1XC-0.70 &quot; &quot; Text1YC-0.25 &quot;  AP(cm)&quot;<br>
   &quot;draw string &quot;Text1XC+0.25 &quot; &quot; Text1YC-0.25 &quot; &quot; int(pw*100)/100<br>
   &quot;set line 0 1 3&quot;<br>
   &quot;draw recf  &quot;Text2XC-0.75 &quot; &quot; Text2YC-0.60 &quot; &quot; Text2XC+0.75 &quot; &quot; Text2YC+0.60<br>
   &quot;set line 1 1 3&quot;<br>
   &quot;draw rec  &quot;Text2XC-0.75 &quot; &quot; Text2YC-0.60 &quot; &quot; Text2XC+0.75 &quot; &quot; Text2YC+0.60<br>
   &quot;draw string &quot;Text2XC-0.35 &quot; &quot; Text2YC+0.50 &quot; Superficie&quot;<br>
   &quot;draw string &quot;Text2XC-0.70 &quot; &quot; Text2YC+0.30 &quot;  Temp(`3.`0C)&quot;<br>
   &quot;draw string &quot;Text2XC+0.25 &quot; &quot; Text2YC+0.30 &quot; &quot; int(Sfctemp*10)/10<br>
   &quot;draw string &quot;Text2XC-0.70 &quot; &quot; Text2YC+0.15 &quot;  Dewp(`3.`0C)&quot;<br>
   &quot;draw string &quot;Text2XC+0.25 &quot; &quot; Text2YC+0.15 &quot; &quot; int(Sfcdewp*10)/10<br>
   &quot;draw string &quot;Text2XC-0.70 &quot; &quot; Text2YC &quot;   `3z`0`bE`n(K)&quot;<br>
   &quot;draw string &quot;Text2XC+0.25 &quot; &quot; Text2YC &quot; &quot; int(SfcThee)<br>
   &quot;draw string &quot;Text2XC-0.70 &quot; &quot; Text2YC-0.15 &quot;  LI&quot;<br>
   &quot;draw string &quot;Text2XC+0.25 &quot; &quot; Text2YC-0.15 &quot; &quot; round(SLI)<br>
   &quot;draw string &quot;Text2XC-0.70 &quot; &quot; Text2YC-0.30 &quot;  CAPE(J)&quot;<br>
   &quot;draw string &quot;Text2XC+0.25 &quot; &quot; Text2YC-0.30 &quot; &quot; int(Pos)<br>
   &quot;draw string &quot;Text2XC-0.70 &quot; &quot; Text2YC-0.45 &quot;  CIN(J)&quot;<br>
   &quot;draw string &quot;Text2XC+0.25 &quot; &quot; Text2YC-0.45 &quot; &quot; int(CIN)<br>
   &quot;set line 0 1 3&quot;<br>
   &quot;draw recf  &quot;Text3XC-0.75 &quot; &quot; Text3YC-0.55 &quot; &quot;  Text3XC+0.75 &quot; &quot; Text3YC+0.55<br>
   &quot;set line 1 1 3&quot;<br>
   &quot;draw rec  &quot;Text3XC-0.75 &quot; &quot; Text3YC-0.55 &quot; &quot;  Text3XC+0.75 &quot; &quot; Text3YC+0.55<br>
   &quot;draw string &quot;Text3XC-0.60 &quot; &quot; Text3YC+0.45 &quot; Mas inestable&quot;<br>
   &quot;draw string &quot;Text3XC-0.70 &quot; &quot; Text3YC+0.20 &quot;  Pres(hPa)&quot;<br>
   &quot;draw string &quot;Text3XC+0.25 &quot; &quot; Text3YC+0.20 &quot; &quot; int(PMaxThee)<br>
   &quot;draw string &quot;Text3XC-0.70 &quot; &quot; Text3YC+0.05 &quot; `3z`0`bE`n(K)&quot;<br>
   &quot;draw string &quot;Text3XC+0.25 &quot; &quot; Text3YC+0.05 &quot; &quot; int(MaxThee)<br>
   &quot;draw string &quot;Text3XC-0.70 &quot; &quot; Text3YC-0.10 &quot; LI&quot;<br>
   &quot;draw string &quot;Text3XC+0.25 &quot; &quot; Text3YC-0.10 &quot; &quot;round(LIMax)<br>
   &quot;draw string &quot;Text3XC-0.70 &quot; &quot; Text3YC-0.25 &quot; CAPE(J)&quot;<br>
   &quot;draw string &quot;Text3XC+0.25 &quot; &quot; Text3YC-0.25 &quot; &quot;int(PosMax)<br>
   &quot;draw string &quot;Text3XC-0.70 &quot; &quot; Text3YC-0.40 &quot; CIN(J)&quot;<br>
   &quot;draw string &quot;Text3XC+0.25 &quot; &quot; Text3YC-0.40 &quot; &quot; int(CINMax)<br>
Endif<br>
<br>
*-----------------------------<br>
* Draw wind profile along side<br>
*-----------------------------<br>
<br>
If (DrawBarb = 1)<br>
   say &quot;Drawing Wind Profile.&quot;<br>
   If (poleloc = -1)<br>
      If (PageType = &quot;Portrait&quot;)<br>
         poleloc = 8.0<br>
      Else<br>
         poleloc = 7.5<br>
      Endif<br>
   Endif<br>
   If (barbline = 1)<br>
      &quot;set line 1 1 3&quot;<br>
      &quot;draw line &quot;poleloc &quot; &quot; byloc &quot; &quot; poleloc &quot; &quot; tyloc<br>
   Endif<br>
   If (BarbCol = -1)<br>
      &#39;set rgb 41 255 0 132&#39;<br>
      &#39;set rgb 42 255 0 168&#39;<br>
      &#39;set rgb 43 255 0 204&#39;<br>
      &#39;set rgb 44 255 0 240&#39;<br>
      &#39;set rgb 45 255 0 255&#39;<br>
      &#39;set rgb 46 204 0 255&#39;<br>
      &#39;set rgb 47 174 0 255&#39;<br>
      &#39;set rgb 48 138 0 255&#39;<br>
      &#39;set rgb 49 108 0 255&#39;<br>
      &#39;set rgb 50 84 0 255&#39;<br>
      &#39;set rgb 51 40 0 255&#39;<br>
      &#39;set rgb 52 0 0  255&#39;<br>
      &#39;set rgb 53 0 42 255&#39;<br>
      &#39;set rgb 54 0 84 255&#39;<br>
      &#39;set rgb 55 0 120 255&#39;<br>
      &#39;set rgb 56 0 150 255&#39;<br>
      &#39;set rgb 57 0 192 255&#39;<br>
      &#39;set rgb 58 0 240 255&#39;<br>
      &#39;set rgb 59 0 255 210&#39;<br>
      &#39;set rgb 60 0 255 160&#39;<br>
      &#39;set rgb 61 0 255 126&#39;<br>
      &#39;set rgb 62 0 255 78&#39;<br>
      &#39;set rgb 63 84 255 0&#39;<br>
      &#39;set rgb 64 138 255 0&#39;<br>
      &#39;set rgb 65 188 255 0&#39;<br>
      &#39;set rgb 66 236 255 0&#39;<br>
      &#39;set rgb 67 255 255 0&#39;<br>
      &#39;set rgb 68 255 222 0&#39;<br>
      &#39;set rgb 69 255 192 0&#39;<br>
      &#39;set rgb 70 255 162 0&#39;<br>
      &#39;set rgb 71 255 138 0&#39;<br>
      &#39;set rgb 72 255 108 0&#39;<br>
      &#39;set rgb 73 255 84 0&#39;<br>
      &#39;set rgb 74 255 54 0&#39;<br>
      &#39;set rgb 75 255 12 0&#39;<br>
      &#39;set rgb 76 255 0 34&#39;<br>
      &#39;set rgb 77 255 0 70&#39;<br>
      &#39;set rgb 78 255 0 105&#39;<br>
      &#39;set rgb 79 255 0 140&#39;<br>
      &#39;set rgb 80 255 0 175&#39;<br>
      &#39;set rgb 81 255 0 215&#39;<br>
      &#39;set rgb 82 255 0 255&#39;<br>
      &#39;set rgb 83 255 255 255&#39;<br>
<br>
      col1=&#39;83 83 83 83 83 83 83 83 83 83 82 81 80 79 78&#39;<br>
      col2=&#39;77 76 75 74 73 72 71 70 69 68 67 66 65 64 63&#39;<br>
      col3=&#39;62 61 60 59 58 57 56 55 54 53 52 51 50 49 48&#39;<br>
      &#39;set rbcols &#39;col1&#39; &#39;col2&#39; &#39;col3<br>
   Endif<br>
   &quot;set z &quot;_zmin&quot; &quot;_zmax<br>
   &quot;set gxout stat&quot;<br>
   zz=1<br>
   wspd=-999<br>
   cont=1<br>
   While (cont = 1 &amp; zz &lt; _zmax)<br>
      &quot;set z &quot;zz<br>
      pres=subwrd(result,4)<br>
      &quot;d &quot;u<br>
      rec=sublin(result,8)<br>
      uwnd=subwrd(rec,4)<br>
<br>
      &quot;d &quot;v<br>
      rec=sublin(result,8)<br>
      vwnd=subwrd(rec,4)<br>
<br>
      wspd=GetWSpd(uwnd,vwnd)<br>
<br>
      if (wspd &lt; 0 | pres &gt; _pmax)<br>
          zz=zz+1<br>
      else<br>
          cont=0<br>
      Endif<br>
   Endwhile<br>
   While (zz &lt;= _zmax)<br>
<br>
      &quot;d &quot;u&quot;(z=&quot;zz&quot;)&quot;<br>
      rec=sublin(result,8)<br>
      uwnd=subwrd(rec,4)<br>
<br>
      &quot;d &quot;v&quot;(z=&quot;zz&quot;)&quot;<br>
      rec=sublin(result,8)<br>
      vwnd=subwrd(rec,4)<br>
<br>
      wspd=GetWSpd(uwnd,vwnd)<br>
<br>
      If (BarbCol &gt;= 0)<br>
         &quot;set line &quot;BarbCol &quot; 1 &quot;BarbThk<br>
      Else<br>
         tempbcol=55+wspd/5<br>
         If (tempbcol &gt; 83)<br>
            tempbcol = 83<br>
         Endif<br>
         &quot;set line &quot;tempbcol &quot; 1 &quot;BarbThk<br>
      Endif<br>
<br>
      &quot;d &quot;u&quot;(z=&quot;zz&quot;)&quot;<br>
      rec=sublin(result,8)<br>
      uwnd=subwrd(rec,4)<br>
<br>
      &quot;d &quot;v&quot;(z=&quot;zz&quot;)&quot;<br>
      rec=sublin(result,8)<br>
      vwnd=subwrd(rec,4)<br>
      if(vwnd != undef)<br>
      wspd=GetWSpd(uwnd,vwnd)<br>
      wdir=GetWDir(uwnd,vwnd)<br>
      Else<br>
      wspd=0<br>
      wdir=0<br>
      Endif<br>
<br>
      xwind=GetUWnd(wspd,wdir)<br>
      ywind=GetVWnd(wspd,wdir)<br>
      &quot;query gr2xy 5 &quot;zz<br>
      y1=subwrd(result,6)<br>
      if (wspd &gt; 0)<br>
         cc=polelen/wspd<br>
         xendpole=poleloc-xwind*cc<br>
         yendpole=y1-ywind*cc<br>
      endif<br>
      if (xendpole&gt;0 &amp; wspd &gt;= 0.5)<br>
        if (flagbase = 1)<br>
           &quot;draw mark 3 &quot;poleloc &quot; &quot; y1 &quot; 0.05&quot;<br>
        endif<br>
        &quot;draw line &quot; poleloc &quot; &quot; y1 &quot;  &quot; xendpole &quot; &quot; yendpole<br>
        flagloop=wspd/10<br>
        windcount=wspd<br>
        flagcount=0<br>
        xflagstart=xendpole<br>
        yflagstart=yendpole<br>
        dx=cos((180-wdir)*_dtr)<br>
        dy=sin((180-wdir)*_dtr)<br>
        while (windcount &gt; 47.5)<br>
           flagcount=flagcount+1<br>
           dxflag=-len50*dx<br>
           dyflag=-len50*dy<br>
           xflagend=xflagstart+dxflag<br>
           yflagend=yflagstart+dyflag<br>
           windcount=windcount-50<br>
           x1=xflagstart+0.5*wid50*xwind/wspd<br>
           y1=yflagstart+0.5*wid50*ywind/wspd<br>
           x2=xflagstart-0.5*wid50*xwind/wspd<br>
           y2=yflagstart-0.5*wid50*ywind/wspd<br>
           If (Fill50 = 1)<br>
              &quot;draw polyf &quot;x1&quot; &quot;y1&quot; &quot;x2&quot; &quot;y2&quot; &quot;xflagend&quot; &quot;yflagend&quot; &quot;x1&quot; &quot;y1<br>
           Else<br>
              &quot;draw line &quot;x1 &quot; &quot;y1 &quot; &quot; xflagend &quot; &quot; yflagend &quot; &quot;<br>
              &quot;draw line &quot;x2 &quot; &quot;y2 &quot; &quot; xflagend &quot; &quot; yflagend<br>
              &quot;draw line &quot;x1 &quot; &quot;y1 &quot; &quot; x2 &quot; &quot; y2<br>
           Endif<br>
           xflagstart=xflagstart+spac50*xwind/wspd<br>
           yflagstart=yflagstart+spac50*ywind/wspd<br>
        endwhile<br>
        while (windcount &gt; 7.5 )<br>
           flagcount=flagcount+1<br>
           dxflag=-len10*dx<br>
           dyflag=-len10*dy<br>
           xflagend=xflagstart+dxflag<br>
           yflagend=yflagstart+dyflag<br>
           windcount=windcount-10<br>
           &quot;draw line &quot; xflagstart &quot; &quot; yflagstart &quot; &quot; xflagend &quot; &quot; yflagend<br>
           xflagstart=xflagstart+spac10*xwind/wspd<br>
           yflagstart=yflagstart+spac10*ywind/wspd<br>
        endwhile<br>
        if (windcount &gt; 2.5)<br>
           flagcount=flagcount+1<br>
           if (flagcount = 1)<br>
              xflagstart=xflagstart+spac05*xwind/wspd<br>
              yflagstart=yflagstart+spac05*ywind/wspd<br>
           endif<br>
           dxflag=-len05*dx<br>
           dyflag=-len05*dy<br>
           xflagend=xflagstart+dxflag<br>
           yflagend=yflagstart+dyflag<br>
           windcount=windcount-5<br>
           &quot;draw line &quot; xflagstart &quot; &quot; yflagstart &quot; &quot; xflagend &quot; &quot; yflagend<br>
        endif<br>
      else<br>
        if (wspd &lt; 0.5 &amp; wspd &gt;= 0)<br>
           &quot;draw mark 2 &quot; poleloc &quot; &quot; y1 &quot; 0.08&quot;<br>
        endif<br>
      endif<br>
      zz=zz+barbint<br>
   endwhile<br>
Endif<br>
<br>
*----------------<br>
* Draw Hodograph<br>
*----------------<br>
<br>
If (DrawHodo = 1)<br>
   say &quot;Drawing Hodograph.&quot;<br>
<br>
   If (HodXcent = -1 | HodYcent = -1)<br>
      If (PageType = &quot;Portrait&quot;)<br>
         HodXcent=6<br>
         HodYcent=9.5<br>
      rec=sublin(result,8)<br>
      uwnd=subwrd(rec,4)<br>
      Else<br>
         HodXcent=9<br>
         HodYcent=7.0<br>
      Endif<br>
   Endif<br>
   HodL=HodXcent-HodSize/2.0<br>
   HodR=HodXcent+HodSize/2.0<br>
   HodT=HodYcent+HodSize/2.0<br>
   HodB=HodYcent-HodSize/2.0<br>
   RingSpac=HodSize/(NumRing*2)<br>
   &quot;set line 0&quot;<br>
   &quot;draw recf &quot;HodL&quot; &quot;HodB&quot; &quot;HodR&quot; &quot;HodT<br>
   &quot;set line &quot;HodoCol&quot; 1 6&quot;<br>
   &quot;draw rec &quot;HodL&quot; &quot;HodB&quot; &quot;HodR&quot; &quot;HodT<br>
   &quot;set line 1 1 3&quot;<br>
   &quot;set string 1 c&quot;<br>
   &quot;draw mark 1 &quot;HodXcent &quot; &quot;HodYcent &quot; &quot; HodSize<br>
   i=1<br>
   While (i &lt;= NumRing)<br>
     &quot;set strsiz 0.10&quot;<br>
     &quot;set string 1 c 3 45&quot;<br>
     uwnd=-i*HodRing*cos(45*_dtr)<br>
     xloc=HodXcent+uwnd*RingSpac/HodRing<br>
     yloc=HodYcent+uwnd*RingSpac/HodRing<br>
<br>
     &quot;draw mark 2 &quot;HodXcent &quot; &quot; HodYcent &quot; &quot; i*HodSize/NumRing<br>
     &quot;draw string &quot;xloc &quot; &quot; yloc &quot; &quot; HodRing*i<br>
     i=i+1<br>
   Endwhile<br>
   &quot;set string 1 l 3 0&quot;<br>
   If (TickInt &gt; 0)<br>
      i=0<br>
      while (i &lt; HodRing*NumRing)<br>
         dist=i*RingSpac/HodRing<br>
         hrxloc=HodXcent+dist<br>
         hlxloc=HodXcent-dist<br>
         htyloc=HodYcent+dist<br>
         hbyloc=HodYcent-dist<br>
         &quot;set line 1 1 3&quot;<br>
         &quot;draw line &quot;hrxloc &quot; &quot; HodYcent-TickSize/2 &quot; &quot; hrxloc &quot; &quot; HodYcent+TickSize/2<br>
         &quot;draw line &quot;hlxloc &quot; &quot; HodYcent-TickSize/2 &quot; &quot; hlxloc &quot; &quot; HodYcent+TickSize/2<br>
         &quot;draw line &quot;HodXcent+TickSize/2 &quot; &quot; htyloc &quot; &quot; HodXcent-TickSize/2 &quot; &quot; htyloc<br>
         &quot;draw line &quot;HodXcent+TickSize/2 &quot; &quot; hbyloc &quot; &quot; HodXcent-TickSize/2 &quot; &quot; hbyloc<br>
         i=i+TickInt<br>
      endwhile<br>
   Endif<br>
   &quot;set line &quot;HodoCol &quot; &quot; HodoLine &quot; &quot;HodoThk<br>
   &quot;draw string &quot;HodL+0.05 &quot; &quot; HodT-0.1 &quot; m/s&quot;<br>
   zloop=_zmin<br>
   xold=-999<br>
   yold=-999<br>
   count=0<br>
   Depth=0<br>
   While (zloop &lt; _zmax &amp; Depth &lt; HodoDep)<br>
      &quot;set z &quot;zloop<br>
      pres=subwrd(result,4)<br>
<br>
      &quot;d &quot;u<br>
      rec=sublin(result,8)<br>
      uwnd=subwrd(rec,4)<br>
      &quot;d &quot;v<br>
      rec=sublin(result,8)<br>
      vwnd=subwrd(rec,4)<br>
      if (uwnd = undef)<br>
      uwnd=0<br>
      vwnd=0<br>
      endif<br>
<br>
      If (wspd &gt;= 0)<br>
         xloc=HodXcent+uwnd*RingSpac/HodRing<br>
         yloc=HodYcent+vwnd*RingSpac/HodRing<br>
         If (xloc &gt; 0 &amp; yloc &gt; 0 &amp; xold &gt; 0 &amp; yold &gt; 0)<br>
            Depth=Depth+pold-pres<br>
            count=count+1<br>
            If (count = 1)<br>
               &quot;draw mark 3 &quot;xold &quot; &quot; yold &quot; 0.05&quot;<br>
            Endif<br>
            &quot;draw line &quot;xold&quot; &quot;yold&quot; &quot;xloc&quot; &quot;yloc<br>
         Endif<br>
         xold=xloc<br>
         yold=yloc<br>
      Endif<br>
      zloop=zloop+1<br>
      pold=pres<br>
   EndWhile<br>
<br>
   If (count &gt; 0)<br>
      &quot;draw mark 3 &quot;xold &quot; &quot; yold &quot; 0.05&quot;<br>
   Endif<br>
Endif<br>
<br>
*----------------------------------------------<br>
* Calculate and Display Absolute &amp; S-R Helicity<br>
*----------------------------------------------<br>
<br>
If (DrawHeli = 1)<br>
   say &quot;Calculating Helicity &amp; SR Helicity.&quot;<br>
   delp=10<br>
   UTotal=0<br>
   VTotal=0<br>
<br>
* First, calculate mass-weighted mean wind<br>
* Since delp is a constant, and mass is proportional to<br>
* delp, this is a simple sum.<br>
<br>
   &quot;set lev &quot;_pmax &quot; &quot; _pmin<br>
   &quot;define uwndarr=&quot;sndspd&quot;*cos((270-&quot;snddir&quot;)*&quot;_dtr&quot;)&quot;<br>
   &quot;define vwndarr=&quot;sndspd&quot;*sin((270-&quot;snddir&quot;)*&quot;_dtr&quot;)&quot;<br>
<br>
   pres=MeanVBot<br>
   While (pres &gt;= MeanVTop)<br>
      uwnd=interp(uwndarr,pres)*_ktm<br>
      vwnd=interp(vwndarr,pres)*_ktm<br>
      If (uwnd &gt; -900 &amp; vwnd &gt; -900)<br>
         UTotal=UTotal+uwnd<br>
         VTotal=VTotal+vwnd<br>
      Endif<br>
      pres=pres-delp<br>
   EndWhile<br>
   vcount=1+(MeanVBot-MeanVTop)/delp<br>
   Umean=UTotal/vcount<br>
   Vmean=VTotal/vcount<br>
   Spdmean=GetWSpd(Umean,Vmean)<br>
   MeanDir=GetWDir(Umean,Vmean)<br>
<br>
* Now, rotate and reduce mean wind to get storm motion<br>
<br>
   If (StormMot = 1)<br>
      If (Spdmean &lt; 15)<br>
         Reduct=0.25<br>
         Rotate=30<br>
      Else<br>
         Reduct=0.20<br>
         Rotate=20<br>
      Endif<br>
   Else<br>
      Reduct=0.0<br>
      Rotate=0.0<br>
   Endif<br>
<br>
   UReduce=(1-Reduct)*Umean<br>
   VReduce=(1-Reduct)*Vmean<br>
   StormSpd=GetWSpd(UReduce,VReduce)<br>
<br>
   StormDir=GetWDir(UReduce,VReduce)+Rotate<br>
   If (StormDir &gt;= 360)<br>
      StormDir=StormDir-360<br>
   Endif<br>
<br>
   StormU=GetUWnd(StormSpd,StormDir)<br>
   StormV=GetVWnd(StormSpd,StormDir)<br>
<br>
* Draw Storm Motion Vector<br>
<br>
   xloc=HodXcent+_mtk*StormU*RingSpac/HodRing<br>
   yloc=HodYcent+_mtk*StormV*RingSpac/HodRing<br>
<br>
   &quot;set line 1 1 4&quot;<br>
   &quot;draw line &quot;HodXcent &quot; &quot; HodYcent &quot; &quot; xloc &quot; &quot; yloc<br>
   Arr1U=GetUWnd(HodRing/10,StormDir+30)<br>
   Arr1V=GetVWnd(HodRing/10,StormDir+30)<br>
   Arr2U=GetUWnd(HodRing/10,StormDir-30)<br>
   Arr2V=GetVWnd(HodRing/10,StormDir-30)<br>
<br>
   xloc2=xloc-Arr1U/HodRing<br>
   xloc3=xloc-Arr2U/HodRing<br>
   yloc2=yloc-Arr1V/HodRing<br>
   yloc3=yloc-Arr2V/HodRing<br>
<br>
   &quot;set line 1 1 3&quot;<br>
<br>
   If (FillArrw = 0)<br>
      &quot;draw line &quot;xloc&quot; &quot;yloc&quot; &quot;xloc2&quot; &quot;yloc2<br>
      &quot;draw line &quot;xloc&quot; &quot;yloc&quot; &quot;xloc3&quot; &quot;yloc3<br>
   Else<br>
      &quot;draw polyf &quot;xloc&quot; &quot;yloc&quot; &quot;xloc2&quot; &quot;yloc2&quot; &quot;xloc3&quot; &quot;yloc3&quot; &quot;xloc&quot; &quot;yloc<br>
   Endif<br>
<br>
<br>
* Now, calculate SR and Environmental Helicity<br>
<br>
   helic=0<br>
   SRhelic=0<br>
   MinP=SfcPlev-HelicDep<br>
   pres=SfcPlev<br>
   uwndold=-999<br>
   vwndold=-999<br>
   While (pres &gt;= MinP)<br>
      uwnd=interp(uwndarr,pres)*_ktm<br>
      vwnd=interp(vwndarr,pres)*_ktm<br>
      If (uwnd &gt; -900 &amp; uwndold &gt; -900)<br>
          du=uwnd-uwndold<br>
          dv=vwnd-vwndold<br>
          ubar=0.5*(uwnd+uwndold)<br>
          vbar=0.5*(vwnd+vwndold)<br>
          uhelic=-dv*ubar<br>
          vhelic=du*vbar<br>
          SRuhelic=-dv*(ubar-StormU)<br>
          SRvhelic=du*(vbar-StormV)<br>
          SRhelic=SRhelic+SRuhelic+SRvhelic<br>
          helic=helic+uhelic+vhelic<br>
      Endif<br>
      uwndold=uwnd<br>
      vwndold=vwnd<br>
      pres=pres-delp<br>
   EndWhile<br>
<br>
   &quot;set strsiz 0.1&quot;<br>
   &quot;set string 1 l 3&quot;<br>
   If (PageType = &quot;Portrait&quot;)<br>
      If (Text4XC = -1)<br>
         Text4XC=rxloc-0.75<br>
      Endif<br>
      If (Text4YC = -1)<br>
         Text4YC=tyloc-5.45<br>
      Endif<br>
   Else<br>
      If (Text4XC = -1)<br>
         Text4XC=rxloc+2.50<br>
      Endif<br>
      If (Text4YC = -1)<br>
         Text4YC=tyloc-6.10<br>
      Endif<br>
   Endif<br>
   &quot;set line 0 1 3&quot;<br>
   &quot;draw recf  &quot;Text4XC-0.75 &quot; &quot;Text4YC-0.5 &quot; &quot; Text4XC+0.75 &quot; &quot; Text4YC+0.5<br>
   &quot;set line 1 1 3&quot;<br>
   &quot;draw rec  &quot;Text4XC-0.75 &quot; &quot;Text4YC-0.5 &quot; &quot; Text4XC+0.75 &quot; &quot; Text4YC+0.5<br>
   &quot;draw string &quot;Text4XC-0.45 &quot; &quot; Text4YC+0.40 &quot; Hodograph&quot;<br>
   &quot;draw string &quot;Text4XC-0.70 &quot; &quot; Text4YC+0.20 &quot; EH&quot;<br>
   &quot;draw string &quot;Text4XC+0.25 &quot; &quot; Text4YC+0.20 &quot; &quot;int(helic)<br>
   &quot;draw string &quot;Text4XC-0.70 &quot; &quot; Text4YC+0.05 &quot; SREH&quot;<br>
   &quot;draw string &quot;Text4XC+0.25 &quot; &quot; Text4YC+0.05 &quot; &quot; int(SRhelic)<br>
   &quot;draw string &quot;Text4XC-0.70 &quot; &quot; Text4YC-0.20 &quot; StmDir&quot;<br>
   &quot;draw string &quot;Text4XC+0.25 &quot; &quot; Text4YC-0.20 &quot; &quot; int(StormDir)&quot;`3.`0&quot;<br>
   &quot;draw string &quot;Text4XC-0.70 &quot; &quot; Text4YC-0.35 &quot; StmSpd(kt)&quot;<br>
   &quot;draw string &quot;Text4XC+0.25 &quot; &quot; Text4YC-0.35 &quot; &quot; int(_mtk*StormSpd)<br>
Endif<br>
<br>
*---------------------------------------------------<br>
* Plot RH profile.<br>
*---------------------------------------------------<br>
<br>
If (DrawRH = 1)<br>
  &quot;set z &quot;_zmin&quot; &quot;_zmax<br>
  &quot;set x &quot;_xval<br>
  &quot;set y &quot;_yval<br>
  &quot;set t &quot;_tval<br>
  &quot;set zlog on&quot;<br>
  &quot;set gxout line&quot;<br>
  &quot;set ccolor &quot;RHCol<br>
  &quot;set cstyle &quot;RHLine<br>
  &quot;set cmark &quot;RHMrk<br>
  &quot;set digsiz &quot;MrkSize<br>
  &quot;set missconn on&quot;<br>
  &quot;set xlab on&quot;<br>
  &quot;set frame off&quot;<br>
  &quot;set vrange 0 350&quot;<br>
  &quot;set xlpos 0 t&quot;<br>
  &quot;set xlevs 25 50 75 100&quot;<br>
  &quot;set grid vertical 5&quot;<br>
  &quot;define rh=100*exp((17.2694*&quot;snddewp&quot;)/(&quot;snddewp&quot;+237.3)-(17.2694*&quot;sndtemp&quot;)/(&quot;sndtemp&quot;+237.3))&quot;<br>
  &quot;d rh&quot;<br>
   If (LblAxes = 1)<br>
     &quot;set string 1 c 3 0&quot;<br>
     &quot;set strsiz 0.125&quot;<br>
     If (PageType = &quot;Portrait&quot;)<br>
       &quot;draw string 1.5 10.85 RH (%)&quot;<br>
     Else<br>
       &quot;draw string 1.75 8.35 RH (%)&quot;<br>
     Endif<br>
   Endif<br>
Endif<br>
<br>
*------------------------------------------<br>
* Reset environment to original dimensions<br>
*------------------------------------------<br>
<br>
&quot;set t &quot;_tval<br>
&quot;set x &quot;_xval<br>
&quot;set y &quot;_yval<br>
&quot;set z &quot;_zmin &quot; &quot;_zmax<br>
<br>
say &quot;Done.&quot;<br>
<br>
*Return(0)<br>
<br>
*************************************************************************<br>
function Templcl(temp,dewp)<br>
<br>
*------------------------------------------------------<br>
* Calculate the temp at the LCL given temp &amp; dewp in C<br>
*------------------------------------------------------<br>
<br>
tempk=temp+273.15<br>
dewpk=dewp+273.15<br>
Parta=1/(dewpk-56)<br>
Partb=log(tempk/dewpk)/800<br>
Tlcl=1/(Parta+Partb)+56<br>
return(Tlcl-273.15)<br>
<br>
**************************************************************************<br>
<br>
function Preslcl(temp,dewp,pres)<br>
<br>
*-------------------------------------------------------<br>
* Calculate press of LCL given temp &amp; dewp in C and pressure<br>
*-------------------------------------------------------<br>
<br>
Tlclk=Templcl(temp,dewp)+273.15<br>
tempk=temp+273.15<br>
theta=tempk*pow(1000/pres,0.286)<br>
plcl=1000*pow(Tlclk/theta,3.48)<br>
return(plcl)<br>
<br>
**************************************************************************<br>
function LiftWet(startt,startp,endp,display,Pmin,Pmax)<br>
<br>
*--------------------------------------------------------------------<br>
* Lift a parcel moist adiabatically from startp to endp.<br>
* Init temp is startt in C.  If you wish to see the parcel&#39;s<br>
* path plotted, display should be 1.  Returns temp of parcel at endp.<br>
*--------------------------------------------------------------------<br>
<br>
temp=startt<br>
pres=startp<br>
cont = 1<br>
delp=10<br>
While (pres &gt;= endp &amp; cont = 1)<br>
    If (display = 1)<br>
       xtemp=GetXLoc(temp,pres)<br>
       &quot;q w2xy &quot;xtemp&quot; &quot;pres<br>
       xloc=subwrd(result,3)<br>
       yloc=subwrd(result,6)<br>
       If (xtemp &lt; 0 | xtemp &gt; 100)<br>
          cont=0<br>
       Else<br>
          If (pres &gt;= Pmin &amp; pres &lt; Pmax &amp; pres &lt; startp)<br>
             &quot;draw line &quot;xold&quot; &quot;yold&quot; &quot;xloc&quot; &quot;yloc<br>
          Endif<br>
       Endif<br>
    Endif<br>
    xold=xloc<br>
    yold=yloc<br>
    temp=temp-100*delp*gammaw(temp,pres-delp/2,100)<br>
    pres=pres-delp<br>
EndWhile<br>
return(temp)<br>
<br>
<br>
**************************************************************************<br>
function LiftDry(startt,startp,endp,display,Pmin,Pmax)<br>
<br>
*--------------------------------------------------------------------<br>
* Lift a parcel dry adiabatically from startp to endp.<br>
* Init temp is startt in C.  If you wish to see the parcel&#39;s<br>
* path plotted, display should be 1.  Returns temp of parcel at endp.<br>
*--------------------------------------------------------------------<br>
<br>
starttk=startt+273.15<br>
cont = 1<br>
delp=10<br>
round=int(startp/10)*10<br>
subscr=0.1*round<br>
powstart=pow(startp,-0.286)<br>
temp=starttk*_powpres.subscr*powstart-273.15<br>
pres=round-10<br>
While (pres &gt;= endp &amp; cont = 1)<br>
    subscr=0.1*pres<br>
    temp=starttk*_powpres.subscr*powstart-273.15<br>
    If (display = 1)<br>
       xtemp=GetXLoc(temp,pres)<br>
       &quot;q w2xy &quot;xtemp&quot; &quot;pres<br>
       xloc=subwrd(result,3)<br>
       yloc=subwrd(result,6)<br>
       If (xtempold &gt; 0 &amp; xtempold &lt; 100 &amp; xtemp &gt; 0 &amp; xtemp &lt; 100)<br>
          If (pres &gt;= Pmin &amp; pres &lt; Pmax &amp; pres &lt; startp)<br>
             &quot;draw line &quot;xold&quot; &quot;yold&quot; &quot;xloc&quot; &quot;yloc<br>
          Endif<br>
       Endif<br>
    Endif<br>
    xold=xloc<br>
    xtempold=xtemp<br>
    yold=yloc<br>
    pres=pres-delp<br>
EndWhile<br>
return(temp)<br>
<br>
**************************************************************************<br>
function CAPE(startt,startp,endp,sndtemp,snddewp)<br>
<br>
*---------------------------------------------------------------------<br>
* Returns all postive area and convective inhibition above LCL.<br>
* Parcel is lifted from LCL at startt,startp and is halted<br>
* at endp.   Integration method used is trapezoid method.<br>
*---------------------------------------------------------------------<br>
<br>
pres=startp<br>
PclTemp=startt<br>
PclTempV=virtual2(PclTemp+273.15,PclTemp+273.15,pres)-273.15<br>
delp=10<br>
Pos=0<br>
Neg=0<br>
Neg2=0<br>
<br>
count=0<br>
While (pres &gt;= endp)<br>
   EnvTemp=interp(sndtemp,pres)<br>
   EnvDewp=interp(snddewp,pres)<br>
   EnvTempV=virtual2(EnvTemp+273.15,EnvDewp+273.15,pres)-273.15<br>
   DelT=PclTempV-EnvTempV<br>
   If (abs(EnvTempV) &lt; 130 &amp; abs(PclTempV) &lt; 130)<br>
     count=count+1<br>
     If (count &gt; 1)<br>
       Val=DelT/pres+Prev<br>
       If (Val &gt; 0)<br>
          Pos=Pos+Val<br>
          Neg2=0<br>
       Else<br>
          Neg=Neg+abs(Val)<br>
          Neg2=Neg2+abs(Val)<br>
       Endif<br>
     Endif<br>
     Prev=DelT/pres<br>
   Endif<br>
   pres=pres-delp<br>
   PclTemp=PclTemp-100*delp*gammaw(PclTemp,pres,100)<br>
   PclTempV=virtual2(PclTemp+273.15,PclTemp+273.15,pres)-273.15<br>
Endwhile<br>
<br>
Pos=0.5*Pos*287*delp<br>
CIN=0.5*(Neg-Neg2)*287*delp<br>
<br>
return(Pos&quot; &quot;CIN)<br>
<br>
***************************************************************************<br>
function gammaw(tempc,pres,rh)<br>
<br>
*-----------------------------------------------------------------------<br>
* Function to calculate the moist adiabatic lapse rate (deg C/Pa) based<br>
* on the temperature, pressure, and rh of the environment.<br>
*----------------------------------------------------------------------<br>
<br>
tempk=tempc+273.15<br>
es=satvap2(tempc)<br>
ws=mixratio(es,pres)<br>
w=rh*ws/100<br>
tempv=virtual(tempk,w)<br>
latent=latentc(tempc)<br>
<br>
A=1.0+latent*ws/(287*tempk)<br>
B=1.0+0.622*latent*latent*ws/(1005*287*tempk*tempk)<br>
Density=100*pres/(287*tempv)<br>
lapse=(A/B)/(1005*Density)<br>
return(lapse)<br>
<br>
*************************************************************************<br>
function latentc(tempc)<br>
<br>
*-----------------------------------------------------------------------<br>
* Function to return the latent heat of condensation in J/kg given<br>
* temperature in degrees Celsius.<br>
*-----------------------------------------------------------------------<br>
<br>
val=2502.2-2.43089*tempc<br>
<br>
return(val*1000)<br>
<br>
*************************************************************************<br>
function precipw(sndtemp,snddewp,startp,endp)<br>
<br>
*-----------------------------------------------------------------------<br>
* Function to calculate the precipitable water (cm) in a sounding<br>
* starting at pressure level startp and ending at pressure level endp.<br>
*-----------------------------------------------------------------------<br>
<br>
ppold=-999<br>
ttold=-999<br>
ddold=-999<br>
delp=10<br>
Int=0<br>
mix=0<br>
pres=startp<br>
logpp=log(pres)<br>
logppm=log(pres-delp)<br>
while (pres &gt;= endp)<br>
   tt=interp(sndtemp,pres)<br>
   dd=interp(snddewp,pres)<br>
   if (tt&gt;-900 &amp; ttold&gt;-900 &amp; dd&gt;-900 &amp; ddold&gt;-900)<br>
      e=satvap2(dd)<br>
      mix=mixratio(e,pres)<br>
      mixavg=(logpp*mix+logppm*mixold)/(logpp+logppm)<br>
      Int=Int+1.020408*mixavg*delp<br>
   endif<br>
   ttold=tt<br>
   ddold=dd<br>
   ppold=pp<br>
   mixold=mix<br>
   pres=pres-delp<br>
   logpp=logppm<br>
   logppm=log(pres-delp)<br>
endwhile<br>
<br>
return(Int)<br>
<br>
*************************************************************************<br>
<br>
function virtual(temp,mix)<br>
<br>
*------------------------------------------------------------<br>
* Function to return virtual temperature given temperature in<br>
* kelvin and mixing ratio in g/g.<br>
*-------------------------------------------------------------<br>
<br>
tempv=temp*(1.0+0.6*mix)<br>
<br>
return (tempv)<br>
<br>
************************************************************************<br>
<br>
function virtual2(temp,dewp,pres)<br>
<br>
*------------------------------------------------------------<br>
* Function to return virtual temperature in kelvin given temperature in<br>
* kelvin and dewpoint in kelvin and pressure in mb<br>
*-------------------------------------------------------------<br>
<br>
if (temp &gt; 0 &amp; dewp &gt; 0)<br>
  vap=satvap2(dewp-273.15)<br>
  mix=mixratio(vap,pres)<br>
  tempv=virtual(temp,mix)<br>
else<br>
  tempv=-9999<br>
endif<br>
<br>
return (tempv)<br>
<br>
************************************************************************<br>
<br>
function satvapor(temp)<br>
<br>
*---------------------------------------------------------------<br>
* Given temp in Celsius, returns saturation vapor pressure in mb<br>
*---------------------------------------------------------------<br>
<br>
pol=_C0+temp*(_C1+temp*(_C2+temp*(_C3+temp*(_C4+temp*(_C5+temp*(_C6+temp*(_C7+temp*(_C8+temp*(_C9)))))))))<br>
<br>
return(6.1078/pow(pol,8))<br>
<br>
************************************************************************<br>
<br>
function satvap2(temp)<br>
<br>
*---------------------------------------------------------------<br>
* Given temp in Celsius, returns saturation vapor pressure in mb<br>
*---------------------------------------------------------------<br>
<br>
es=6.112*exp(17.67*temp/(temp+243.5))<br>
<br>
return(es)<br>
<br>
*************************************************************************<br>
<br>
function mixratio(e,p)<br>
<br>
*------------------------------------------------------<br>
* Given vapor pressure and pressure, return mixing ratio<br>
*-------------------------------------------------------<br>
<br>
mix=0.622*e/(p-e)<br>
<br>
return(mix)<br>
<br>
************************************************************************<br>
<br>
function getrh(temp,dewp,pres)<br>
<br>
tempk=temp+273.15<br>
dewpk=dewp+273.15<br>
<br>
es=satvap2(temp)<br>
<br>
If (temp &gt; 0)<br>
   A=2.53*pow(10,9)<br>
   B=5420<br>
Else<br>
   A=3.41*pow(10,10)<br>
   B=6130<br>
Endif<br>
<br>
w=A*0.622*exp(-B/dewpk)/pres<br>
ws=mixratio(es,pres)<br>
<br>
return(100*w/ws)<br>
<br>
************************************************************************<br>
function interp(array,pres)<br>
<br>
*------------------------------------------------------------------------<br>
* Interpolate inside array for pressure level pres.<br>
* Returns estimated value of array at pressure pres.<br>
*------------------------------------------------------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;set lev &quot;pres<br>
altpres=subwrd(result,4)<br>
&quot;q dims&quot;<br>
rec=sublin(result,4)<br>
zlev=subwrd(rec,9)<br>
<br>
If (zlev &lt; 2 | zlev &gt; _zmaxfile)<br>
  Vest = -9999.0<br>
Else<br>
  If (altpres &gt; pres)<br>
    zlev=zlev+1<br>
  Endif<br>
  &quot;set z &quot;zlev<br>
  PAbove=subwrd(result,4)<br>
  &quot;d &quot;array&quot;(lev=&quot;PAbove&quot;)&quot;<br>
  rec=sublin(result,8)<br>
  VAbove=subwrd(rec,4)<br>
  &quot;set z &quot;zlev-1<br>
  PBelow=subwrd(result,4)<br>
  &quot;d &quot;array&quot;(lev=&quot;PBelow&quot;)&quot;<br>
  rec=sublin(result,8)<br>
  VBelow=subwrd(rec,4)<br>
<br>
* Now if we are in a region of missing data, find next good level.<br>
<br>
  If (abs(VAbove) &gt; 130 &amp; zlev &gt; 1 &amp; zlev &lt; _zmaxfile)<br>
     zz=zlev<br>
     While (abs(VAbove) &gt; 130 &amp; zz &lt; _zmaxfile)<br>
       zz=zz+1<br>
       &quot;set z &quot;zz<br>
       PAbove=subwrd(result,4)<br>
       &quot;d &quot;array&quot;(lev=&quot;PAbove&quot;)&quot;<br>
       rec=sublin(result,8)<br>
       VAbove=subwrd(rec,4)<br>
     EndWhile<br>
  Endif<br>
<br>
  If (abs(VBelow) &gt; 130 &amp; zlev &gt; 1 &amp; zlev &lt; _zmaxfile)<br>
      zz=zlev-1<br>
      While (abs(VBelow) &gt; 130 &amp; zz &gt; 1)<br>
        zz=zz-1<br>
        &quot;set z &quot;zz<br>
        PBelow=subwrd(result,4)<br>
        &quot;d &quot;array&quot;(lev=&quot;PBelow&quot;)&quot;<br>
        rec=sublin(result,8)<br>
        VBelow=subwrd(rec,4)<br>
      EndWhile<br>
  Endif<br>
<br>
  If (abs(VAbove) &lt; 130 &amp; abs(VBelow) &lt; 130)<br>
     Vest=VBelow+log(PBelow/pres)*(VAbove-VBelow)/log(PBelow/PAbove)<br>
  Else<br>
     Vest=-9999.0<br>
  Endif<br>
<br>
Endif<br>
<br>
Return(Vest)<br>
<br>
****************************************************************************<br>
<br>
function GetUWnd(wspd,wdir)<br>
<br>
*------------------------<br>
* Get x-component of wind.<br>
*------------------------<br>
<br>
<br>
If (wspd &gt;= 0)<br>
   xwind=wspd*cos((270-wdir)*_dtr)<br>
Else<br>
   xwind = -9999.0<br>
Endif<br>
return(xwind)<br>
<br>
**************************************************************************<br>
<br>
function GetVWnd(wspd,wdir)<br>
<br>
*-----------------------<br>
* Get y-component of wind<br>
*------------------------<br>
<br>
If (wspd &gt;= 0)<br>
   ywind=wspd*sin((270-wdir)*_dtr)<br>
Else<br>
   ywind = -9999.0<br>
Endif<br>
return(ywind)<br>
<br>
<br>
*************************************************************************<br>
<br>
function GetWSpd(xwind,ywind)<br>
<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d mag(&quot;xwind&quot;,&quot;ywind&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
<br>
return (val)<br>
<br>
*************************************************************************<br>
<br>
function GetWDir(xwind,ywind)<br>
<br>
* Return wind direction given x and y components<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;define theta=270-&quot;_rtd&quot;*atan2(&quot;ywind&quot;,&quot;xwind&quot;)&quot;<br>
&quot;d theta&quot;<br>
rec=sublin(result,8)<br>
Dir=subwrd(rec,4)<br>
<br>
If (Dir &gt; 360)<br>
   Dir=Dir-360<br>
Endif<br>
<br>
If (Dir &lt; 0)<br>
   Dir=360+Dir<br>
Endif<br>
<br>
return(Dir)<br>
<br>
*************************************************************************<br>
<br>
function GetXLoc(temp,pres)<br>
<br>
*-------------------------------------------------<br>
* Get x-location on skew-t based on temp, pressure<br>
*-------------------------------------------------<br>
<br>
xloc=(temp-_m1*log10(pres)-_m3)/_m2<br>
return(xloc)<br>
<br>
*************************************************************************<br>
<br>
function GetTemp(xloc,pres)<br>
<br>
*-------------------------------------------------<br>
* Return temperature at location given by xloc,pres<br>
*-------------------------------------------------<br>
<br>
tempval=_m1*log10(pres)+_m2*xloc+_m3<br>
return(tempval)<br>
<br>
**************************************************************************<br>
<br>
function GetTheta(temp,pres)<br>
<br>
*---------------------------------------------------<br>
* Calculate theta for a given temperature and pressure<br>
*---------------------------------------------------<br>
<br>
theta=(temp+273.15)*pow(1000/pres,0.286)-273.15<br>
return(theta)<br>
<br>
<br>
*************************************************************************<br>
<br>
function GetThet2(temp,dewp,pres)<br>
<br>
*---------------------------------------------------<br>
* Calculate theta for a given temperature,dewp, and pressure<br>
*---------------------------------------------------<br>
<br>
tempk=273.15+temp<br>
dewpk=273.15+dewp<br>
<br>
es=satvap2(temp)<br>
ws=mixratio(es,pres)<br>
<br>
mix=10*getrh(temp,dewp,pres)*ws<br>
<br>
exponent=0.2854*(1.0-0.00028*mix)<br>
theta=(temp+273.15)*pow(1000/pres,exponent)-273.15<br>
return(theta)<br>
<br>
*************************************************************************<br>
<br>
function Thetae(temp,dewp,pres)<br>
<br>
*--------------------------------------------------------------<br>
* Return equiv. pot. temp in Kelvin given temp, dewp in celsius<br>
* From Bolton (1980) Mon Wea Rev<br>
*--------------------------------------------------------------<br>
<br>
es=satvap2(temp)<br>
ws=mixratio(es,pres)<br>
mix=10*getrh(temp,dewp,pres)*ws<br>
theta=GetThet2(temp,dewp,pres)+273.15<br>
TLcl=Templcl(temp,dewp)+273.15<br>
thetae=theta*exp((3.376/TLcl-0.00254)*mix*(1.0+0.00081*mix))<br>
<br>
return(thetae)<br>
<br>
**************************************************************************<br>
<br>
<br>
function int(i0)<br>
<br>
*--------------------------<br>
* Return integer of i0<br>
*--------------------------<br>
  i=0<br>
  while(i&lt;12)<br>
    i=i+1<br>
    if(substr(i0,i,1)=&#39;.&#39;)<br>
      i0=substr(i0,1,i-1)<br>
      break<br>
    endif<br>
  endwhile<br>
return(i0)<br>
<br>
*************************************************************************<br>
<br>
function abs(i)<br>
<br>
*----------------------------<br>
* return absolute value of i<br>
*----------------------------<br>
<br>
  if (i &lt; 0)<br>
     absval=-i<br>
  else<br>
     absval=i<br>
  endif<br>
<br>
return(absval)<br>
<br>
*************************************************************************<br>
<br>
function log(i)<br>
<br>
*---------------------------<br>
* return natural log of i<br>
*---------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d log(&quot;i&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
return(val)<br>
<br>
*************************************************************************<br>
<br>
function log10(i)<br>
<br>
*--------------------------<br>
* return log base 10 of i<br>
*--------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d log10(&quot;i&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
return(val)<br>
<br>
*************************************************************************<br>
<br>
function pow(i,j)<br>
<br>
*-------------------------------<br>
* return power of i raised to j<br>
*-------------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d pow(&quot;i&quot;,&quot;j&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
return(val)<br>
<br>
************************************************************************<br>
<br>
function cos(i)<br>
<br>
*-----------------------------------------<br>
* return cosine of i, where i is in radians<br>
*------------------------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d cos(&quot;i&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
return(val)<br>
<br>
************************************************************************<br>
<br>
function sin(i)<br>
<br>
*------------------------------------------<br>
* return sine of i, where i is in radians<br>
*------------------------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d sin(&quot;i&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
return(val)<br>
<br>
************************************************************************<br>
<br>
function exp(i)<br>
<br>
*------------------------------------------<br>
* return exponential of i<br>
*------------------------------------------<br>
<br>
&quot;set gxout stat&quot;<br>
&quot;d exp(&quot;i&quot;)&quot;<br>
rec=sublin(result,8)<br>
val=subwrd(rec,4)<br>
return(val)<br>
<br>
***********************************************************************<br>
function round(i)<br>
<br>
rr=abs(1.0*i)<br>
rr=int(rr+0.5)<br>
if (i &lt; 0)<br>
   rr=-1*rr<br>
endif<br>
return(rr)<br>
<br>
<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://gradsusr.org/pipermail/gradsusr/attachments/20101108/1c1328b3/attachment.html" target="_blank">http://gradsusr.org/pipermail/gradsusr/attachments/20101108/1c1328b3/attachment.html</a><br>
<br>
------------------------------<div class="im"><br>
<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>
<br>
<br></div>
End of gradsusr Digest, Vol 9, Issue 13<br>
***************************************<br>
</blockquote></div><br>
<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>Iowa State University<br>Meteorology Graduate Student<br>3134 Agronomy Hall<br><a href="http://www.meteor.iastate.edu/~jdduda">www.meteor.iastate.edu/~jdduda</a><br>