spectrochempy.diagonal
- diagonal(dataset, offset=0, dim='x', dtype=None, **kwargs)[source]
Return the diagonal of a 2D array.
As we reduce a 2D to a 1D we must specified which is the dimension for the coordinates to keep!.
- Parameters:
dataset (
NDDataset
or array-like) – Object from which to extract the diagonal.offset (int, optional) – Offset of the diagonal from the main diagonal. Can be positive or negative. Defaults to main diagonal (0).
dim (str, optional) – Dimension to keep for coordinates. By default it is the last (-1,
x
or another name if the default dimension name has been modified).dtype (dtype, optional) – The type of the returned array.
**kwargs – Additional keyword parameters to be passed to the NDDataset constructor.
- Returns:
diagonal – The diagonal of the input array.
See also
diag
Extract a diagonal or construct a diagonal array.
Examples
>>> nd = scp.full((2, 2), 0.5, units='s', title='initial') >>> nd NDDataset: [float64] s (shape: (y:2, x:2)) >>> nd.diagonal(title='diag') NDDataset: [float64] s (size: 2)