tidy3d.FreqRange#
- class FreqRange[source]#
Bases:
Tidy3dBaseModel
Convenience class for handling frequency/wavelength conversion; it simplifies specification of frequency ranges and sample points for sources and monitors.
- 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()
.freq0 (PositiveFloat) – [units = Hz]. Real-valued positive central frequency.
fwidth (PositiveFloat) – [units = Hz]. Real-valued positive width of the frequency range (bandwidth).
Notes
Depending on the context the user can define desired frequency range by specifying: - central frequency
freq0
and frequency bandwidthfwidth
; - frequency interval [fmin
,``fmax``]; - central wavelengthwvl0
and wavelength rangewvl_width
; - wavelength interval [wvl_min
,wvl_max
].Example
>>> import tidy3d as td >>> freq0 = 1e12 >>> fwidth = 1e11 >>> freq_range = td.FreqRange(freq0=freq0, fwidth=fwidth) >>> central_freq = freq_range.freqs(num_points=1, spacing="uniform_freq") >>> freqs = freq_range.freqs(num_points=11, spacing="uniform_wvl") >>> source = freq_range.to_gaussian_pulse()
Attributes
Infer highest frequency
fmax
from central frequencyfreq0
and bandwidthfwidth
.Infer lowest frequency
fmin
from central frequencyfreq0
and bandwidthfwidth
.Get central wavelength from central frequency and bandwidth.
Methods
freqs
(num_points[, spacing])method
freqs()
returns a numpy array ofnum_point
frequencies uniformly sampled from the specified frequency range; ifnum_points == 1
method returns the central frequencyfreq0
.from_freq_interval
(fmin, fmax)method
from_freq_interval()
creates instance of classFreqRange
from frequency interval defined by argumentsfmin
andfmax
.from_wvl
(wvl0, wvl_width)method
from_wvl()
updated instance of classFreqRange
by reassigning new frequency- and wavelength-related parameters.from_wvl_interval
(wvl_min, wvl_max)method
from_wvl_interval()
updated instance of classFreqRange
by reassigning new frequency- and wavelength-related parameters.to_gaussian_pulse
(**kwargs)to_gaussian_pulse(): Return a
GaussianPulse
instance based on this frequency range.wvls
(num_points[, spacing])method
wvls()
returns a numpy array ofnum_points
wavelengths uniformly sampled from the range of wavelengths; ifnum_points == 1
the method returns central wavelengthwvl0
.Inherited Common Usage
- freq0#
- fwidth#
- property fmin#
Infer lowest frequency
fmin
from central frequencyfreq0
and bandwidthfwidth
.
- property fmax#
Infer highest frequency
fmax
from central frequencyfreq0
and bandwidthfwidth
.
- property wvl0#
Get central wavelength from central frequency and bandwidth.
- classmethod from_freq_interval(fmin, fmax)[source]#
method
from_freq_interval()
creates instance of classFreqRange
from frequency interval defined by argumentsfmin
andfmax
.NB: central frequency never corresponds to central wavelength!
freq0 = (fmin + fmax) / 2
implies thatwvl0 != (wvl_min + wvl_max) / 2
and vise-versa.- Parameters:
fmin (float) – Lower bound of frequency of interest.
fmax (float) – Upper bound of frequency of interest.
- Returns:
An instance of
FreqRange
defined by frequency interval [fmin
,fmax
].- Return type:
- classmethod from_wvl(wvl0, wvl_width)[source]#
method
from_wvl()
updated instance of classFreqRange
by reassigning new frequency- and wavelength-related parameters.NB: central frequency never corresponds to central wavelength!
wvl0 = (wvl_min + wvl_max) / 2
implies thatfreq0 != (fmin + fmax) / 2
and vise versa.- Parameters:
wvl0 (float) – Real-valued central wavelength.
wvl_width (float) – Real-valued wavelength range.
- Returns:
An instance of
FreqRange
defined by central wavelengthwvl0
and wavelength rangewvl_width
.- Return type:
- classmethod from_wvl_interval(wvl_min, wvl_max)[source]#
method
from_wvl_interval()
updated instance of classFreqRange
by reassigning new frequency- and wavelength-related parameters.NB: central frequency never corresponds to central wavelength!
wvl0 = (wvl_min + wvl_max) / 2
implies thatfreq0 != (fmin + fmax) / 2
.- Parameters:
wvl_min (float) – The lowest wavelength of interest.
wvl_max (float) – The longest wavelength of interest.
- Returns:
An instance of
FreqRange
defined by the wavelength interval [wvl_min
,wvl_max
].- Return type:
- freqs(num_points, spacing='uniform_freq')[source]#
method
freqs()
returns a numpy array ofnum_point
frequencies uniformly sampled from the specified frequency range; ifnum_points == 1
method returns the central frequencyfreq0
.- Parameters:
num_points (int) – Number of frequency points in a frequency range of interest.
spacing (str = "uniform_freq") – Mode of frequency sampling. If spacing is set to
uniform_freq
, frequencies are sampled uniformly over the frequency interval. If set touniform_wvl
, frequencies correspond to uniformly sampled wavelengths over the wavelength interval. Frequencies are sorted in ascending order.
- Returns:
a numpy array of uniformly distributed frequency samples in a frequency range of interest.
- Return type:
np.ndarray
- wvls(num_points, spacing='uniform_wvl')[source]#
method
wvls()
returns a numpy array ofnum_points
wavelengths uniformly sampled from the range of wavelengths; ifnum_points == 1
the method returns central wavelengthwvl0
.- Parameters:
num_points (int) – Number of wavelength points in a range of wavelengths of interest.
spacing (str = "uniform_wvl") – Mode of wavelength sampling. If spacing is set to
uniform_wvl
, wavelengths are sampled uniformly over the wavelength interval. If set touniform_freq
, wavelengths correspond to uniformly sampled frequencies over the frequency interval. Wavelengths are sorted in ascending order.
- Returns:
a numpy array of uniformly distributed wavelength samples in ascending order.
- Return type:
np.ndarray
- to_gaussian_pulse(**kwargs)[source]#
to_gaussian_pulse(): Return a
GaussianPulse
instance based on this frequency range.This method constructs a
GaussianPulse
usingGaussianPulse.from_frequency_range(fmin=self.fmin, fmax=self.fmax, **kwargs)
.If you prefer to define the pulse using
freq0
andfwidth
directly, you should manually instantiate theGaussianPulse
instead.- Parameters:
kwargs (dict) – Keyword arguments passed to
GaussianPulse()
, excludingfreq0
&fwidth
.- Returns:
A
GaussianPulse
that maximizes its amplitude in the frequency range [fmin
,fmax
].- Return type:
- __hash__()#
Hash method.