VCSBeam
|
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <mwalib.h>
#include <mwa_hyperbeam.h>
#include "vcsbeam.h"
#include "gpu_macros.h"
Macros | |
#define | NCOMPLEXELEMENTS 4 |
Functions | |
void | handle_hyperbeam_error (char file[], int line_num, const char function_name[]) |
Calculates the beam model Jones matrices for the given pointings. More... | |
void | vmCalcB (vcsbeam_context *vm, beam_geom *beam_geom_vals) |
void | vmCreatePrimaryBeam (vcsbeam_context *vm) |
Allocates memory for the beam model Jones matrices. More... | |
void | free_primary_beam (primary_beam *pb) |
Frees the memory allocated in vmCreatePrimaryBeam() More... | |
void | create_delays_amps_from_metafits (MetafitsMetadata *obs_metadata, uint32_t ***delays, double ***amps) |
Constructs "delay" and "amp" arrays required by Hyperbeam. More... | |
void | free_delays_amps (MetafitsMetadata *obs_metadata, uint32_t **delays, double **amps) |
Frees the memory allocated in create_delays_amps_from_metafits(). More... | |
int | hash_dipole_config (double *amps) |
Implements a hash lookup for dead/live dipole configurations. More... | |
void | parallactic_angle_correction (double *Ppa, double lat, double az, double za) |
Calculates the parallactic angle correction matrix, \({\bf P}_\text{pa}\). More... | |
void | calc_normalised_beam_response (FEEBeam *beam, double az, double za, double freq_hz, uint32_t *delays, double *amps, double *IQUV, gpuDoubleComplex *J, bool apply_pa_correction) |
Calculates the normalised primary beam response to a Stokes I, Q, U, or V sky. More... | |
Variables | |
const double | Isky [] = { 0.5, 0. , 0. , 0. , 0. , 0. , 0.5, 0. } |
The coherency matrix for a pure Stokes I sky. More... | |
const double | Qsky [] = { 0.5, 0. , 0. , 0. , 0. , 0. , -0.5, 0. } |
The coherency matrix for a pure Stokes Q sky. More... | |
const double | Usky [] = { 0. , 0. , 0.5, 0. , 0.5, 0. , 0. , 0. } |
The coherency matrix for a pure Stokes U sky. More... | |
const double | Vsky [] = { 0. , 0. , 0. , -0.5, 0 , 0.5, 0. , 0. } |
The coherency matrix for a pure Stokes V sky. More... | |
const double * | sky [] = { Isky, Qsky, Usky, Vsky } |
The set of coherency matrices for pure Stokes I, Q, U, and V skies. More... | |
#define NCOMPLEXELEMENTS 4 |
void calc_normalised_beam_response | ( | FEEBeam * | beam, |
double | az, | ||
double | za, | ||
double | freq_hz, | ||
uint32_t * | delays, | ||
double * | amps, | ||
double * | IQUV, | ||
gpuDoubleComplex * | J, | ||
bool | apply_pa_correction | ||
) |
Calculates the normalised primary beam response to a Stokes I, Q, U, or V sky.
beam | A Hyperbeam object | |
[in] | az | The azimuth (radians) |
[in] | za | The zenith angle (radians) |
[in] | freq_hz | The frequency (Hz) |
[in] | delays | The dipole delays that define a primary beam pointing |
[in] | amps | The dipole amplitudes that define the live/dead configuration |
[out] | IQUV | The beam response |
[out] | J | A pointer to the beam model Jones matrix |
apply_pa_correction | Whether to apply the parallactic angle correction to J |
IQUV
must point to already-allocated memory with size \(N_s\).
This function will allocate memory for J
, which must be freed by the caller.
void create_delays_amps_from_metafits | ( | MetafitsMetadata * | obs_metadata, |
uint32_t *** | delays, | ||
double *** | amps | ||
) |
Constructs "delay" and "amp" arrays required by Hyperbeam.
[in] | obs_metadata | A MetafitsMetadata object containing the delays and amps. |
[out] | delays | A pointer to an array of delay values, with layout \(N_i \times N_d\) |
[out] | amps | A pointer to an array of amp values, with layout \(N_i \times N_d\) |
Delays can be brought directly across from the MetafitsMetadata struct. The "conversion" from delays to amps is straightforward: All amps are "1.0" unless the delay is 32, in which case the amp should be "0.0". (The value 32 is the number assigned to a faulty or broken dipole.)
This function allocates memory for both delays and amps. This can be freed by a call to free_delays_amps().
void free_delays_amps | ( | MetafitsMetadata * | obs_metadata, |
uint32_t ** | delays, | ||
double ** | amps | ||
) |
Frees the memory allocated in create_delays_amps_from_metafits().
obs_metadata | A MetafitsMetadata object |
delays | The array of delay values to be freed |
amps | The array of amp values to be freed |
Here, the MetafitsMetadata is used to find \(N_i\) (one of the dimensions of delays
and amps
).
void free_primary_beam | ( | primary_beam * | pb | ) |
Frees the memory allocated in vmCreatePrimaryBeam()
void handle_hyperbeam_error | ( | char | file[], |
int | line_num, | ||
const char | function_name[] | ||
) |
Calculates the beam model Jones matrices for the given pointings.
vm | The VCSBeam context struct |
beam_geom_vals | An array of beam_geom objects containing the pointing information |
This function uses Hyperbeam to calculate the beam model Jones matrices for each pointing in beam_geom_vals
.
Only those configurations of live (i.e. non-dead) dipoles which exist in the array are calculated, in order to save calculation time.
The parallactic angle correction is applied, so that the final matrices, which are stored in pb→B
, are in the basis
\[ {\bf B} = \begin{bmatrix} B_{qx} & B_{qy} \\ B_{px} & B_{py} \end{bmatrix}. \]
int hash_dipole_config | ( | double * | amps | ) |
Implements a hash lookup for dead/live dipole configurations.
amps | The array of amps whose configuration is to be hashed |
In order to avoid recalculating the FEE beam for repeated dipole configurations, we have to keep track of which configurations have already been calculated. We do this through a boolean array, and this function converts dipole configurations into indices of this array. In other words, this function assigns meaning to the array.
Since dead dipoles are relatively rare, we only consider configurations in which up to two dipoles are dead. Any more than that and the we can recalculate the Jones matrix with minimal entropy. In this case, this function returns MANY_DEAD_DIPOLES
. The other remaining cases are:
for a grand total of 138 indices. They are ordered as follows:
This function defines "dead" as amps=0.0, "live" otherwise.
void parallactic_angle_correction | ( | double * | Ppa, |
double | lat, | ||
double | az, | ||
double | za | ||
) |
Calculates the parallactic angle correction matrix, \({\bf P}_\text{pa}\).
[out] | Ppa | The output rotation matrix |
[in] | lat | The observing latitude (radians) |
[in] | az | The azimuth angle (radians) |
[in] | za | The zenith angle (radians) |
This function computes the parallactic angle correction matrix in the basis (see Parallactic angle correction):
\[ {\bf P}_\text{pa} = \begin{bmatrix} P_{\theta x} & P_{\theta y} \\ P_{\phi x} & P_{\phi y} \end{bmatrix}. \]
void vmCalcB | ( | vcsbeam_context * | vm, |
beam_geom * | beam_geom_vals | ||
) |
void vmCreatePrimaryBeam | ( | vcsbeam_context * | vm | ) |
Allocates memory for the beam model Jones matrices.
The resulting array (vm→B
) has dimensions \(N_b \times N_a \times N_p \times N_p\).
const double Isky[] = { 0.5, 0. , 0. , 0. , 0. , 0. , 0.5, 0. } |
The coherency matrix for a pure Stokes I sky.
const double Qsky[] = { 0.5, 0. , 0. , 0. , 0. , 0. , -0.5, 0. } |
The coherency matrix for a pure Stokes Q sky.
The set of coherency matrices for pure Stokes I, Q, U, and V skies.
const double Usky[] = { 0. , 0. , 0.5, 0. , 0.5, 0. , 0. , 0. } |
The coherency matrix for a pure Stokes U sky.
const double Vsky[] = { 0. , 0. , 0. , -0.5, 0 , 0.5, 0. , 0. } |
The coherency matrix for a pure Stokes V sky.