thztools.timebase#

thztools.timebase(n, *, dt=None, t_init=0.0)[source]#

Timebase for time-domain waveforms.

Parameters:
nint

Number of samples.

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.

t_initfloat, optional

Value of the initial time point. Default is 0.0.

Returns:
tndarray

Array of time samples.

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.

Notes

This is a helper function that computes

t = t_init + dt * numpy.arange(n).

Examples

The following example computes the timebase with different methods for assigning the sampling time.

>>> import thztools as thz
>>> n, dt, t_init = 256, 0.05, 2.5
>>> t_1 = thz.timebase(n)
>>> t_2 = thz.timebase(n, dt=dt)
>>> thz.set_option("sampling_time", dt)
>>> t_3 = thz.timebase(n)
>>> t_4 = thz.timebase(n, t_init=t_init)
>>> print(t_1[:3])
[0. 1. 2.]
>>> print(t_2[:3])
[0.   0.05 0.1 ]
>>> print(t_3[:3])
[0.   0.05 0.1 ]
>>> print(t_4[:3])
[2.5  2.55 2.6 ]