mtuq.grid.UnstructuredGrid¶
- class mtuq.grid.UnstructuredGrid(dims=None, coords=None, start=0, stop=None, callback=None)[source]¶
Bases:
object
An UnstructuredGrid is defined by lists of individual coordinate points, which can be irregularly spaced
Example
Unstructured grid consisting of N randomly-chosen points within the unit square:
x = np.random.rand(N) y = np.random.rand(N) grid = UnstructuredGrid(dims=('x', 'y'), coords=(x, y))
Iterating over grids
Iterating over an unstructured grid is similar to iterating over a list.
If
start
andstop
arguments are given when creating an unstructured grid, iteration will begin and end at these indices. Otherwise, iteration will begin at the first index (i=0) and stop at the last index.Accessing individual grid points
Individual grid points can be accessed through the
get
andget_dict
methods.get(i)
returns the i-th grid point as a NumPy array.If a
callback
function is given when creating an unstructured grid, thenget
returns the result of applying the callback to the i-th grid point. This behavior can be overridden by supplying a callback function as a keyword argument toget
itself. Ifcallback
isNone
, then no function is applied.get_dict(i)
returns the i-th grid point as a dictionary of coordinate axis names and coordinate values without applying any callback.Public Methods
Returns i-th grid point
Returns i-th grid point as a dictionary of parameter names and values
Partitions grid for parallel processing
Returns the entire set of grid points as a NumPy array
Returns the entire set of grid points as a pandas.DataFrame