Example #1
0
'''
Using parameters
=================
'''
import matplotlib.pyplot as plt
import numpy as np
import pyant

beam = pyant.Airy(
    azimuth=[0, 45.0, 0],
    elevation=[89.0, 80.0, 60.0],
    frequency=[930e6, 230e6],
    I0=10**4.81,
    radius=np.linspace(10,23.0,num=20),
)

k = np.array([0,0,1.0]).T

#This is the shape and names of the parameters
print(f'beam.shape = {beam.shape}')
print(f'beam.parameters = {beam.parameters}')

#this means their values can be found trough the corresponding attributes
print(f'beam.radius = {beam.radius}')

#One needs to choose values for all parameters

#Either trough direct input into beam.gain
print(f'G = {beam.gain(k, pointing=k, frequency=314e6, radius=20.0)} ')
#pointing is the only parameter that supports also input by azimuth and elevation
print(f'G = {beam.gain(k, azimuth=20.2, elevation=89.1, frequency=314e6, radius=20.0)} ')
Example #2
0
'''
Vectorized gain functions
================================
'''
import time

import numpy as np
import pyant

kn = 500

ant = pyant.Airy(
    azimuth=45.0,
    elevation=75.0,
    frequency=930e6,
    I0=10**4.81,
    radius=23.0,
)

kx = np.linspace(-1, 1, num=kn)
ky = np.linspace(-1, 1, num=kn)

size = len(kx) * len(ky)

#loop version
start_time = time.time()

G = np.zeros((len(kx), len(ky)))
for i, x in enumerate(kx):
    for j, y in enumerate(ky):
        k = np.array([x, y, np.sqrt(1.0 - x**2 + y**2)])
Example #3
0
'''
Multiple pointing directions 
=============================
'''
import matplotlib.pyplot as plt
import numpy as np
import pyant

beam = pyant.Airy(
    azimuth=[0, 45.0, 0],
    elevation=[90.0, 80.0, 60.0],
    frequency=[930e6, 230e6],
    I0=10**4.81,
    radius=23.0,
)

print(
    f'Gain can be calculated with the following parameter sizes: {beam.shape}')
print(f'Corresponding to the following parameters: {beam.parameters}')
print(f'These are the default values:')
for key, val in zip(beam.parameters, beam.get_parameters(ind=None)):
    print(f'{key}: {val}')

k = np.array([[0, 0, 1.0], [0, 1, 1]]).T

print(
    f'Gain for {k[:,0]} and without giving parameter index: {beam.gain(k[:,0])}'
)

for pi in range(len(beam.azimuth)):
    print(
Example #4
0
'''
Airy disk movie
========================
'''
import numpy as np
import pyant

beam = pyant.Airy(
    azimuth=0,
    elevation=90.0,
    frequency=50e6,
    I0=10**4.81,
    radius=10.0,
)


def update(beam, item):
    beam.radius = item
    beam.elevation += 0.25
    return beam


pyant.plotting.gain_heatmap_movie(beam,
                                  iterable=np.linspace(10, 23, num=100),
                                  beam_update=update)
pyant.plotting.show()
Example #5
0
'''
Copy of beams
========================
'''

import pyant

import numpy as np

beam = pyant.Airy(
    azimuth=0,
    elevation=90.0,
    frequency=[930e6, 220e6],
    I0=10**4.81,
    radius=23.0,
)

beam_2 = beam.copy()

beam_2.sph_point(
    azimuth=0,
    elevation=45.0,
)
beam_2.frequency = beam_2.frequency[1:]

pyant.plotting.gain_heatmap(beam, resolution=301, min_elevation=80.0)
pyant.plotting.gain_heatmap(beam_2, resolution=301, min_elevation=80.0)
pyant.plotting.show()

xv, yv = np.meshgrid(np.linspace(-50, 50, num=22), np.linspace(-50, 50,
                                                               num=22))