[ncl-talk] Looping through strings to build new variable names

Michael Ventrice mventrice at wsi.com
Thu Jan 29 08:48:38 MST 2015


Hi all,

Is it possible to call in a string from an array in order to build a new
variable name using part of the string that was called in? I put a mock
example at the bottom that I'd think would be a way to do it... but
obviously it doesn't work :)

Thanks in advance,
Mike V.



  statID_array = (/"KALB","KLGA"/)


do i = 0, dimsizes(statID_array)-1
station = statID(i)

  k = 294

  station+"_MaxT" = new((/dimsizes(dates(i*k:i*k+i))/), "float")
  station+"_MaxT"!0 = "time"
  station+"_MaxT"&time = dates(i*k:i*k+i)
  station+"_MaxT"&time at units = dates at units
  station+"_MaxT" = (/maxT(i*k:i*k+i)/)

end do

;-----------------------------
; for i=0:
;KALB_MaxT = new((/dimsizes(dates(i*k:i*k+i))/), "float")
;KALB_MaxT!0 = "time"
;KALB_MaxT&time = dates(i*k:i*k+i)
;KALB_MaxT&time at units = dates at units
;KALB__MaxT" = (/maxT(i*k:i*k+i)/)

; for i=1:
;KLGA_MaxT = new((/dimsizes(dates(i*k:i*k+i))/), "float")
;KLGA_MaxT!0 = "time"
;KLGA_MaxT&time = dates(i*k:i*k+i)
;KLGA_MaxT&time at units = dates at units
;KLGA__MaxT" = (/maxT(i*k:i*k+i)/)


etc...

-- 
* Michael **Ventrice, Ph.D.  **|* *Operational Scientist*
* w:* 978-983-6786      *e:* michael.ventrice at weather.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150129/185132c4/attachment.html 


More information about the ncl-talk mailing list