tidy3d.FreqRange#
- class FreqRange[source]#
Bases:
Tidy3dBaseModelConvenience 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,
attrsare mutable. For example, the following is allowed for setting anattrobj.attrs['foo'] = bar. Also note that Tidy3D` will raise aTypeErrorifattrscontain objects that can not be serialized. One can check ifattrsare 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
freq0and frequency bandwidthfwidth; - frequency interval [fmin,``fmax``]; - central wavelengthwvl0and 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
fmaxfrom central frequencyfreq0and bandwidthfwidth.Infer lowest frequency
fminfrom central frequencyfreq0and bandwidthfwidth.Get central wavelength from central frequency and bandwidth.
Methods
freqs(num_points[, spacing])method
freqs()returns a numpy array ofnum_pointfrequencies uniformly sampled from the specified frequency range; ifnum_points == 1method returns the central frequencyfreq0.from_freq_interval(fmin, fmax)method
from_freq_interval()creates instance of classFreqRangefrom frequency interval defined by argumentsfminandfmax.from_wvl(wvl0, wvl_width)method
from_wvl()updated instance of classFreqRangeby reassigning new frequency- and wavelength-related parameters.from_wvl_interval(wvl_min, wvl_max)method
from_wvl_interval()updated instance of classFreqRangeby reassigning new frequency- and wavelength-related parameters.to_gaussian_pulse(**kwargs)to_gaussian_pulse(): Return a
GaussianPulseinstance based on this frequency range.wvls(num_points[, spacing])method
wvls()returns a numpy array ofnum_pointswavelengths uniformly sampled from the range of wavelengths; ifnum_points == 1the method returns central wavelengthwvl0.Inherited Common Usage
- freq0#
- fwidth#
- property fmin#
Infer lowest frequency
fminfrom central frequencyfreq0and bandwidthfwidth.
- property fmax#
Infer highest frequency
fmaxfrom central frequencyfreq0and 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 classFreqRangefrom frequency interval defined by argumentsfminandfmax.NB: central frequency never corresponds to central wavelength!
freq0 = (fmin + fmax) / 2implies thatwvl0 != (wvl_min + wvl_max) / 2and vise-versa.- Parameters:
fmin (float) – Lower bound of frequency of interest.
fmax (float) – Upper bound of frequency of interest.
- Returns:
An instance of
FreqRangedefined by frequency interval [fmin,fmax].- Return type:
- classmethod from_wvl(wvl0, wvl_width)[source]#
method
from_wvl()updated instance of classFreqRangeby reassigning new frequency- and wavelength-related parameters.NB: central frequency never corresponds to central wavelength!
wvl0 = (wvl_min + wvl_max) / 2implies thatfreq0 != (fmin + fmax) / 2and vise versa.- Parameters:
wvl0 (float) – Real-valued central wavelength.
wvl_width (float) – Real-valued wavelength range.
- Returns:
An instance of
FreqRangedefined by central wavelengthwvl0and wavelength rangewvl_width.- Return type:
- classmethod from_wvl_interval(wvl_min, wvl_max)[source]#
method
from_wvl_interval()updated instance of classFreqRangeby reassigning new frequency- and wavelength-related parameters.NB: central frequency never corresponds to central wavelength!
wvl0 = (wvl_min + wvl_max) / 2implies 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
FreqRangedefined by the wavelength interval [wvl_min,wvl_max].- Return type:
- freqs(num_points, spacing='uniform_freq')[source]#
method
freqs()returns a numpy array ofnum_pointfrequencies uniformly sampled from the specified frequency range; ifnum_points == 1method 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_pointswavelengths uniformly sampled from the range of wavelengths; ifnum_points == 1the 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
GaussianPulseinstance based on this frequency range.This method constructs a
GaussianPulseusingGaussianPulse.from_frequency_range(fmin=self.fmin, fmax=self.fmax, **kwargs).If you prefer to define the pulse using
freq0andfwidthdirectly, you should manually instantiate theGaussianPulseinstead.- Parameters:
kwargs (dict) – Keyword arguments passed to
GaussianPulse(), excludingfreq0&fwidth.- Returns:
A
GaussianPulsethat maximizes its amplitude in the frequency range [fmin,fmax].- Return type:
- __hash__()#
Hash method.