coordinates.mixins.coords.CoordinateOperationsMixin.create_coordinate_list#

CoordinateOperationsMixin.create_coordinate_list(coordinate_arrays: Sequence[ndarray], /, axes: Sequence[str] | None = None, *, fixed_axes: Dict[str, float] | None = None) List[ndarray | float][source]#

Assemble a list of coordinate components (arrays or scalars) in canonical axis order.

This method combines provided free axis arrays and fixed scalar values into a complete list of coordinates, ordered according to the coordinate system’s axes.

Parameters:
  • coordinate_arrays (list of np.ndarray) –

    Array values corresponding to the free (swept) axes. Each array can be:

    • 1D (for simple swept coordinates, e.g., [0, 1, 2, 3]), or

    • ND (for pre-built grids created by numpy.meshgrid()).

  • axes (list of str, optional) – The complete list of axes (both free and fixed) represented by the inputs. Defaults to the canonical axis order self.axes if omitted.

  • fixed_axes (dict of {str: float}, optional) – A mapping of axis names to constant scalar values for axes held fixed. Scalars must be real numbers (floats or ints).

Returns:

A list of coordinate components, one for each canonical axis in self.axes.

  • Free axes are represented by the corresponding arrays (broadcast-compatible).

  • Fixed axes are represented by constant scalar values.

Return type:

list of numpy.ndarray or float

Raises:

ValueError

  • If unknown axes are provided. - If the number of provided coordinate arrays does not match the number of free axes. - If a fixed axis is specified that is not present in the overall axes list.

Examples

Construct a list with a mix of free (swept) and fixed coordinates:

>>> from pymetric.coordinates import SphericalCoordinateSystem
>>> from pymetric.utilities.logging import pg_log
>>> pg_log.level = 50
>>> cs = SphericalCoordinateSystem()
>>> r = np.linspace(0, 1, 100)
>>> phi = np.linspace(0, 2*np.pi, 200)
>>> coords = cs.create_coordinate_list([r, phi], fixed_axes={"theta": np.pi/2})
>>> [c.shape if isinstance(c, np.ndarray) else c for c in coords]
[(100,), 1.5707963267948966, (200,)]

Providing axes explicitly and out of order:

>>> coords = cs.create_coordinate_list([phi, r], axes=["phi", "theta", "r"], fixed_axes={"theta": np.pi/2})
>>> [c.shape if isinstance(c, np.ndarray) else c for c in coords]
[(100,), 1.5707963267948966, (200,)]