wodenpy.uvfits

Methods to write visibilities to uvfits files.

wodenpy_uvfits

wodenpy_uvfits.RTS_decode_baseline(blcode)[source]

The ancient aips/miriad extended way of decoding a baseline. Takes the baseline code from the ‘BASELINE’ array of a uvfits, and returns the index of antennas 1 and 2 that form the baseline.

Parameters:

blcode (int) – Baseline code from a uvfits file encoded the two antennas

Returns:

  • b1 (int) – Index of first antenna

  • b2 (int) – Index of second antenna

wodenpy_uvfits.RTS_encode_baseline(b1, b2)[source]

The ancient aips/miriad extended way of encoding a baseline by antenna number, by multiplying antenna number 1 by 256, and adding the second antenna number. (e.g. b1*256 + b2). Needed for populating the uvfits files.

Uses the RTS extension for antennas higher that 255, where encoding happens as b1*2048 + b2 + 65536

Parameters:
  • b1 (int) – Index of first antenna

  • b2 (int) – Index of second antenna

Returns:

baseline_number – Encdoded baseline number for uvfits ‘BASELINE’ array

Return type:

int

wodenpy_uvfits.create_uvfits(v_container=None, freq_cent=None, central_freq_chan=None, ch_width=None, ra_point=None, dec_point=None, output_uvfits_name=None, uu=None, vv=None, ww=None, longitude=None, latitude=None, array_height=None, telescope_name=None, baselines_array=None, date_array=None, int_jd=None, hdu_ant=None, gitlabel=False, IAU_order=False)[source]

Takes visibility data read in from WODEN binary files, predefined BASELINE and DATE arrays and an antenna table, and writes them out together into a uvfits file. Uses multiple astropy.io.fits routines to create the final uvfits file. Uses GroupData and GroupsHDU to create the data table, and then combines with the antenna table in a uvfits via HDUList.

Will only work for data as ordered as coming out of the WODEN C/CUDA code (where XX = NS). See –IAU_order for more explanation.

Parameters:
  • v_container (float array) –

    Data container for the visibility data. Should have shape = (num_time_steps*num_baselines, 1, 1, num_freq_channels, 4, 3) and should contain instrumental linear polarisation visibilities. The axes should change as:

    • 1st axis: ordered by baseline (fastest changing) and then time step (slowest changing).

    • 2nd, 3rd axes: essentially do nothing in these uvfits, are placeholders

    • 4th axis: ordered with increasing frequency

    • 5th axis: ordered by polarisation in the order of XX,YY,XY,YX

    • 6th axis: ordered by real visi part, imaginary visi part, weighting

  • freq_cent (float) – Frequency of the central frequency channel (Hz)

  • central_freq_chan (int) – Index of the central frequency channel (zero indexed)

  • ch_width (float) – Resolutiom of frequency channels (Hz)

  • ra_point (float) – Right ascension of the observation, to set header keyword ‘OBSRA’ with (deg)

  • dec_point (float) – Declination of the observation, to set header keyword ‘OBSDEC’ with (deg)

  • output_uvfits_name (string) – Name for the output uvfits file

  • uu (float array) – :math`u` coordinates (seconds).

  • vv (float array) – :math`v` coordinates (seconds).

  • ww (float array) – :math`w` coordinates (seconds).

  • baselines_array (int/float array) – Baseline coding needed for ‘BASELINE’ array

  • date_array (float array) – Fractional julian date array to put in ‘DATE’ array (days)

  • int_jd (int) – Integer julian date to put in the header as ‘PZERO4’

  • hdu_ant (astropy.io.fits.hdu.table.BinTableHDU) – Populated uvfits antenna table

  • gitlabel (string) – Optional string to add as ‘GITLABEL’ in the header. Used by WODEN to add the git commit of the code for this run

  • IAU_order (Boolean) – By default, the visibilities out of the CUDA/C code have XX = North-South, which is the the IAU ordering. Turns out most people want uvfits with XX = East-West. So when I`AU_order == True`, do not reorder the input data, and add a header value of IAUORDER = True. If IAU_order == False, then the XX is flipped to be East-West by reordering the data in

wodenpy_uvfits.make_antenna_table(XYZ_array=None, telescope_name=None, num_antennas=None, freq_cent=None, date=None, gst0_deg=None, degpdy=None, ut1utc=None, longitude=None, latitude=None, array_height=None, ant_names=False)[source]

Write an antenna table for a uvfits file. This is the first table in the uvfits file that encodes antenna positions, with some header keywords. Uses astropy.io.fits.BinTableHDU to create the table.

Parameters:
  • XYZ_array (float array) – Array with shape = (num_antennas, 3), containg the local \(X,Y,Z\) coorindates of the antenna locations (meters)

  • telescope_name (string) – Name to assign to the ‘ARRNAM’ header keyword

  • num_antennas (int) – Number of antennas in the array

  • freq_cent (float) – Central frequency to assign to the ‘FREQ’ header keyword (Hz)

  • date (string) – UTC date/time in format YYYY-MM-DDThh:mm:ss to give to the ‘RDATE’ header keyword

  • gst0_deg (float) – Greenwich sidereal time at 0 hours on the given date (degrees)

  • degpdy (float) – Rotational speed of Earth on the given date (degrees per day)

  • ut1utc (float) – Difference between UT1 and UTC (secs)

  • longitude (float) – Longitude of the array (deg)

  • latitude (float) – Latitude of the array (deg)

  • array_height (float) – Height of the array above sea level (metres)

Returns:

hdu_ant – Populated uvfits antenna table

Return type:

astropy.io.fits.hdu.table.BinTableHDU

wodenpy_uvfits.make_baseline_date_arrays(num_antennas, date, num_time_steps, time_res, do_autos=False)[source]

Makes the BASELINE and DATE arrays needed in the uvfits file The BASELINE array encode which two antennas formed the baseline The DATE array contains the fractional jd date, that is added to the header value PZERO5, to specify the time each visibility was recorded at.

In WODEN, by default, only cross-correlations are simulated. To include auto-correlations in the BASELINE array, use do_autos=True.

Parameters:
  • num_antennas (int) – The number of antennas in the antenna table

  • date (string) – Initial UTC date/time (e.g. in format YYYY-MM-DDThh:mm:ss or similar)

  • num_time_steps (int) – Number of time steps in the data

  • time_res (Boolean) – Integration time of the data (seconds)

  • time_res – Whether to include auto-correlations (same antenna to antenna)

Returns:

  • baselines_array (float array) – The uvfits antenna encoded array needed for BASELINE

  • date_array (float array) – The fractional part of the julian date needed for DATE (days)