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 an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.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

to_dict

Return a dict of the three Coord1D objects as numpy arrays.

to_list

Return a list of the three Coord1D objects as numpy arrays.

attrs

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 faster assume_sorted=True.

  1. 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.