import sys
import time
import numpy as np
import mwa_hyperbeam
if len(sys.argv) > 1 and sys.argv[1] == "rts":
beam = mwa_hyperbeam.AnalyticBeam(rts_behaviour=True)
else:
beam = mwa_hyperbeam.AnalyticBeam()
n = 1000000
az_rad = np.linspace(0, 0.9 * np.pi, n)
za_rad = np.linspace(0.1, 0.9 * np.pi / 2, n)
freq_hz = 167000000
delays = [0] * 16
amps = [1.0] * 16
latitude_rad = -0.4660608448386394
norm_to_zenith = True
start_time = time.time()
jones = beam.calc_jones_array(
az_rad, za_rad, freq_hz, delays, amps, latitude_rad, norm_to_zenith
)
duration = time.time() - start_time
print("Time to calculate {} directions: {:.3}s".format(n, duration))
print("First Jones matrix:")
print(jones[0])
amps = np.ones(32)
amps[-1] = 0
jones = beam.calc_jones_array(
az_rad[:1], za_rad[:1], freq_hz, delays, amps, latitude_rad, norm_to_zenith
)
print("First Jones matrix with altered Y amps:")
print(jones[0])
beam = mwa_hyperbeam.AnalyticBeam(bowties_per_row=8)
az_rad = 45.0 * np.pi / 180.0
za_rad = 80.0 * np.pi / 180.0
freq_hz = 51200000
delays_cram = [
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
3, 2, 1, 0, 3, 2, 1, 0,
]
amps_cram = [
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 0, 1,
]
jones = beam.calc_jones(
az_rad, za_rad, freq_hz, delays_cram, amps_cram, latitude_rad, norm_to_zenith
)
print("The CRAM Jones matrix:")
print(jones)