<div dir="ltr"><br><div class="gmail_quote"><br><div dir="ltr"><div><div><div>Hi NCL user,<br><br></div>I would like to write final average corresponding to two different stations to single array. <br></div>Could someone help me to accomplish this? <br><br>Thank you,<br>Adv<br><br> fkey   = &quot;minnesota&quot;<br>strs=asciiread(&quot;minnesota50.csv&quot; , -1, &quot;string&quot;)<br>;***********************************************<br>; user specified YYYYMM and VARIABLE<br>;***********************************************<br>  yyyymm = 197301<br>  fldstr = &quot;PRCP&quot;                                         ; case sensitive<br>  con    = 1.00<br>  dat=new((/1/),float)<br>;***********************************************<br>; match all data lines with specified YYYYYY<br>;***********************************************<br><br>  seldata = str_match_ic_regex(strs, tostring(yyyymm))    ; 6.3.0<br>;  seldata = str_match_ic_regex(strs, 1973)    ; 6.3.0<br>;  print(seldata)<br>  print(&quot;=====&quot;)<br>n=(/&quot;THIEF&quot;,&quot;PARK&quot;/)<br>print(n)<br><br>do i =0, dimsizes(n)-1<br>strkey = n(i)<br>print(strkey)<br>;strkey= &quot;THIEF&quot;<br>;print(strkey)<br>;return<br>; find all lines (rows) which contain the key string<br><br>  seldata1 = str_match_ic_regex(seldata, strkey)     ; 6.3.0  onward<br>print(seldata1)<br>print(dimsizes(seldata1))<br>;***********************************************<br>; write selected data to ascii file<br>;***********************************************<br><br>  seldir  = &quot;./&quot;<br>  selfil  = fkey+&quot;.&quot;+yyyymm+&quot;.csv&quot;<br>  system(&quot;/bin/rm -f &quot;+seldir+selfil)<br>  asciiwrite(seldir+selfil, seldata1)   ; all data for selected yyyymm<br>;***********************************************<br>; Which field matches<br>;***********************************************<br>FIELDS = (/&quot;STATION&quot;,&quot;STATION_NAME&quot;,&quot;ELEVATION&quot;,&quot;LATITUDE&quot;,&quot;LONGITUDE&quot;    \<br>          ,&quot;DATE&quot;,&quot;MDPR&quot;,&quot;MDSF&quot;,&quot;DAPR&quot;,&quot;DASF&quot;,&quot;PRCP&quot;,&quot;SNWD&quot;,&quot;SNOW&quot;        \<br>          ,&quot;TMAX&quot;,&quot;TMIN&quot;,&quot;TOBS&quot;                                           /)     <br><br><br>  nfield = ind(FIELDS.eq.fldstr) + 1      ; field to be extracted<br>  print(&quot;fldstr=&quot;+fldstr+&quot; corresponds to field number &quot;+nfield)<br>  print(&quot;=====&quot;)<br>;***********************************************<br>; extract the values<br>;***********************************************<br><br>  sdat   = str_get_field(seldata1 , 2, &quot;,&quot;)<br>;*********Monthly average********************************<br>  data   = tofloat( str_get_field(seldata1 , nfield, &quot;,&quot;) )*con<br>  data@_FillValue = -9999*con<br>  print(sdat+&quot; : &quot;+data)<br> print(&quot;=====&quot;)<br>;print(data)<br>;return<br>tavg=avg(data)<br>end do<br>print(tavg)<br>return<br></div><br></div>
</div><br></div>