Re: Re: [ncl-talk] Reducing the rank of an arbitrary variable

From: Jan Ploski <Jan.Ploski_at_nyahnyahspammersnyahnyah>
Date: Thu, 6 Dec 2007 09:31:27 +0100

Mary Haley <haley_at_ucar.edu> schrieb am 12/05/2007 05:19:44 PM:

> 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

Thanks, Mary. This code works as expected (with a little extra 1d tip from
Dennis). Unfortunately, it is over 60 times slower than a direct
assignment X = V(i,:,:) - measured in a 100 times run with V dimensioned
200,3000,500. So I guess I will have to stick to my "optimized" redundant
routines for the time being - maybe this is something that can be
implemented natively in a next version of NCL?

-JPL
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 06 2007 - 01:31:27 MST

This archive was generated by hypermail 2.2.0 : Tue Dec 11 2007 - 14:19:21 MST