Frequency (pmrf.Frequency)
- class Frequency(start=0, stop=0, npoints=0, unit='Hz')[source]
Bases:
ModuleRepresents a frequency axis for paramrf models.
This class provides a container for a frequency band, defining the points at which network parameters are evaluated. The source code has been derived from the scikit-rf Frequency class, but with added JAX compatibility.
The primary purpose is to hold a vector of frequency points (f) and the corresponding frequency unit (unit). It provides numerous properties for accessing different representations of the frequency axis, such as angular frequency (w) and scaled frequency (f_scaled).
- Variables:
_f (jnp.ndarray) – The frequency vector in Hz.
_unit (str) – The frequency unit (e.g., ‘hz’, ‘ghz’). Marked as static for JAX/Equinox.
- Parameters:
Examples
import pmrf as prf import skrf as rf # Create a frequency axis from 1 to 2 GHz with 101 points freq = prf.Frequency(start=1, stop=2, npoints=101, unit='ghz') # Access properties like the frequency vector in Hz or radians/sec print(f"Frequency points in Hz: {freq.f[:5]}...") print(f"Angular frequency in rad/s: {freq.w[:5]}...") # Convert to a scikit-rf Frequency object skrf_freq = freq.to_skrf() print(f"Type after conversion: {type(skrf_freq)}") # Create from a scikit-rf Frequency object freq_from_skrf = prf.Frequency.from_skrf(skrf_freq)
- classmethod from_f(f, unit=None)[source]
Construct Frequency object from a frequency vector.
The unit is set by kwarg ‘unit’.
- Parameters:
f (scalar or array-like) – Frequency vector.
unit (FrequencyUnitT, optional) – Frequency unit of the band. Default is None (defaults to ‘Hz’).
- Returns:
The instantiated Frequency object.
- Return type:
Examples
>>> f = np.linspace(75,100,101) >>> rf.Frequency.from_f(f, unit='GHz')
- static from_skrf(skrf_frequency, *, unit=None)[source]
Create a pmrf.Frequency from a skrf.Frequency object.
- Parameters:
skrf_frequency (skrf.Frequency) – The scikit-rf Frequency object.
- Returns:
The equivalent pmrf Frequency object.
- Return type:
- to_skrf()[source]
Convert this pmrf.Frequency object to a skrf.Frequency object.
- Returns:
The equivalent scikit-rf Frequency object.
- Return type:
skrf.Frequency
- property start_scaled: float
The starting frequency in the specified unit.
- Returns:
Scaled start frequency.
- Return type:
- property stop_scaled: float
The stop frequency in the specified unit.
- Returns:
Scaled stop frequency.
- Return type:
- property npoints: int
The number of points in the frequency axis.
- Returns:
Number of points.
- Return type:
- property center: float
The center frequency in Hz.
- Returns:
The exact center frequency in Hz.
- Return type:
- property center_idx: int
The index of the frequency point closest to the center.
- Returns:
Index of the center frequency.
- Return type:
- property center_scaled: float
The center frequency in the specified unit.
- Returns:
The exact center frequency in the specified unit.
- Return type:
- property step: float
The frequency step size in Hz for evenly spaced sweeps.
- Returns:
Step size in Hz.
- Return type:
- property step_scaled: float
The frequency step size in the specified unit for evenly spaced sweeps.
- Returns:
Step size in units.
- Return type:
- property span_scaled: float
The frequency span (stop - start) in the specified unit.
- Returns:
Span in units.
- Return type:
- property f: Array
The frequency vector in Hz.
- Returns:
The frequency vector in Hz.
- Return type:
jnp.ndarray
- property f_scaled: Array
The frequency vector in the specified unit.
- Returns:
A frequency vector in the specified unit.
- Return type:
jnp.ndarray
- property w: Array
The angular frequency vector in radians/s.
Angular frequency is defined as \(\omega=2\pi f\).
- Returns:
Angular frequency in rad/s.
- Return type:
jnp.ndarray
- property df: Array
The gradient of the frequency vector, in Hz.
- Returns:
Gradient of frequency.
- Return type:
jnp.ndarray
- property df_scaled: Array
The gradient of the scaled frequency vector.
- Returns:
Gradient of scaled frequency.
- Return type:
jnp.ndarray
- property dw: Array
The gradient of the angular frequency vector, in rad/s.
- Returns:
Gradient of angular frequency.
- Return type:
jnp.ndarray