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, - attrsare mutable. For example, the following is allowed for setting an- attr- obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a- TypeErrorif- attrscontain objects that can not be serialized. One can check if- attrsare serializable by calling- obj.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 bandwidth- fwidth; - frequency interval [- fmin,``fmax``]; - central wavelength- wvl0and wavelength range- wvl_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 frequency- freq0and bandwidth- fwidth.- Infer lowest frequency - fminfrom central frequency- freq0and bandwidth- fwidth.- Get central wavelength from central frequency and bandwidth. - Methods - freqs(num_points[, spacing])- method - freqs()returns a numpy array of- num_pointfrequencies uniformly sampled from the specified frequency range; if- num_points == 1method returns the central frequency- freq0.- from_freq_interval(fmin, fmax)- method - from_freq_interval()creates instance of class- FreqRangefrom frequency interval defined by arguments- fminand- fmax.- from_wvl(wvl0, wvl_width)- method - from_wvl()updated instance of class- FreqRangeby reassigning new frequency- and wavelength-related parameters.- from_wvl_interval(wvl_min, wvl_max)- method - from_wvl_interval()updated instance of class- FreqRangeby 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 of- num_pointswavelengths uniformly sampled from the range of wavelengths; if- num_points == 1the method returns central wavelength- wvl0.- Inherited Common Usage - freq0#
 - fwidth#
 - property fmin#
- Infer lowest frequency - fminfrom central frequency- freq0and bandwidth- fwidth.
 - property fmax#
- Infer highest frequency - fmaxfrom central frequency- freq0and bandwidth- fwidth.
 - property wvl0#
- Get central wavelength from central frequency and bandwidth. 
 - classmethod from_freq_interval(fmin, fmax)[source]#
- method - from_freq_interval()creates instance of class- FreqRangefrom frequency interval defined by arguments- fminand- fmax.- NB: central frequency never corresponds to central wavelength! - freq0 = (fmin + fmax) / 2implies that- wvl0 != (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 class- FreqRangeby reassigning new frequency- and wavelength-related parameters.- NB: central frequency never corresponds to central wavelength! - wvl0 = (wvl_min + wvl_max) / 2implies that- freq0 != (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 wavelength- wvl0and wavelength range- wvl_width.
- Return type:
 
 - classmethod from_wvl_interval(wvl_min, wvl_max)[source]#
- method - from_wvl_interval()updated instance of class- FreqRangeby reassigning new frequency- and wavelength-related parameters.- NB: central frequency never corresponds to central wavelength! - wvl0 = (wvl_min + wvl_max) / 2implies that- freq0 != (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 of- num_pointfrequencies uniformly sampled from the specified frequency range; if- num_points == 1method returns the central frequency- freq0.- 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 to- uniform_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 of- num_pointswavelengths uniformly sampled from the range of wavelengths; if- num_points == 1the method returns central wavelength- wvl0.- 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 to- uniform_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 - GaussianPulseusing- GaussianPulse.from_frequency_range(fmin=self.fmin, fmax=self.fmax, **kwargs).- If you prefer to define the pulse using - freq0and- fwidthdirectly, you should manually instantiate the- GaussianPulseinstead.- Parameters:
- kwargs (dict) – Keyword arguments passed to - GaussianPulse(), excluding- freq0&- fwidth.
- Returns:
- A - GaussianPulsethat maximizes its amplitude in the frequency range [- fmin,- fmax].
- Return type:
 
 - __hash__()#
- Hash method.