tidy3d.Coords#

class Coords[source]#

Bases: Tidy3dBaseModel

Holds data about a set of x,y,z positions on a grid.

Parameters:
  • 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.

Methods

spatial_interp(array, interp_method[, ...])

Similar to xarrray.DataArray.interp with 2 enhancements:

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) Check if the coordinate of the supplied data are in monotonically increasing order. If they are, apply the faster assume_sorted=True.

  1. For axes of single entry, instead of error, apply isel() along the axis.

Parameters:
  • array (Union[SpatialDataArray, ScalarFieldDataArray]) – 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.