Is it possible to create an array of netCDF variables of the same dimension so they can easily be accessed by the same line of code?
For example I have a netCDF file:a=addfile(file,"r")
I want to access variables U, V and W in the netCDF file but don't want to write out a command for each variable:U=a->U(i:j,k:l,p:q,r:s)
Can I create some sort of array?: X=(/"U","V","W"/)
and access each variable in a loop:do t=0,2U=X{t}(i:j,k:l,p:q,r:s)[....do something..]delete(U)end do
a = addfile(flnm,"r") vars = getfilevarnames(a) ; gets a list of variables in flnm; could be replaced by a list like you have do i = 0, dimsizes(vars)-1 if (vars(i) .eq. "stream-heating") psi750 = a->$vars(i)$(0,{750},:,:) end if end doThe key point seems to be that your "X{t}" needs to be "$X(t)$".
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 9 03:28:47 2013
This archive was generated by hypermail 2.1.8 : Wed May 15 2013 - 10:19:28 MDT