thztools.scaleshift#

thztools.scaleshift(x, *, dt=None, a=None, eta=None, axis=-1)[source]#

Rescale and shift waveforms.

Parameters:
xarray_like

Data array.

dtfloat or None, optional

Sampling time, normally in picoseconds. Default is None, which sets the sampling time to thztools.options.sampling_time. If both dt and thztools.options.sampling_time are None, the sampling time is set to 1.0. In this case, eta must be given in units of the sampling time.

aarray_like, optional

Scale array.

etaarray_like, optional

Shift array.

axisint, optional

Axis over which to apply the correction. If not given, applies over the last axis in x.

Returns:
x_adjndarray

Adjusted data array.

Warns:
UserWarning

If thztools.options.sampling_time and the dt parameter are both not None and are set to different float values, the function will set the sampling time to dt and raise a UserWarning.

Examples

The following example makes an array with 4 identical copies of the signal mu returned by wave. It then uses scaleshift to rescale each copy by a = [1.0, 0.5, 0.25, 0.125] and shift it by eta = [0.0, 1.0, 2.0, 3.0].

>>> import numpy as np
>>> import thztools as thz
>>> from matplotlib import pyplot as plt
>>> n, dt = 256, 0.05
>>> t = thz.timebase(n, dt=dt)
>>> mu = thz.wave(n, dt=dt)
>>> m = 4
>>> x = np.repeat(np.atleast_2d(mu), m, axis=0)
>>> a = 0.5 ** np.arange(m)
>>> eta = np.arange(m)
>>> x_adj = thz.scaleshift(x, a=a, eta=eta, dt=dt)
>>> plt.plot(t, x_adj.T, label=[f"{k=}" for k in range(4)])
>>> plt.legend()
>>> plt.xlabel("t (ps)")
>>> plt.ylabel(r"$x_{\mathrm{adj}, k}$")
>>> plt.show()
../_images/thztools-scaleshift-1.png