[SciPy-User] Creating meshgrid from meshgrid
Chris Barker
chris.barker at noaa.gov
Tue Sep 5 19:54:27 EDT 2017
I'm confused as to what you are trying to do.
Meshgrid is used to create a regular grid when you have a vectors of the
axes.
It support 2 or more dimensions.
I have two arrays of size N (let's say 2 arrays of length 4) that I combine
> using np.meshgrid
>
> xxA, yyA = np.meshgrid(xA, yA)
> xxB, yyB = np.meshgrid(xB, yB)
>
> which gives me two meshes
>
> xx.shape = yy.shape = (4,4)
> which represent a N-dimensional mesh with 16 elements.
>
no -- it represents a 2-dimensional mesh with four nodes in each direction.
> Now I want to evaluate a function f on every possible pair of
> N-dimensional points in the grid, resulting in a 16 x 16
> matrix:
>
I think you are looking for a different function than meshgrid.
But if you want to evaluate a function on a four dimensional space, you can
use meshgrid with four dimensions:
xx, yy, zz, tt = meshgrid(x, y, z, t)
results = func(xx,yy,zz,tt)
note that with numpy's broadcasting, you may not need to use meshgrid at
all.
Is that what you are looking for?
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20170905/18c45112/attachment.html>
More information about the SciPy-User
mailing list