tidy3d.components.time.AbstractTimeDependence#
- class AbstractTimeDependence[source]#
Bases:
ABC
,Tidy3dBaseModel
Base class describing time dependence.
- Parameters:
attrs (dict = {}) β Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields,
attrs
are mutable. For example, the following is allowed for setting anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.json()
.amplitude (NonNegativeFloat = 1.0) β Real-valued maximum amplitude of the time dependence.
phase (float = 0.0) β [units = rad]. Phase shift of the time dependence.
Attributes
Methods
amp_time
(time)Complex-valued amplitude as a function of time.
plot
(times[,Β val,Β ax])Plot the complex-valued amplitude of the time-dependence.
plot_spectrum_in_frequency_range
(times,Β ...)Plot the complex-valued amplitude of the time-dependence.
spectrum
(times,Β freqs,Β dt)Complex-valued spectrum as a function of frequency.
Inherited Common Usage
- amplitude#
- phase#
- abstract amp_time(time)[source]#
Complex-valued amplitude as a function of time.
- Parameters:
time (float) β Time in seconds.
- Returns:
Complex-valued amplitude at that time.
- Return type:
complex
- spectrum(times, freqs, dt)[source]#
Complex-valued spectrum as a function of frequency. Note: Only the real part of the time signal is used.
- Parameters:
times (np.ndarray) β Times to use to evaluate spectrum Fourier transform. (Typically the simulation time mesh).
freqs (np.ndarray) β Frequencies in Hz to evaluate spectrum at.
dt (float or np.ndarray) β Time step to weight FT integral with. If array, use to weigh each of the time intervals in
times
.
- Returns:
Complex-valued array (of len(freqs)) containing spectrum at those frequencies.
- Return type:
np.ndarray
- plot_spectrum_in_frequency_range(times, fmin, fmax, num_freqs=101, val='real', ax=None)[source]#
Plot the complex-valued amplitude of the time-dependence. Note: Only the real part of the time signal is used.
- Parameters:
times (np.ndarray) β Array of evenly-spaced times (seconds) to evaluate time-dependence at. The spectrum is computed from this value and the time frequency content. To see spectrum for a specific
Simulation
, passsimulation.tmesh
.fmin (float) β Lower bound of frequency for the spectrum plot.
fmax (float) β Upper bound of frequency for the spectrum plot.
num_freqs (int = 101) β Number of frequencies to plot within the [fmin, fmax].
ax (matplotlib.axes._subplots.Axes = None) β Matplotlib axes to plot on, if not specified, one is created.
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- plot(times, val='real', ax=None)[source]#
Plot the complex-valued amplitude of the time-dependence.
- Parameters:
times (np.ndarray) β Array of times (seconds) to plot source at. To see source time amplitude for a specific
Simulation
, passsimulation.tmesh
.val (Literal['real', 'imag', 'abs'] = 'real') β Which part of the spectrum to plot.
ax (matplotlib.axes._subplots.Axes = None) β Matplotlib axes to plot on, if not specified, one is created.
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- __hash__()#
Hash method.