def test_azel_to_cart(self): dec = 7 y = n.array([10.0, 0.0, 0.0]) y_ref = coord.azel_to_cart(90.0, 0.0, 10.0) nt.assert_array_almost_equal(y, y_ref, decimal=dec) y = n.array([0.0, 10.0, 0.0]) y_ref = coord.azel_to_cart(0.0, 0.0, 10.0) nt.assert_array_almost_equal(y, y_ref, decimal=dec) y = n.array([0.0, 0.0, 10.0]) y_ref = coord.azel_to_cart(0.0, 90.0, 10.0) nt.assert_array_almost_equal(y, y_ref, decimal=dec) y = n.array([10.0, 0.0, 10.0]) y_ref = coord.azel_to_cart(90.0, 45.0, n.sqrt(200.0)) nt.assert_array_almost_equal(y, y_ref, decimal=dec)
def point(self, az0, el0): '''Point beam towards azimuth and elevation coordinate. :param float az0: Azimuth of pointing direction in dgreees east of north. :param float el0: Elevation of pointing direction in degrees from horizon. ''' self.az0 = az0 self.el0 = el0 self.on_axis = coord.azel_to_cart(az0, el0, 1.0)
def __init__(self, gain_func, az0, el0, I_0, f, beam_name=''): self.I_0 = I_0 self.f = f self.az0 = az0 self.el0 = el0 self.on_axis = coord.azel_to_cart(az0, el0, 1.0) self.gain_func = gain_func self.beam_name = beam_name
def planar_beam(az0, el0, I_0, f, a0, az1, el1): '''# TODO: Description. ''' beam = antenna.BeamPattern(planar, az0, el0, I_0, f, beam_name='Planar') beam.a0 = a0 beam.plane_normal = coord.azel_to_cart(az1, el1, 1.0) beam.lam = c.c / f beam.point(az0, el0) return beam
def angle(self, az, el): '''Get angle between azimuth and elevation and pointing direction. :param float az: Azimuth in dgreees east of north to measure from. :param float el: Elevation in degrees from horizon to measure from. :return: Angle in degrees. :rtype: float ''' direction = coord.azel_to_cart(az, el, 1.0) return coord.angle_deg(self.on_axis, direction)
def local_pointing(self, t): '''Returns the instantaneous pointing in local coordinates (ENU). :param float t: Seconds past a reference epoch to retrieve the pointing at. ''' point = self._pointing(t) if self._pointing_coord == 'ned': k0 = n.array([point[1], point[0], -point[2]], dtype=n.float) elif self._pointing_coord == 'enu': k0 = n.array([point[0], point[1], point[2]], dtype=n.float) elif self._pointing_coord == 'azel': k0 = coord.azel_to_cart(point[0], point[1], 1.0) return k0
def plot_gains(beams, res=1000, min_el=0.0, alpha=0.5): '''Plot the gain of a list of beam patterns as a function of elevation at :math:`0^\circ` degrees azimuth. :param list beams: List of instances of :class:`antenna.BeamPattern`. :param int res: Number of points to devide the set elevation range into. :param float min_el: Minimum elevation in degrees, elevation range is from this number to :math:`90^\circ`. ''' #turn on TeX interperter plt.rc('text', usetex=True) fig = plt.figure(figsize=(15, 7)) ax = fig.add_subplot(111) theta = n.linspace(min_el, 90.0, num=res) S = n.zeros((res, len(beams))) for b, beam in enumerate(beams): for i, th in enumerate(theta): k = coord.azel_to_cart(0.0, th, 1.0) S[i, b] = beam.gain(k) for b in range(len(beams)): ax.plot(90 - theta, n.log10(S[:, b]) * 10.0, label="Gain " + beams[b].beam_name, alpha=alpha) ax.legend() bottom, top = plt.ylim() plt.ylim((0, top)) ax.set_xlabel('Zenith angle [deg]', fontsize=24) plt.xticks(fontsize=17) plt.yticks(fontsize=17) ax.set_ylabel('Gain $G$ [dB]', fontsize=24) ax.set_title('Gain patterns', fontsize=28) return fig, ax