Re: array reordering

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 31 Mar 2006 09:48:04 -0700 (MST)

> I have an array v with dims time,lat,lev,lon and I would like an array x
> with dims time,lev,ncol where ncol
> represents a collapse of lat x lon , the following gives a fairly
> uninformative syntax error. Oh wise and wonderful ncl oracle won't you
> suggest a better way?
>
> dims = getvardims(v)
> do i=0,sizes(1)-1
> do j=0,sizes(3)-1
> n=i*sizes(3)+j
> x($dims(0)$ | :,$dims(2)$ | :,n) = v($dims(0)$ |
> :,i,$dims(2)$ | :,j)
> end do
> end do
>
------------------
Whilst I sit on a mountain top chanting to the powers that be,
the following came to my consciousness:

             dims = getvardims(v)
             ntim = dims(0)
             klev = dims(1)
             nlat = dims(2)
             mlon = dims(3)

             vNew = onedtond( ndtooned(v), (/nlat,klev,nlat*mlon/) )
             printVarSummary(vNew) ; ^^^^^^^^^

---------------------
FYI: When I 1st looked at NCL, I thought the "onedtond" and "ndtooned"
      functions would rarely be used. I was wrong. I use
      them and the "ind" function often. They help avoid loops.

---------------------
Back to chanting ....

good luck
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Mar 31 2006 - 09:48:04 MST

This archive was generated by hypermail 2.2.0 : Fri Mar 31 2006 - 10:32:28 MST