<div dir="ltr"><div>Hi, so what I am trying to do here is to plot Streamline plots and Precipitation plots on the same plot...but when I try to create a loop for that I get lots of error messages that it doesn't recognize my variable 'precip' that's with my precip netcdf file. So, then I tried appending the precip file onto the end and just ended up with even messier code.</div>
<div><br></div><div>Is there a lot shorter, easier way I could do this code and get both precipitation and streamline winds on the same plot. Note that my years in this code come from text file 'NovJanPosQBO.txt' I also include that code at the end.</div>
<br><div><div>'reinit'</div><div>'set display color white';'c'</div><div>'set grid off'</div><div><br></div><div>*- - -</div><div> xl=0.4 ; yt=7.5</div><div> dx=2.3 ; dy=2.4</div><div>*- - -</div>
<div><br></div><div>size.1=10</div><div>size.2=42</div><div><br></div><div>file='NovJanPosQBO.txt'</div><div>ret=read(file)</div><div><br></div><div>n=1;while(n<=100)</div><div>ret=read(file)</div><div>chk=sublin(ret,1);if(chk>0);break;endif</div>
<div>ret=sublin(ret,2)</div><div><br></div><div>ip=1;while(ip<=2)</div><div> if(n<=size.ip)</div><div>* year.ip.n=substr(ret,ip)</div><div> year.1.n=substr(ret,1,4)</div><div> year.2.n=substr(ret,6,4)</div>
<div> endif</div><div>ip=ip+1;endwhile</div><div><br></div><div>n=n+1;endwhile</div><div><br></div><div>*= = = = = = = = =</div><div><br></div><div>'sdfopen /export1/Databank/NCEP_Month/pressure/<a href="http://uwnd.mon.mean.nc">uwnd.mon.mean.nc</a>'</div>
<div>'sdfopen /export1/Databank/NCEP_Month/pressure/<a href="http://vwnd.mon.mean.nc">vwnd.mon.mean.nc</a>'</div><div><br></div><div> lv=1 ; while(lv<=2)</div><div>'set t 17 775'</div><div> if(lv=1); 'set lev 30' ;endif</div>
<div> if(lv=2); 'set lev 200' ;endif</div><div>*if(lv=3); 'set lev 700' ;endif</div><div>*if(lv=4); 'set lev 1000' ;endif</div><div><br></div><div>'define pu1=ave(uwnd.1,t-3,t+3)'</div><div>
'define pu2=ave(uwnd.1,t-16,t+16)'</div><div>'define pufilter=pu1-pu2'</div><div>'define pv1=ave(vwnd.2,t-3,t+3)'</div></div><div><div>'define pv2=ave(vwnd.2,t-16,t+16)'</div><div>'define pvfilter=pv1-pv2'</div>
<div><br></div><div><br></div><div> ip=1 ; while(ip<=2)</div><div><br></div><div>'define ucomp'ip'=const(pufilter,0)'</div><div>'define vcomp'ip'=const(pvfilter,0)'</div><div><br></div><div>
n=1 ; while(n<=size.ip)</div><div><br></div><div> 'set time apr'year.ip.n</div><div> 'ucomp'ip'=ucomp'ip'+ave(pufilter,t-0,t+2)/'size.ip</div><div> 'vcomp'ip'=vcomp'ip'+ave(pvfilter,t-0,t+2)/'size.ip</div>
<div><br></div><div> n=n+1 ; endwhile</div><div><br></div><div> ip=ip+1 ; endwhile</div><div>* = = = = = = = = =</div><div>*'set gxout shaded'</div><div>'set gxout vector'</div><div>'umean=(ucomp1 + ucomp2)/2'</div>
<div>'vmean=(vcomp1 + vcomp2)/2'</div><div><br></div><div> ip=1 ; while(ip<=2)</div><div><br></div><div>'define utot'1'= ucomp'ip' - umean'</div><div>'define vtot'1'= vcomp'ip' - vmean'</div>
<div>ip=ip+1 ; endwhile</div><div><br></div><div><br></div><div>* plotting</div><div><br></div><div><br></div><div> ip=1 ; while(ip<=1)</div><div><br></div><div> xr=xl+dx</div><div> yb=yt-dy</div><div>'set parea 'xl' 'xr' 'yb' 'yt</div>
<div>'set lat -90 90'</div><div>'set lon 0 360'</div><div>'set lev 30'</div><div><br></div><div>'set mproj scaled'</div><div>'set mpdset mres'</div></div><div><div>'set ccolor 1'</div>
<div>'set map 11'</div><div>'set annot 1 2'</div><div>'set xlopts 15 1 0.08'</div><div>'set ylopts 15 1 0.08'</div><div><br></div><div>len=0.1</div><div>scale=3</div><div><br></div><div> 'color -10 10 -kind green->white->orangered'</div>
<div> 'd utot'1</div><div><br></div><div>*'set gxout vector'</div><div>*'set arrscl 'len' 'scale</div><div>*'set arrlab off'</div><div>*'set arrowhead -0.2'</div><div>*'d skip(utot'ip',6);skip(vtot'ip',6)'</div>
<div><br></div><div> 'set gxout stream'</div><div>'set cthick 1' ; 'set ccolor 1'</div><div> 'set strmden 1'</div><div> 'd utot'1';vtot'1</div><div><br></div><div>'set string 1 c 5'</div>
<div>'set strsiz 0.1 0.1'</div><div>'draw string 1.5 8.1 (1) Apr-Jun 30mb'</div><div>'draw string 1.5 7.9 Wind Anomaly for'</div><div>'draw string 1.5 7.7 QBO Positive Phase in Nov-Jan'</div>
<div><br></div><div><br></div><div>'set string 1 c 5'</div><div>'set strsiz 0.1 0.1'</div><div>'draw string 1.5 3.7 (1) Apr-Jun 200mb'</div><div>'draw string 1.5 3.5 Wind Anomaly for'</div>
<div>'draw string 1.5 3.3 QBO Positive Phase in Nov-Jan'</div><div><br></div><div><br></div><div><br></div><div> xl=xr+0.4</div><div> ip=ip+1 ; endwhile</div><div><br></div><div> xl=0.4</div><div> yt=yb-2.0</div><div>
lv=lv+1 ; endwhile</div></div><div><div>**********************QBO Positive Phase************************************</div><div><br></div><div>x0=5.5;y0=8.5</div><div>xl=x0; yt=y0</div><div>dx=3.0;dy=2.0</div><div><br></div>
<div>yb=yt-dy;xr=xl+dx</div><div><br></div><div>'sdfopen /export1/Databank/PRECIP/<a href="http://precl.mon.mean.1x1.nc">precl.mon.mean.1x1.nc</a>'</div><div>*'sdfopen /export1/Databank/PRECIP/<a href="http://precip.1x1.mon.mean.nc">precip.1x1.mon.mean.nc</a>'</div>
<div>'set t 17 770'</div><div>'define p1=ave(precip,t-3,t+3)'</div><div>'define p2=ave(precip,t-16,t+16)'</div><div>'define pfilter=p1-p2'</div><div>yy.1=1964</div><div>yy.2=1967</div><div>
yy.3=1976</div><div>yy.4=1983</div><div>yy.5=1986</div><div>yy.6=1988</div><div>yy.7=1991</div><div>yy.8=1993</div><div>yy.9=2009</div><div>yy.10=2011</div><div><br></div><div>month.1='apr'</div><div>month.2='may'</div>
<div>month.3='jun'</div><div><br></div><div>yr=1; while(yr<=10)</div><div><br></div><div>mm=1; while(mm<=3)</div><div>if(yr=1);'define sea'mm'= const(pfilter,0)';endif</div><div>year=yy.yr;mon=<a href="http://month.mm">month.mm</a></div>
<div>*say mm'/'year</div><div>'define sea'mm'= sea'mm'+ pfilter(time= 'mon''year')/10'</div><div>mm=mm+1;endwhile</div><div>yr=yr+1;endwhile</div><div><br></div><div>'set parea 'xl' 'xr' 'yb' 'yt</div>
<div>*say 'parea 'xl' 'xr' 'yb' 'yt</div></div><div><div>'define SeaTotal=(sea1+sea2+sea3)/3'</div><div><br></div><div>'set gxout shaded'</div><div>'color -0.3 0.3 0.03 -kind maroon->red->orangered->orange->yellow->white->white->lime->forestgreen->blue->midnightblue->darkviolet'</div>
<div><br></div><div>'set lat 20 50'</div><div>'set lon 190 300'</div><div>'set t 17'</div><div>'define avera1= ave(pfilter,time=01apr1950,time=01apr2011,12)/3'</div><div>'define avera2= ave(pfilter,time=01may1950,time=01may2011,12)/3'</div>
<div>'define avera3= ave(pfilter,time=01jun1950,time=01jun2011,12)/3'</div><div><br></div><div>'define TotalAvera= avera1+avera2+avera3'</div><div>'set mpdset hires'</div><div>'d (Seatotal-TotalAvera)'</div>
<div>'set string 1 tc 5'</div><div>'set strsiz 0.1 0.1'</div><div>'draw string 7.0 8.2 Apr-Jun Precipitation Anomaly'</div><div>'draw string 7.0 8.0 for QBO Nov-Jan Positive Years'</div><div>
'set csmooth on'</div><div>cbar(xr+0.14,yt-2.4,ik)</div><div>function cbar(x,y,k)</div><div> 'query shades'</div><div> shdinfo = result</div><div> if (subwrd(shdinfo,1)='None')</div><div> say 'Cannot plot color bar: No shading information'</div>
<div> return</div><div> endif</div><div>*</div><div> cnum = subwrd(shdinfo,5)</div><div>*</div><div>* Plot colorbar</div><div>*</div><div> dx=0.07</div><div> dy=0.12</div><div> x=x</div><div> y0=y</div><div>
<br></div><div> num = 0</div><div> while (num<cnum)</div><div><br></div><div> rec = sublin(shdinfo,num+2)</div><div> col = subwrd(rec,1)</div><div> hi = subwrd(rec,3)</div><div> 'set line 'col</div>
</div><div><div> 'draw recf 'x-dx' 'y' 'x' 'y+dy</div><div> 'set line 1 1 2'</div><div> 'draw rec 'x-dx' 'y' 'x' 'y+dy</div><div> if(num<cnum-1)</div>
<div> 'set string 1 l 2 0' ; 'set strsiz 0.07 0.08'</div><div> 'draw string 'x+0.02' 'y+dy' `0'hi</div><div> endif</div><div> num = num + 1</div><div> y=y+dy</div>
<div> endwhile</div><div><br></div><div>if(ik=1);'draw string 'x+0.02' 'y+dy'(km)';endif</div></div><div><br></div><div>NovJanPosQBO.txt text file code:</div><div><br></div><div><div>years others</div>
<div>1964 1960</div><div>1967 1961</div><div>1976 1962</div><div>1983 1963</div><div>1986 1965</div><div>1988 1966</div><div>1991 1968</div><div>1993 1969</div><div>2009 1970</div><div>2011 1971</div><div> 1972</div><div>
1973</div><div> 1974</div><div> 1975</div><div> 1977</div><div> 1978</div><div> 1979</div><div> 1980</div><div> 1981</div><div> 1982</div><div> 1984</div><div> 1985</div><div> 1987</div>
<div> 1989</div><div> 1990</div><div> 1992</div><div> 1994</div><div> 1995</div><div> 1996</div><div> 1997</div><div> 1998</div><div> 1999</div><div> 2000</div><div> 2001</div><div>
2002</div><div> 2003</div><div> 2004</div><div> 2005</div><div> 2006</div><div> 2007</div><div> 2008</div><div> 2010</div></div><div><br></div></div>