Skip to content

Commit

Permalink
Add sdr.wavelength()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Aug 19, 2023
1 parent 0a7db7d commit c3b39c3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/sdr/_link_budget/_antenna.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@
from .._helper import export


@export
def wavelength(freq: float) -> float:
r"""
Calculates the wavelength $\lambda$ of a electromagnetic wave with frequency $f$.
$$\lambda = \frac{c}{f}$$
Arguments:
freq: The frequency $f$ in Hz of the signal.
Returns:
The wavelength $\lambda$ in meters.
Examples:
The wavelength of a 1 GHz signal is 0.3 meters.
.. ipython:: python
sdr.wavelength(1e9)
Group:
link-budget-antennas
"""
freq = np.asarray(freq)
return scipy.constants.speed_of_light / freq


@export
def parabolic_antenna(
freq: float,
Expand Down Expand Up @@ -62,7 +89,7 @@ def parabolic_antenna(
if not np.all((0 <= efficiency) & (efficiency <= 1)):
raise ValueError("Argument 'efficiency' must be between 0 and 1.")

lambda_ = scipy.constants.speed_of_light / freq # Wavelength in meters
lambda_ = wavelength(freq) # Wavelength in meters
G = (np.pi * diameter / lambda_) ** 2 * efficiency # Gain in linear units
G = db(G) # Gain in dBi

Expand Down

0 comments on commit c3b39c3

Please sign in to comment.