Re: Reducing the rank of an arbitrary variable

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 5 Dec 2007 09:19:44 -0700 (MST)

Jan,

I think this might work. It could be similar to what Saji suggested:

dims = dimsizes(V)
rdims = dims(1:) ; Get rightmost dimensions
rsize = product(rdims) ; Get # of elements
V1d = ndtooned(V)

do i = something,to_something
   ii = i*rsize ; Index into 1D array
   X = onedtond(V1d(ii:ii+rsize-1),rdims)
   ...
end do

--Mary

On Wed, 5 Dec 2007, Jan Ploski wrote:

> Hello,
>
> A few days ago I learned from Dennis how to increase dimensionality
> (rank), and now I am running into trouble with the opposite procedure.
> Given a variable V, which has n dimensions (n is not known until run time)
> and an index i, how can I efficiently copy V(i,:,:,...,:) to a new
> variable X with n-1 dimensions?
>
> Regards,
> Jan Ploski
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 05 2007 - 09:19:44 MST

This archive was generated by hypermail 2.2.0 : Wed Dec 05 2007 - 10:17:04 MST