tidy3d.components.data.data_array.AbstractSpatialDataArray#
- class AbstractSpatialDataArray[source]#
-
Spatial distribution.
Methods
does_cover(bounds[, rtol, atol])Check whether data fully covers specified by
boundsspatial region.interpolate_to_grid(grid, *[, offset, ...])Interpolate onto a target grid, with optional spatial offset and output ordering.
item(*args)Copy an element of an array to a standard Python scalar and return it.
plot(*args[, field, grid])Plot the spatial data.
searchsorted(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order.
sel_inside(bounds, *[, include_interp_padding])Return a new SpatialDataArray that contains the minimal amount data necessary to cover a spatial region defined by
bounds.shifted_spatial_coords(center)Return a copy with spatial coordinates shifted by
center.- plot(*args, field=True, grid=False, **kwargs)[source]#
Plot the spatial data.
Accepts the same arguments as xarray’s
DataArray.plot(). The extragridandfieldkeyword arguments are accepted for API compatibility withTriangularGridDataset.plot()but grid overlay is not supported on structured data.- Parameters:
field (bool = True) – Whether to plot the data field. Must be
Truefor structured data.grid (bool = False) – Not supported for structured data. Raises
DataErrorifTrue.
- interpolate_to_grid(grid, *, offset=None, method='linear', target_dims=None)[source]#
Interpolate onto a target grid, with optional spatial offset and output ordering.
- sel_inside(bounds, *, include_interp_padding=True)[source]#
Return a new SpatialDataArray that contains the minimal amount data necessary to cover a spatial region defined by
bounds. Note that the returned data is sorted with respect to spatial coordinates.- Parameters:
bounds (Tuple[float, float, float], Tuple[float, float float]) – Min and max bounds packaged as
(minx, miny, minz), (maxx, maxy, maxz).- Returns:
SpatialDataArray – Extracted spatial data array.
include_interp_padding (bool = True) – If
True(default), include neighbor points around bounds to support interpolation. IfFalse, keep only points whose coordinates are inside bounds.
- does_cover(bounds, rtol=0.0, atol=0.0)[source]#
Check whether data fully covers specified by
boundsspatial region. If data contains only one point along a given direction, then it is assumed the data is constant along that direction and coverage is not checked.- Parameters:
- Returns:
Full cover check outcome.
- Return type:
- item(*args)#
Copy an element of an array to a standard Python scalar and return it.
- Parameters:
*args (Arguments (variable number and type)) –
none: in this case, the method only works for arrays with one element (a.size == 1), which element is copied into a standard Python scalar object and returned.
int_type: this argument is interpreted as a flat index into the array, specifying which element to copy and return.
tuple of int_types: functions as does a single int_type argument, except that the argument is interpreted as an nd-index into the array.
- Returns:
z – A copy of the specified element of the array as a suitable Python scalar
- Return type:
Standard Python scalar object
Notes
When the data type of a is longdouble or clongdouble, item() returns a scalar array object because there is no available Python scalar that would not lose information. Void arrays return a buffer object for item(), unless fields are defined, in which case a tuple is returned.
item is very similar to a[args], except, instead of an array scalar, a standard Python scalar is returned. This can be useful for speeding up access to elements of the array and doing arithmetic on elements of the array using Python’s optimized math.
Examples
>>> import numpy as np >>> np.random.seed(123) >>> x = np.random.randint(9, size=(3, 3)) >>> x array([[2, 2, 6], [1, 3, 6], [1, 0, 1]]) >>> x.item(3) 1 >>> x.item(7) 0 >>> x.item((0, 1)) 2 >>> x.item((2, 2)) 1
For an array with object dtype, elements are returned as-is.
>>> a = np.array([np.int64(1)], dtype=object) >>> a.item() #return np.int64 np.int64(1)
- searchsorted(v, side='left', sorter=None)#
Find indices where elements of v should be inserted in a to maintain order.
For full documentation, see numpy.searchsorted
See also
numpy.searchsortedequivalent function