Skip to content
Snippets Groups Projects
Commit 800199d6 authored by Sepehr Madani's avatar Sepehr Madani
Browse files

Fixed relative import, formatting

parent 651dee88
No related branches found
No related tags found
No related merge requests found
from converter import deg_to_u, range_in_deg
from cmath import exp from cmath import exp
from math import radians, pi from math import pi, radians
def compute_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=None, calibration=None, degrees=None): from .converter import deg_to_u, range_in_deg
def compute_pattern(
res=0.1,
N=16,
k=1,
weights=None,
single_patterns=None,
calibration=None,
degrees=None,
):
"""Computes the pattern absolute value of the given parameters. """Computes the pattern absolute value of the given parameters.
res: the computation resolution. res: the computation resolution.
...@@ -16,14 +26,28 @@ def compute_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=None, cali ...@@ -16,14 +26,28 @@ def compute_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=None, cali
calibration values are assumed to be in degrees. calibration values are assumed to be in degrees.
""" """
single_pattern = compute_single_pattern(res=res, N=N, k=k, weights=weights, \ single_pattern = compute_single_pattern(
single_patterns=single_patterns, calibration=calibration, degrees=degrees) res=res,
N=N,
pattern = [abs(sum( pattern_i )) for pattern_i in single_pattern] k=k,
weights=weights,
single_patterns=single_patterns,
calibration=calibration,
degrees=degrees,
)
pattern = [abs(sum(pattern_i)) for pattern_i in single_pattern]
return pattern return pattern
def compute_single_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=None, calibration=None, degrees=None): def compute_single_pattern(
res=0.1,
N=16,
k=1,
weights=None,
single_patterns=None,
calibration=None,
degrees=None,
):
"""Computes the single pattern of each of the antennas given the parameters in a nested list. """Computes the single pattern of each of the antennas given the parameters in a nested list.
see compute_pattern for more details. see compute_pattern for more details.
""" """
...@@ -31,7 +55,7 @@ def compute_single_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=Non ...@@ -31,7 +55,7 @@ def compute_single_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=Non
degrees = range_in_deg(res) degrees = range_in_deg(res)
total_length = len(degrees) total_length = len(degrees)
if weights is None: if weights is None:
weights = [1] * N weights = [1] * N
if single_patterns is None: if single_patterns is None:
...@@ -42,17 +66,20 @@ def compute_single_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=Non ...@@ -42,17 +66,20 @@ def compute_single_pattern(res=0.1, N=16, k=1, weights=None, single_patterns=Non
cos_degs = deg_to_u(degrees) cos_degs = deg_to_u(degrees)
calibration_rad = [radians(x) for x in calibration] calibration_rad = [radians(x) for x in calibration]
assert len(weights) == len(calibration) == len(single_patterns) == N, \ assert (
"some vector here has the wrong length! (weights, calibration, single_patterns)" len(weights) == len(calibration) == len(single_patterns) == N
), "some vector here has the wrong length! (weights, calibration, single_patterns)"
single_pattern = [[weights[ant_i] * exp(-1j * (k * pi * u * ant_i - calibration_rad[ant_i])) \
for ant_i in range(N)] for u in cos_degs]
single_pattern = [
[
weights[ant_i] * exp(-1j * (k * pi * u * ant_i - calibration_rad[ant_i]))
for ant_i in range(N)
]
for u in cos_degs
]
return single_pattern return single_pattern
if __name__ == "__main__": if __name__ == "__main__":
print(compute_pattern()) print(compute_pattern())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment