Radio Interferometer Measurement Equation¶
Functions used to compute the terms of the Radio Interferometer Measurement Equation (RIME). It describes the response of an interferometer to a sky model.
where for antenna \(p\) and \(q\), and source \(s\):
- \(G_{p}\) represents direction-independent effects.
- \(E_{ps}\) represents direction-dependent effects.
- \(L_{p}\) represents the feed rotation.
- \(K_{ps}\) represents the phase delay term.
- \(B_{s}\) represents the brightness matrix.
The RIME is more formally described in the following four papers:
- I. A full-sky Jones formalism
- II. Calibration and direction-dependent effects
- III. Addressing direction-dependent effects in 21cm WSRT observations of 3C147
- IV. A generalized tensor formalism
Numpy¶
predict_vis(time_index, antenna1, antenna2) |
Multiply Jones terms together to form model visibilities according to the following formula: |
phase_delay(lm, uvw, frequency[, convention]) |
Computes the phase delay (K) term: |
parallactic_angles(times, antenna_positions, …) |
Computes parallactic angles per timestep for the given reference antenna position and field centre. |
feed_rotation(parallactic_angles[, feed_type]) |
Computes the 2x2 feed rotation (L) matrix from the parallactic_angles. |
transform_sources(lm, parallactic_angles, …) |
Creates beam sampling coordinates suitable for use in beam_cube_dde() by: |
beam_cube_dde(beam, beam_lm_extents, …) |
Evaluates Direction Dependent Effects along a source’s path by interpolating the values of a complex beam cube at the source location. |
zernike_dde(coords, coeffs, noll_index, …) |
Computes Direction Dependent Effects by evaluating Zernicke Polynomials defined by coefficients coeffs and noll indexes noll_index at the specified coordinates coords. |
wsclean_predict(uvw, lm, source_type, flux, …) |
Predict visibilities from a WSClean sky model. |
-
africanus.rime.predict_vis(time_index, antenna1, antenna2, dde1_jones=None, source_coh=None, dde2_jones=None, die1_jones=None, base_vis=None, die2_jones=None)[source]¶ Multiply Jones terms together to form model visibilities according to the following formula:
\[V_{pq} = G_{p} \left( B_{pq} + \sum_{s} E_{ps} X_{pqs} E_{qs}^H \right) G_{q}^H\]where for antenna \(p\) and \(q\), and source \(s\):
- \(B_{{pq}}\) represent base coherencies.
- \(E_{{ps}}\) represents Direction-Dependent Jones terms.
- \(X_{{pqs}}\) represents a coherency matrix (per-source).
- \(G_{{p}}\) represents Direction-Independent Jones terms.
Generally, \(E_{ps}\), \(G_{p}\), \(X_{pqs}\) should be formed by using the RIME API functions and combining them together with
einsum().Please read the Notes
Parameters: time_index :
numpy.ndarrayTime index used to look up the antenna Jones index for a particular baseline with shape
(row,). Obtainable vianp.unique(time, return_inverse=True)[1].antenna1 :
numpy.ndarrayAntenna 1 index used to look up the antenna Jones for a particular baseline. with shape
(row,).antenna2 :
numpy.ndarrayAntenna 2 index used to look up the antenna Jones for a particular baseline. with shape
(row,).dde1_jones :
numpy.ndarray, optional\(E_{ps}\) Direction-Dependent Jones terms for the first antenna. shape
(source,time,ant,chan,corr_1,corr_2)source_coh :
numpy.ndarray, optional\(X_{pqs}\) Direction-Dependent Coherency matrix for the baseline. with shape
(source,row,chan,corr_1,corr_2)dde2_jones :
numpy.ndarray, optional\(E_{qs}\) Direction-Dependent Jones terms for the second antenna. This is usually the same array as
dde1_jonesas this preserves the symmetry of the RIME.predict_viswill perform the conjugate transpose internally. shape(source,time,ant,chan,corr_1,corr_2)die1_jones :
numpy.ndarray, optional\(G_{ps}\) Direction-Independent Jones terms for the first antenna of the baseline. with shape
(time,ant,chan,corr_1,corr_2)base_vis :
numpy.ndarray, optional\(B_{pq}\) base coherencies, added to source coherency summation before multiplication with die1_jones and die2_jones. shape
(row,chan,corr_1,corr_2).die2_jones :
numpy.ndarray, optional\(G_{ps}\) Direction-Independent Jones terms for the second antenna of the baseline. This is usually the same array as
die1_jonesas this preserves the symmetry of the RIME.predict_viswill perform the conjugate transpose internally. shape(time,ant,chan,corr_1,corr_2)Returns: visibilities :
numpy.ndarrayModel visibilities of shape
(row,chan,corr_1,corr_2)Notes
- Direction-Dependent terms (dde{1,2}_jones) and Independent (die{1,2}_jones) are optional, but if one is present, the other must be present.
- The inputs to this function involve
row,timeandant(antenna) dimensions. - Each
rowis associated with a pair of antenna Jones matrices at a particular timestep via thetime_index,antenna1andantenna2inputs. - The
rowdimension must be an increasing partial order in time.
-
africanus.rime.phase_delay(lm, uvw, frequency, convention='fourier')[source]¶ Computes the phase delay (K) term:
\[ \begin{align}\begin{aligned}& {\Large e^{-2 \pi i (u l + v m + w (n - 1))} }\\& \textrm{where } n = \sqrt{1 - l^2 - m^2}\end{aligned}\end{align} \]Parameters: lm :
numpy.ndarrayLM coordinates of shape
(source, 2)with L and M components in the last dimension.uvw :
numpy.ndarrayUVW coordinates of shape
(row, 3)with U, V and W components in the last dimension.frequency :
numpy.ndarrayfrequencies of shape
(chan,)convention : {‘fourier’, ‘casa’}
Uses the \(e^{-2 \pi \mathit{i}}\) sign convention if
fourierand \(e^{2 \pi \mathit{i}}\) ifcasa.Returns: complex_phase :
numpy.ndarraycomplex of shape
(source, row, chan)Notes
Corresponds to the complex exponential of the Van Cittert-Zernike Theorem.
MeqTrees uses the CASA sign convention.
-
africanus.rime.parallactic_angles(times, antenna_positions, field_centre, backend='casa')[source]¶ Computes parallactic angles per timestep for the given reference antenna position and field centre.
Parameters: times :
numpy.ndarrayArray of Mean Julian Date times in seconds with shape
(time,),antenna_positions :
numpy.ndarrayAntenna positions of shape
(ant, 3)in metres in the ITRF frame.field_centre :
numpy.ndarrayField centre of shape
(2,)in radiansbackend : {‘casa’, ‘test’}, optional
Backend to use for calculating the parallactic angles.
casadefers to an implementation depending onpython-casacore. This backend should be used by default.testcreates parallactic angles by multiplying thetimesandantenna_positionarrays. It exist solely for testing.
Returns: parallactic_angles :
numpy.ndarrayParallactic angles of shape
(time,ant)
-
africanus.rime.feed_rotation(parallactic_angles, feed_type='linear')[source]¶ Computes the 2x2 feed rotation (L) matrix from the
parallactic_angles.\[\begin{split}\textrm{linear} \begin{bmatrix} cos(pa) & sin(pa) \\ -sin(pa) & cos(pa) \end{bmatrix} \qquad \textrm{circular} \begin{bmatrix} e^{-i pa} & 0 \\ 0 & e^{i pa} \end{bmatrix}\end{split}\]Parameters: parallactic_angles :
numpy.ndarrayfloating point parallactic angles. Of shape
(pa0, pa1, ..., pan).feed_type : {‘linear’, ‘circular’}
The type of feed
Returns: feed_matrix :
numpy.ndarrayFeed rotation matrix of shape
(pa0, pa1,...,pan,2,2)
-
africanus.rime.transform_sources(lm, parallactic_angles, pointing_errors, antenna_scaling, frequency, dtype=None)[source]¶ Creates beam sampling coordinates suitable for use in
beam_cube_dde()by:- Rotating
lmcoordinates by theparallactic_angles - Adding
pointing_errors - Scaling by
antenna_scaling
Parameters: lm :
numpy.ndarrayLM coordinates of shape
(src,2)in radians offset from the phase centre.parallactic_angles :
numpy.ndarrayparallactic angles of shape
(time, antenna)in radians.pointing_errors :
numpy.ndarrayLM pointing errors for each antenna at each timestep in radians. Has shape
(time, antenna, 2)antenna_scaling :
numpy.ndarrayantenna scaling factor for each channel and each antenna. Has shape
(antenna, chan)frequency :
numpy.ndarrayfrequencies for each channel. Has shape
(chan,)dtype :
numpy.dtype, optionalNumpy dtype of result array. Should be float32 or float64. Defaults to float64
Returns: coords :
numpy.ndarraycoordinates of shape
(3, src, time, antenna, chan)where each coordinate component represents l, m and frequency, respectively.- Rotating
-
africanus.rime.beam_cube_dde(beam, beam_lm_extents, beam_freq_map, lm, parallactic_angles, point_errors, antenna_scaling, frequency)[source]¶ Evaluates Direction Dependent Effects along a source’s path by interpolating the values of a complex beam cube at the source location.
Parameters: beam :
numpy.ndarrayComplex beam cube of shape
(beam_lw, beam_mh, beam_nud, corr, corr). beam_lw, beam_mh and beam_nud define the size of the cube in the l, m and frequency dimensions, respectively.beam_lm_extents :
numpy.ndarraylm extents of the beam cube of shape
(2, 2).[[lower_l, upper_l], [lower_m, upper_m]].beam_freq_map :
numpy.ndarrayBeam frequency map of shape
(beam_nud,). This array is used to define interpolation along the(chan,)dimension.lm :
numpy.ndarraySource lm coordinates of shape
(source, 2). These coordinates are:- Scaled if the associated frequency lies outside the beam cube.
- Offset by pointing errors:
point_errors - Rotated by parallactic angles:
parallactic_angles. - Scaled by antenna scaling factors:
antenna_scaling.
parallactic_angles :
numpy.ndarrayParallactic angles of shape
(time, ant).point_errors :
numpy.ndarrayPointing errors of shape
(time, ant, chan, 2).antenna_scaling :
numpy.ndarrayAntenna scaling factors of shape
(ant, chan, 2)frequency :
numpy.ndarrayFrequencies of shape
(chan,).Returns: ddes :
numpy.ndarrayDirection Dependent Effects of shape
(source, time, ant, chan, corr, corr)Notes
- Sources are clamped to the provided beam_lm_extents.
- Frequencies outside the cube (i.e. outside beam_freq_map) introduce linear scaling to the lm coordinates of a source.
-
africanus.rime.zernike_dde(coords, coeffs, noll_index, parallactic_angles, frequency_scaling, antenna_scaling, pointing_errors)[source]¶ Computes Direction Dependent Effects by evaluating Zernicke Polynomials defined by coefficients
coeffsand noll indexesnoll_indexat the specified coordinatescoords.Decomposition of a voxel beam cube into Zernicke polynomial coefficients can be achieved through the use of the eidos package.
Parameters: coords :
numpy.ndarrayFloat coordinates at which to evaluate the zernike polynomials. Has shape
(3, source, time, ant, chan). The three components in the first dimension represent l, m and frequency coordinates, respectively.coeffs :
numpy.ndarraycomplex Zernicke polynomial coefficients. Has shape
(ant, chan, corr_1, ..., corr_n, poly)wherepolyis the number of polynomial coefficients andcorr_1, ..., corr_nare a variable number of correlation dimensions.noll_index :
numpy.ndarrayNoll index associated with each polynomial coefficient. Has shape
(ant, chan, corr_1, ..., corr_n, poly). correlation dimensions.parallactic_angles :
numpy.ndarrayParallactic angle rotation. Has shape
(time, ant).frequency_scaling :
numpy.ndarrayThe scaling of frequency of the beam. Has shape
(chan,).antenna_scaling :
numpy.ndarrayThe antenna scaling. Has shape
(ant, chan, 2).pointing_errors :
numpy.ndarrayThe pointing error. Has shape
(time, ant, chan, 2).Returns: dde :
numpy.ndarraycomplex values with shape
(source, time, ant, chan, corr_1, ..., corr_n)
-
africanus.rime.wsclean_predict(uvw, lm, source_type, flux, coeffs, log_poly, ref_freq, gauss_shape, frequency)[source]¶ Predict visibilities from a WSClean sky model.
Parameters: uvw :
numpy.ndarrayUVW coordinates of shape
(row, 3)lm :
numpy.ndarraySource LM coordinates of shape
(source, 2), in radians. Derived from theRaandDecfields.source_type :
numpy.ndarrayStrings defining the source type of shape
(source,). Should be either"POINT"or"GAUSSIAN". Contains theTypefield.flux :
numpy.ndarraySource flux of shape
(source,). Contains theIfield.coeffs :
numpy.ndarraySource Polynomial coefficients of shape
(source, coeffs). Contains theSpectralIndexfield.log_poly :
numpy.ndarraySource polynomial type of shape
(source,). If True, logarithmic polynomials are used. If False, standard polynomials are used. Contains theLogarithmicSIfield.ref_freq :
numpy.ndarraySource Reference frequency of shape
(source,). Contains theReferenceFrequencyfield.gauss_shape :
numpy.ndarrayGaussian shape parameters of shape
(source, 3)used when the correspondingsource_typeis"GAUSSIAN". The 3 components should contain theMajorAxis,MinorAxisandOrientationfields in radians, respectively.frequency :
numpy.ndarrayFrequency of shape
(chan,).Returns: visibilities :
numpy.ndarrayComplex visibilities of shape
(row, chan, 1)
Cuda¶
predict_vis(time_index, antenna1, antenna2) |
Multiply Jones terms together to form model visibilities according to the following formula: |
phase_delay(lm, uvw, frequency) |
Computes the phase delay (K) term: |
feed_rotation(parallactic_angles[, feed_type]) |
Computes the 2x2 feed rotation (L) matrix from the parallactic_angles. |
beam_cube_dde(beam, beam_lm_ext, …) |
Evaluates Direction Dependent Effects along a source’s path by interpolating the values of a complex beam cube at the source location. |
-
africanus.rime.cuda.predict_vis(time_index, antenna1, antenna2, dde1_jones=None, source_coh=None, dde2_jones=None, die1_jones=None, base_vis=None, die2_jones=None)[source]¶ Multiply Jones terms together to form model visibilities according to the following formula:
\[V_{pq} = G_{p} \left( B_{pq} + \sum_{s} E_{ps} X_{pqs} E_{qs}^H \right) G_{q}^H\]where for antenna \(p\) and \(q\), and source \(s\):
- \(B_{{pq}}\) represent base coherencies.
- \(E_{{ps}}\) represents Direction-Dependent Jones terms.
- \(X_{{pqs}}\) represents a coherency matrix (per-source).
- \(G_{{p}}\) represents Direction-Independent Jones terms.
Generally, \(E_{ps}\), \(G_{p}\), \(X_{pqs}\) should be formed by using the RIME API functions and combining them together with
einsum().Please read the Notes
Parameters: time_index :
cupy.ndarrayTime index used to look up the antenna Jones index for a particular baseline with shape
(row,). Obtainable viacp.unique(time, return_inverse=True)[1].antenna1 :
cupy.ndarrayAntenna 1 index used to look up the antenna Jones for a particular baseline. with shape
(row,).antenna2 :
cupy.ndarrayAntenna 2 index used to look up the antenna Jones for a particular baseline. with shape
(row,).dde1_jones :
cupy.ndarray, optional\(E_{ps}\) Direction-Dependent Jones terms for the first antenna. shape
(source,time,ant,chan,corr_1,corr_2)source_coh :
cupy.ndarray, optional\(X_{pqs}\) Direction-Dependent Coherency matrix for the baseline. with shape
(source,row,chan,corr_1,corr_2)dde2_jones :
cupy.ndarray, optional\(E_{qs}\) Direction-Dependent Jones terms for the second antenna. This is usually the same array as
dde1_jonesas this preserves the symmetry of the RIME.predict_viswill perform the conjugate transpose internally. shape(source,time,ant,chan,corr_1,corr_2)die1_jones :
cupy.ndarray, optional\(G_{ps}\) Direction-Independent Jones terms for the first antenna of the baseline. with shape
(time,ant,chan,corr_1,corr_2)base_vis :
cupy.ndarray, optional\(B_{pq}\) base coherencies, added to source coherency summation before multiplication with die1_jones and die2_jones. shape
(row,chan,corr_1,corr_2).die2_jones :
cupy.ndarray, optional\(G_{ps}\) Direction-Independent Jones terms for the second antenna of the baseline. This is usually the same array as
die1_jonesas this preserves the symmetry of the RIME.predict_viswill perform the conjugate transpose internally. shape(time,ant,chan,corr_1,corr_2)Returns: visibilities :
cupy.ndarrayModel visibilities of shape
(row,chan,corr_1,corr_2)Notes
- Direction-Dependent terms (dde{1,2}_jones) and Independent (die{1,2}_jones) are optional, but if one is present, the other must be present.
- The inputs to this function involve
row,timeandant(antenna) dimensions. - Each
rowis associated with a pair of antenna Jones matrices at a particular timestep via thetime_index,antenna1andantenna2inputs. - The
rowdimension must be an increasing partial order in time.
-
africanus.rime.cuda.phase_delay(lm, uvw, frequency)[source]¶ Computes the phase delay (K) term:
\[ \begin{align}\begin{aligned}& {\Large e^{-2 \pi i (u l + v m + w (n - 1))} }\\& \textrm{where } n = \sqrt{1 - l^2 - m^2}\end{aligned}\end{align} \]Parameters: lm :
cupy.ndarrayLM coordinates of shape
(source, 2)with L and M components in the last dimension.uvw :
cupy.ndarrayUVW coordinates of shape
(row, 3)with U, V and W components in the last dimension.frequency :
cupy.ndarrayfrequencies of shape
(chan,)convention : {‘fourier’, ‘casa’}
Uses the \(e^{-2 \pi \mathit{i}}\) sign convention if
fourierand \(e^{2 \pi \mathit{i}}\) ifcasa.Returns: complex_phase :
cupy.ndarraycomplex of shape
(source, row, chan)Notes
Corresponds to the complex exponential of the Van Cittert-Zernike Theorem.
MeqTrees uses the CASA sign convention.
-
africanus.rime.cuda.feed_rotation(parallactic_angles, feed_type='linear')[source]¶ Computes the 2x2 feed rotation (L) matrix from the
parallactic_angles.\[\begin{split}\textrm{linear} \begin{bmatrix} cos(pa) & sin(pa) \\ -sin(pa) & cos(pa) \end{bmatrix} \qquad \textrm{circular} \begin{bmatrix} e^{-i pa} & 0 \\ 0 & e^{i pa} \end{bmatrix}\end{split}\]Parameters: parallactic_angles :
cupy.ndarrayfloating point parallactic angles. Of shape
(pa0, pa1, ..., pan).feed_type : {‘linear’, ‘circular’}
The type of feed
Returns: feed_matrix :
cupy.ndarrayFeed rotation matrix of shape
(pa0, pa1,...,pan,2,2)
-
africanus.rime.cuda.beam_cube_dde(beam, beam_lm_ext, beam_freq_map, lm, parangles, pointing_errors, antenna_scaling, frequencies)[source]¶ Evaluates Direction Dependent Effects along a source’s path by interpolating the values of a complex beam cube at the source location.
Parameters: beam :
cupy.ndarrayComplex beam cube of shape
(beam_lw, beam_mh, beam_nud, corr, corr). beam_lw, beam_mh and beam_nud define the size of the cube in the l, m and frequency dimensions, respectively.beam_lm_extents :
cupy.ndarraylm extents of the beam cube of shape
(2, 2).[[lower_l, upper_l], [lower_m, upper_m]].beam_freq_map :
cupy.ndarrayBeam frequency map of shape
(beam_nud,). This array is used to define interpolation along the(chan,)dimension.lm :
cupy.ndarraySource lm coordinates of shape
(source, 2). These coordinates are:- Scaled if the associated frequency lies outside the beam cube.
- Offset by pointing errors:
point_errors - Rotated by parallactic angles:
parallactic_angles. - Scaled by antenna scaling factors:
antenna_scaling.
parallactic_angles :
cupy.ndarrayParallactic angles of shape
(time, ant).point_errors :
cupy.ndarrayPointing errors of shape
(time, ant, chan, 2).antenna_scaling :
cupy.ndarrayAntenna scaling factors of shape
(ant, chan, 2)frequency :
cupy.ndarrayFrequencies of shape
(chan,).Returns: ddes :
cupy.ndarrayDirection Dependent Effects of shape
(source, time, ant, chan, corr, corr)Notes
- Sources are clamped to the provided beam_lm_extents.
- Frequencies outside the cube (i.e. outside beam_freq_map) introduce linear scaling to the lm coordinates of a source.
Dask¶
predict_vis(time_index, antenna1, antenna2) |
Multiply Jones terms together to form model visibilities according to the following formula: |
phase_delay(lm, uvw, frequency[, convention]) |
Computes the phase delay (K) term: |
parallactic_angles(times, antenna_positions, …) |
Computes parallactic angles per timestep for the given reference antenna position and field centre. |
feed_rotation(parallactic_angles, feed_type) |
Computes the 2x2 feed rotation (L) matrix from the parallactic_angles. |
transform_sources(lm, parallactic_angles, …) |
Creates beam sampling coordinates suitable for use in beam_cube_dde() by: |
beam_cube_dde(beam, beam_lm_extents, …) |
Evaluates Direction Dependent Effects along a source’s path by interpolating the values of a complex beam cube at the source location. |
zernike_dde(coords, coeffs, noll_index, …) |
Computes Direction Dependent Effects by evaluating Zernicke Polynomials defined by coefficients coeffs and noll indexes noll_index at the specified coordinates coords. |
wsclean_predict(uvw, lm, source_type, flux, …) |
Predict visibilities from a WSClean sky model. |
-
africanus.rime.dask.predict_vis(time_index, antenna1, antenna2, dde1_jones=None, source_coh=None, dde2_jones=None, die1_jones=None, base_vis=None, die2_jones=None, streams=None)[source]¶ Multiply Jones terms together to form model visibilities according to the following formula:
\[V_{pq} = G_{p} \left( B_{pq} + \sum_{s} E_{ps} X_{pqs} E_{qs}^H \right) G_{q}^H\]where for antenna \(p\) and \(q\), and source \(s\):
- \(B_{{pq}}\) represent base coherencies.
- \(E_{{ps}}\) represents Direction-Dependent Jones terms.
- \(X_{{pqs}}\) represents a coherency matrix (per-source).
- \(G_{{p}}\) represents Direction-Independent Jones terms.
Generally, \(E_{ps}\), \(G_{p}\), \(X_{pqs}\) should be formed by using the RIME API functions and combining them together with
einsum().Please read the Notes
Parameters: time_index :
dask.array.ArrayTime index used to look up the antenna Jones index for a particular baseline with shape
(row,). Obtainable viatime.map_blocks(lambda a: np.unique(a, return_inverse=True)[1]).antenna1 :
dask.array.ArrayAntenna 1 index used to look up the antenna Jones for a particular baseline. with shape
(row,).antenna2 :
dask.array.ArrayAntenna 2 index used to look up the antenna Jones for a particular baseline. with shape
(row,).dde1_jones :
dask.array.Array, optional\(E_{ps}\) Direction-Dependent Jones terms for the first antenna. shape
(source,time,ant,chan,corr_1,corr_2)source_coh :
dask.array.Array, optional\(X_{pqs}\) Direction-Dependent Coherency matrix for the baseline. with shape
(source,row,chan,corr_1,corr_2)dde2_jones :
dask.array.Array, optional\(E_{qs}\) Direction-Dependent Jones terms for the second antenna. This is usually the same array as
dde1_jonesas this preserves the symmetry of the RIME.predict_viswill perform the conjugate transpose internally. shape(source,time,ant,chan,corr_1,corr_2)die1_jones :
dask.array.Array, optional\(G_{ps}\) Direction-Independent Jones terms for the first antenna of the baseline. with shape
(time,ant,chan,corr_1,corr_2)base_vis :
dask.array.Array, optional\(B_{pq}\) base coherencies, added to source coherency summation before multiplication with die1_jones and die2_jones. shape
(row,chan,corr_1,corr_2).die2_jones :
dask.array.Array, optional\(G_{ps}\) Direction-Independent Jones terms for the second antenna of the baseline. This is usually the same array as
die1_jonesas this preserves the symmetry of the RIME.predict_viswill perform the conjugate transpose internally. shape(time,ant,chan,corr_1,corr_2)streams : {False, True}
If
Truethe coherencies are serially summed in a linear chain. IfFalse, dask uses a tree style reduction algorithm.Returns: visibilities :
dask.array.ArrayModel visibilities of shape
(row,chan,corr_1,corr_2)Notes
Direction-Dependent terms (dde{1,2}_jones) and Independent (die{1,2}_jones) are optional, but if one is present, the other must be present.
The inputs to this function involve
row,timeandant(antenna) dimensions.Each
rowis associated with a pair of antenna Jones matrices at a particular timestep via thetime_index,antenna1andantenna2inputs.The
rowdimension must be an increasing partial order in time.The
antdimension should only contain a single chunk equal to the number of antenna. Since eachrowcan contain any antenna, random access must be preserved along this dimension.The chunks in the
rowandtimedimension must align. This subtle point must be understood otherwise invalid results will be produced by the chunking scheme. In the example below we have four unique time indices[0,1,2,3], and four unique antenna[0,1,2,3]indexing10rows.# Row indices into the time/antenna indexed arrays time_idx = np.asarray([0,0,1,1,2,2,2,2,3,3]) ant1 = np.asarray( [0,0,0,0,1,1,1,2,2,3] ant2 = np.asarray( [0,1,2,3,1,2,3,2,3,3])
A reasonable chunking scheme for the
rowandtimedimension would be(4,4,2)and(2,1,1)respectively. Another way of explaining this is that the first four rows contain two unique timesteps, the second four rows contain one unique timestep and the last two rows contain one unique timestep.Some rules of thumb:
The number chunks in
rowandtimemust match although the individual chunk sizes need not.Unique timesteps should not be split across row chunks.
For a Measurement Set whose rows are ordered on the
TIMEcolumn, the following is a good way of obtaining the row chunking strategy:import numpy as np import pyrap.tables as pt ms = pt.table("data.ms") times = ms.getcol("TIME") unique_times, chunks = np.unique(times, return_counts=True)
Use
aggregate_chunks()to aggregate multiplerowandtimechunks into chunks large enough such that functions operating on the resulting data can drop the GIL and spend time processing the data. Expanding the previous example:# Aggregate row utimes = unique_times.size # Single chunk for each unique time time_chunks = (1,)*utimes # Aggregate row chunks into chunks <= 10000 aggregate_chunks((chunks, time_chunks), (10000, utimes))
-
africanus.rime.dask.phase_delay(lm, uvw, frequency, convention='fourier')[source]¶ Computes the phase delay (K) term:
\[ \begin{align}\begin{aligned}& {\Large e^{-2 \pi i (u l + v m + w (n - 1))} }\\& \textrm{where } n = \sqrt{1 - l^2 - m^2}\end{aligned}\end{align} \]Parameters: lm :
dask.array.ArrayLM coordinates of shape
(source, 2)with L and M components in the last dimension.uvw :
dask.array.ArrayUVW coordinates of shape
(row, 3)with U, V and W components in the last dimension.frequency :
dask.array.Arrayfrequencies of shape
(chan,)convention : {‘fourier’, ‘casa’}
Uses the \(e^{-2 \pi \mathit{i}}\) sign convention if
fourierand \(e^{2 \pi \mathit{i}}\) ifcasa.Returns: complex_phase :
dask.array.Arraycomplex of shape
(source, row, chan)Notes
Corresponds to the complex exponential of the Van Cittert-Zernike Theorem.
MeqTrees uses the CASA sign convention.
-
africanus.rime.dask.parallactic_angles(times, antenna_positions, field_centre, **kwargs)[source]¶ Computes parallactic angles per timestep for the given reference antenna position and field centre.
Parameters: times :
dask.array.ArrayArray of Mean Julian Date times in seconds with shape
(time,),antenna_positions :
dask.array.ArrayAntenna positions of shape
(ant, 3)in metres in the ITRF frame.field_centre :
dask.array.ArrayField centre of shape
(2,)in radiansbackend : {‘casa’, ‘test’}, optional
Backend to use for calculating the parallactic angles.
casadefers to an implementation depending onpython-casacore. This backend should be used by default.testcreates parallactic angles by multiplying thetimesandantenna_positionarrays. It exist solely for testing.
Returns: parallactic_angles :
dask.array.ArrayParallactic angles of shape
(time,ant)
-
africanus.rime.dask.feed_rotation(parallactic_angles, feed_type)[source]¶ Computes the 2x2 feed rotation (L) matrix from the
parallactic_angles.\[\begin{split}\textrm{linear} \begin{bmatrix} cos(pa) & sin(pa) \\ -sin(pa) & cos(pa) \end{bmatrix} \qquad \textrm{circular} \begin{bmatrix} e^{-i pa} & 0 \\ 0 & e^{i pa} \end{bmatrix}\end{split}\]Parameters: parallactic_angles :
numpy.ndarrayfloating point parallactic angles. Of shape
(pa0, pa1, ..., pan).feed_type : {‘linear’, ‘circular’}
The type of feed
Returns: feed_matrix :
numpy.ndarrayFeed rotation matrix of shape
(pa0, pa1,...,pan,2,2)
-
africanus.rime.dask.transform_sources(lm, parallactic_angles, pointing_errors, antenna_scaling, frequency, dtype=None)[source]¶ Creates beam sampling coordinates suitable for use in
beam_cube_dde()by:- Rotating
lmcoordinates by theparallactic_angles - Adding
pointing_errors - Scaling by
antenna_scaling
Parameters: lm :
dask.array.ArrayLM coordinates of shape
(src,2)in radians offset from the phase centre.parallactic_angles :
dask.array.Arrayparallactic angles of shape
(time, antenna)in radians.pointing_errors :
dask.array.ArrayLM pointing errors for each antenna at each timestep in radians. Has shape
(time, antenna, 2)antenna_scaling :
dask.array.Arrayantenna scaling factor for each channel and each antenna. Has shape
(antenna, chan)frequency :
dask.array.Arrayfrequencies for each channel. Has shape
(chan,)dtype :
numpy.dtype, optionalNumpy dtype of result array. Should be float32 or float64. Defaults to float64
Returns: coords :
dask.array.Arraycoordinates of shape
(3, src, time, antenna, chan)where each coordinate component represents l, m and frequency, respectively.- Rotating
-
africanus.rime.dask.beam_cube_dde(beam, beam_lm_extents, beam_freq_map, lm, parallactic_angles, point_errors, antenna_scaling, frequencies)[source]¶ Evaluates Direction Dependent Effects along a source’s path by interpolating the values of a complex beam cube at the source location.
Parameters: beam :
dask.array.ArrayComplex beam cube of shape
(beam_lw, beam_mh, beam_nud, corr, corr). beam_lw, beam_mh and beam_nud define the size of the cube in the l, m and frequency dimensions, respectively.beam_lm_extents :
dask.array.Arraylm extents of the beam cube of shape
(2, 2).[[lower_l, upper_l], [lower_m, upper_m]].beam_freq_map :
dask.array.ArrayBeam frequency map of shape
(beam_nud,). This array is used to define interpolation along the(chan,)dimension.lm :
dask.array.ArraySource lm coordinates of shape
(source, 2). These coordinates are:- Scaled if the associated frequency lies outside the beam cube.
- Offset by pointing errors:
point_errors - Rotated by parallactic angles:
parallactic_angles. - Scaled by antenna scaling factors:
antenna_scaling.
parallactic_angles :
dask.array.ArrayParallactic angles of shape
(time, ant).point_errors :
dask.array.ArrayPointing errors of shape
(time, ant, chan, 2).antenna_scaling :
dask.array.ArrayAntenna scaling factors of shape
(ant, chan, 2)frequency :
dask.array.ArrayFrequencies of shape
(chan,).Returns: ddes :
dask.array.ArrayDirection Dependent Effects of shape
(source, time, ant, chan, corr, corr)Notes
- Sources are clamped to the provided beam_lm_extents.
- Frequencies outside the cube (i.e. outside beam_freq_map) introduce linear scaling to the lm coordinates of a source.
-
africanus.rime.dask.zernike_dde(coords, coeffs, noll_index, parallactic_angle, frequency_scaling, antenna_scaling, pointing_errors)[source]¶ Computes Direction Dependent Effects by evaluating Zernicke Polynomials defined by coefficients
coeffsand noll indexesnoll_indexat the specified coordinatescoords.Decomposition of a voxel beam cube into Zernicke polynomial coefficients can be achieved through the use of the eidos package.
Parameters: coords :
dask.array.ArrayFloat coordinates at which to evaluate the zernike polynomials. Has shape
(3, source, time, ant, chan). The three components in the first dimension represent l, m and frequency coordinates, respectively.coeffs :
dask.array.Arraycomplex Zernicke polynomial coefficients. Has shape
(ant, chan, corr_1, ..., corr_n, poly)wherepolyis the number of polynomial coefficients andcorr_1, ..., corr_nare a variable number of correlation dimensions.noll_index :
dask.array.ArrayNoll index associated with each polynomial coefficient. Has shape
(ant, chan, corr_1, ..., corr_n, poly). correlation dimensions.parallactic_angles :
dask.array.ArrayParallactic angle rotation. Has shape
(time, ant).frequency_scaling :
dask.array.ArrayThe scaling of frequency of the beam. Has shape
(chan,).antenna_scaling :
dask.array.ArrayThe antenna scaling. Has shape
(ant, chan, 2).pointing_errors :
dask.array.ArrayThe pointing error. Has shape
(time, ant, chan, 2).Returns: dde :
dask.array.Arraycomplex values with shape
(source, time, ant, chan, corr_1, ..., corr_n)
-
africanus.rime.dask.wsclean_predict(uvw, lm, source_type, flux, coeffs, log_poly, ref_freq, gauss_shape, frequency)[source]¶ Predict visibilities from a WSClean sky model.
Parameters: uvw :
dask.array.ArrayUVW coordinates of shape
(row, 3)lm :
dask.array.ArraySource LM coordinates of shape
(source, 2), in radians. Derived from theRaandDecfields.source_type :
dask.array.ArrayStrings defining the source type of shape
(source,). Should be either"POINT"or"GAUSSIAN". Contains theTypefield.flux :
dask.array.ArraySource flux of shape
(source,). Contains theIfield.coeffs :
dask.array.ArraySource Polynomial coefficients of shape
(source, coeffs). Contains theSpectralIndexfield.log_poly :
dask.array.ArraySource polynomial type of shape
(source,). If True, logarithmic polynomials are used. If False, standard polynomials are used. Contains theLogarithmicSIfield.ref_freq :
dask.array.ArraySource Reference frequency of shape
(source,). Contains theReferenceFrequencyfield.gauss_shape :
dask.array.ArrayGaussian shape parameters of shape
(source, 3)used when the correspondingsource_typeis"GAUSSIAN". The 3 components should contain theMajorAxis,MinorAxisandOrientationfields in radians, respectively.frequency :
dask.array.ArrayFrequency of shape
(chan,).Returns: visibilities :
dask.array.ArrayComplex visibilities of shape
(row, chan, 1)