[ncl-talk] loop ncl array
Agud Pique, Enric
eagud.q at ccma.cat
Sat Dec 10 04:52:15 MST 2016
Hello,
The following code extract a variable from a wrfout file, modify the variable and save it again. This is for all the nTimes of the simulation. But, I would like to do it for only some hours of the simulation. How can I do it for exemple, for time 5,6,7,29, 30,31 if nTimes is for exemple 55?
Thank you, best
Enric
#####Code#######
begin
f = addfile(met_name,"rw")
;
; Extract variable
th2 = f->TH2
;
; Determine dimensions of the th2 field
;
dims = dimsizes(th2)
nTimes = dims(0)
south_north = dims(1)
west_east = dims(2)
print("nTimes dimension: "+nTimes)
print("South-North dimension: "+south_north)
print("West-East dimension: "+west_east)
;
; Modify the th2 as needed
;
iTime = 0
do l=0, nTimes-1
;do l=(/"5","6","7","29","30","31"/)
do j=0,south_north-1
do i=0,west_east-1
th2(l,j,i) = th2(l,j,i) + 1 ; increase Th2+ 1
end do
end do
end do
;print(th2)
f->TH2 = th2
end
More information about the ncl-talk
mailing list