spectrochempy.stack๏ƒ

stack(*datasets, **kwargs)[source]๏ƒ

Stack of NDDataset objects along a new dimension.

Any number of NDDataset objects can be stacked. For this operation to be defined the following must be true :

  1. all inputs must be valid dataset objects,

  2. units of data and axis must be compatible (rescaling is applied automatically if necessary).

Parameters:
  • *datasets (a series of NDDataset) โ€“ The dataset to be stacked to the current dataset.

  • **kwargs โ€“ Optional keyword parameters.

Other Parameters:

axis (int, optional, default=0) โ€“ Stacking axis.

  • axis=0 preserves the historical behavior and stacks datasets along a new leading dimension.

  • axis=1 is supported for 1D datasets and promotes them to a 2D dataset with profiles stacked as columns.

Returns:

out โ€“ A NDDataset created from the stack of the datasets datasets.

See also

concatenate

Concatenate NDDataset objects along a given dimension.

Examples

>>> A = scp.read('irdata/nh4y-activation.spg', protocol='omnic')
>>> B = scp.read('irdata/nh4y-activation.scp')
>>> C = scp.stack(A, B)
>>> print(C)
NDDataset: [float64] a.u. (shape: (z:2, y:55, x:5549))

Stack 1D profiles as columns in a 2D dataset

>>> t = scp.linspace(0, 1, 5)
>>> profiles = [np.exp(-((t - c) ** 2) / 0.05) for c in (0.2, 0.5)]
>>> C = scp.stack(profiles, axis=1)
>>> C.shape
(5, 2)

Create 1D datasets from a coordinate and stack them as columns:

>>> time = scp.Coord.linspace(0, 1, 200, title="time")
>>> data1 = scp.exp(-0.5 * ((time.data - 0.25) / 0.10) ** 2)
>>> data2 = 0.8 * scp.exp(-0.5 * ((time.data - 0.55) / 0.12) ** 2)
>>> c1 = scp.NDDataset(data1, coordset=[time], title="C1")
>>> c2 = scp.NDDataset(data2, coordset=[time], title="C2")
>>> profiles = scp.stack([c1, c2], axis=1)
>>> profiles.shape
(200, 2)

Examples using spectrochempy.stack๏ƒ

Build synthetic concentration profiles

Build synthetic concentration profiles

Built-in line-shape helpers

Built-in line-shape helpers