Re: Increasing dimensionality

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 29 Nov 2007 08:26:43 -0700

I'm not sure if this is what you mean:

      xNew = onedtond( ndtooned(x), (/ 1, d(0), d(1) /) )

There is also the "conform" function. This expands an array
into the same size/shape as a *pre-existing array*. Perhaps,
this could be used.

http://www.ncl.ucar.edu/Document/Functions/Built-in/ndtooned.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/noedtond.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/conform.shtml

Jan Ploski wrote:
> Hello,
>
> Is there a simple way to increase the dimensionality of a variable?
>
> For example, I have this function:
>
> ; Inserts a time dimension with size = 1 into a 2d variable.
> ;
> function insert_time_dim2d(v)
> local d, nv
> begin
> d = dimsizes(v)
> nv = new((/ 1, d(0), d(1) /), typeof(v), "No_FillValue")
> nv(0,:,:) = v
> return nv
> end
>
> I'd like it to be independent from the dimensionality of the input
> variable v. Is there some smart way to implement the nv(0,..) = v
> assignment then or do would I have to use loops to copy each element
> individually?
>
> Best 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 Thu Nov 29 2007 - 08:26:43 MST

This archive was generated by hypermail 2.2.0 : Fri Nov 30 2007 - 10:55:49 MST