tidy3d.Coords#
- class Coords[source]#
Bases:
Tidy3dBaseModel
Holds data about a set of x,y,z positions on a grid.
- Parameters:
attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields,
attrs
are mutable. For example, the following is allowed for setting anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.json()
.x (ArrayLike[dtype=float, ndim=1]) – 1-dimensional array of x coordinates.
y (ArrayLike[dtype=float, ndim=1]) – 1-dimensional array of y coordinates.
z (ArrayLike[dtype=float, ndim=1]) – 1-dimensional array of z coordinates.
Example
>>> x = np.linspace(-1, 1, 10) >>> y = np.linspace(-1, 1, 11) >>> z = np.linspace(-1, 1, 12) >>> coords = Coords(x=x, y=y, z=z)
Attributes
Return a dict of the three Coord1D objects as numpy arrays.
Return a list of the three Coord1D objects as numpy arrays.
Methods
spatial_interp
(array, interp_method[, ...])Similar to
xarrray.DataArray.interp
with 2 enhancements:Inherited Common Usage
- x#
- y#
- z#
- property to_dict#
Return a dict of the three Coord1D objects as numpy arrays.
- property to_list#
Return a list of the three Coord1D objects as numpy arrays.
- spatial_interp(array, interp_method, fill_value='extrapolate')[source]#
Similar to
xarrray.DataArray.interp
with 2 enhancements:1) (if input data is an
xarrray.DataArray
) Check if the coordinate of the supplied data are in monotonically increasing order. If they are, apply the fasterassume_sorted=True
.Data is assumed invariant along zero-size dimensions (if any).
- Parameters:
array (Union[) –
SpatialDataArray
,ScalarFieldDataArray
,TriangularGridDataset
,TetrahedralGridDataset
,] – Supplied scalar dataset
interp_method (
InterpMethod
) – Interpolation method.fill_value (Union[Literal['extrapolate'], float] = "extrapolate") – Value used to fill in for points outside the data range. If set to ‘extrapolate’, values will be extrapolated into those regions using the “nearest” method.
- Returns:
The interpolated spatial dataset.
- Return type:
Union[
SpatialDataArray
,ScalarFieldDataArray
]
Note
This method is called from a
Coords
instance with the array to be interpolated as an argument, not the other way around.
- __hash__()#
Hash method.