[SciPy-user] Create n-dim array from axis

David Huard david.huard@gmail....
Mon Mar 23 08:38:47 CDT 2009


Paul,

try
>>> mx, my = numpy.meshgrid(x, y)
>>> [zip(a,b) for (a,b) in zip(mx, my)]

HTH,

David


On Mon, Mar 23, 2009 at 3:54 AM, Paul Hilscher <
p.hilscher@lsw.uni-heidelberg.de> wrote:

> Dear all,
>
> I am looking for a function which takes some axes as an argument and
> produce the correspond n-dimensional array.
>
> So let's say we have two dimensions with following axis
>
> x = linspace(0.0,1.0,3)
> y = linspace(2.0,3.0,3)
>
> and we want to create the array by providing only the axis
>
> arr = create_array(x,y)
>
> and "create_array" produces then
>
> arr = array([[0.0,2.0], [0.5,2.0], [1.0,2.0]],
>    [[0.0,2.5], [0.5,2.5], [1.0,2.5]]
>            [[0.0,3.0], [0.5,3.0], [1.0,3.0]])
>
>
> I've been looking for quite a while now for such a function, but I did not
> found
> any versatile and clean one. Any hints ?
>
> Thanks for all help,
>
> Paul
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090323/243d587f/attachment.html 


More information about the SciPy-user mailing list