wodenpy.primary_beam

Ways to calculate the primary beam response on the CPU rather than the GPU.

use_everybeam

use_everybeam.run_everybeam(ms_path: str, coeff_path: str, ras: ndarray, decs: ndarray, beam_ra0: float, beam_dec0: float, j2000_latitudes: ndarray, j2000_lsts: ndarray, times: ndarray, freqs: ndarray, station_ids: ndarray, element_response_model='default', apply_beam_norms: bool = True, iau_order: bool = False, element_only: bool = False, parallactic_rotate: bool = False, logger: Logger = False) ndarray[source]

Calculate the Jones matrices for a given set of coordinates, times, frequencies, and station ids using the EveryBeam library. j2000_latitudes should be the array latitude as precessed back to J2000, with j2000_lsts being the matching LST in J2000.

Parameters:
  • ras (np.ndarray) – Right ascensions of the coordinates in radians.

  • decs (np.ndarray) – Declinations of the coordinates in radians.

  • beam_ra0 (float) – Right ascension of the beam center in radians.

  • beam_dec0 (float) – Declination of the beam center in radians.

  • j2000_latitudes (np.ndarray) – Latitudes in J2000 coordinates.

  • j2000_lsts (np.ndarray) – Local sidereal times in J2000 coordinates.

  • times (np.ndarray) – Array of observation times.

  • freqs (np.ndarray) – Array of frequencies.

  • telescope ((eb.Telescope):) – Telescope object from the EveryBeam library.

  • station_ids (np.ndarray) – Array of station IDs.

  • apply_beam_norms (bool, optional) – Whether to apply beam normalisation. Defaults to True. Achieved by calculating the beam response at beam centre, and multiplying all Jones by the inverse of this central beam response.

  • iau_order (bool, optional) – If True, use IAU polarisation ordering, so set jones[0,0] to the NS dipole and jones[1,1] to EW. If False, jones[0,0] is EW.

  • element_only (bool, optional) – Whether to use only the element response. Defaults to False. Use this to look at the dipole response only, not the beam formed response.

  • parallactic_rotate (bool, optional) – Whether to apply parallactic angle rotation. Defaults to False.

Returns:

The calculated Jones matrices with shape (num_stations, num_times, num_freqs, num_coords, 2, 2).

Return type:

np.ndarray

use_everybeam.run_everybeam_over_threads(num_threads: int, ms_path: str, coeff_path: str, ras: ndarray, decs: ndarray, ra0: float, dec0: float, j2000_latitudes: ndarray, j2000_lsts: ndarray, times: ndarray, freqs: ndarray, station_ids: ndarray, full_accuracy: bool = True, apply_beam_norms: bool = True, iau_order: bool = False, element_only: bool = False, parallactic_rotate: bool = True, use_local_mwa: bool = True, element_response_model='default')[source]

Runs run_everybeam in parallel over num_threads threads, using concurrent.futures.ProcessPoolExecutor. See run_everybeam for more details of what each parameter does.

Creates a new EveryBeam telescope object from ms_path for each thread. This has to be done because concurrent.futures.ProcessPoolExecutor has to pickle the function and all it’s arguments, and EveryBeam objects can’t be pickled. This is somewhat wasteful but I can’t work out a better way to make things parallel.

Parameters:
  • num_threads (int) – Number of threads being in call by run_everybeam_over_threads.

  • ms_path (str) – Path to the measurement set to load the EveryBeam telescope from.

  • ras (np.ndarray) – Right ascensions of the coordinates in radians.

  • decs (np.ndarray) – Declinations of the coordinates in radians.

  • beam_ra0 (float) – Right ascension of the beam center in radians.

  • beam_dec0 (float) – Declination of the beam center in radians.

  • j2000_latitudes (np.ndarray) – Latitudes in J2000 coordinates.

  • j2000_lsts (np.ndarray) – Local sidereal times in J2000 coordinates.

  • times (np.ndarray) – Array of observation times.

  • freqs (np.ndarray) – Array of frequencies.

  • station_ids (np.ndarray) – Array of station IDs.

  • full_accuracy (bool, optional) – Whether to use the full accuracy of the EveryBeam library. Defaults to True. If False, the array factor and element response are calculated separately (the two values that multiply to give the full response). The array factor is only calculated at the middle time and frequency, under the assumption that the range of frequencies and times is small enough that the array factor will not change significantly. Magnitude of the differences vary by frequency and direction so use with caution.

  • apply_beam_norms (bool, optional) – Whether to apply beam normalisation. Defaults to True. Achieved by calculating the beam response at beam centre, and multiplying all Jones by the inverse of this central beam response.

  • iau_order (bool, optional) – If True, use IAU polarisation ordering, so set jones[0,0] to the NS dipole and jones[1,1] to EW. If False, jones[0,0] is EW.

  • element_only (bool, optional) – Whether to use only the element response. Defaults to False. Use this to look at the dipole response only, not the beam formed response.

  • parallactic_rotate (bool, optional) – Whether to apply parallactic angle. Defaults to False.

  • para_angle_offset (float, optional) – Offset to add to the parallactic angle. Defaults to 0.

  • element_response_model (str, optional) – The Everybeam element response model to use. Defaults to ‘hamaker’. Avaible options are ‘hamaker’ (LOFAR), ‘skala40_wave’ (OSKAR), and ‘MWA’ (MWA).

  • use_local_mwa (bool, optional) – Whether to use the local MWA model. Defaults to True. The local MWA model takes za/az instead of RA/Dec.

Returns:

The calculated Jones matrices with shape (num_stations, num_times, num_freqs, num_coord, 2, 2)

Return type:

np.ndarray

use_everybeam.run_everybeam_thread(num_threads: int, thread_id: int, ms_path: str, coeff_path: str, ras: ndarray, decs: ndarray, ra0: float, dec0: float, j2000_latitudes: ndarray, j2000_lsts: ndarray, times: ndarray, freqs: ndarray, station_ids: ndarray, full_accuracy: bool = True, apply_beam_norms: bool = True, iau_order: bool = False, element_only: bool = False, parallactic_rotate: bool = True, element_response_model='default', use_local_mwa: bool = True) Tuple[ndarray, int][source]

Thread function called by run_everybeam_over_threads to calculate the EveryBeam response in parrallel. Calls run_everybeam with a subset of the coordinates; see run_everybeam for more details of the parameters.

Creates a new EveryBeam telescope object from ms_path for each thread. This has to be done because concurrent.futures.ProcessPoolExecutor has to pickle the function and all it’s arguments, and EveryBeam objects can’t be pickled. This is somewhat wasteful but I can’t work out a better way to make things parallel.

Parameters:
  • num_threads (int) – Number of threads being in call by run_everybeam_over_threads.

  • thread_id (int) – ID of the current thread. Useds to work out what chunk of ras and decs to process.

  • ms_path (str) – Path to the measurement set to load the EveryBeam telescope from.

  • ras (np.ndarray) – Right ascensions of the coordinates in radians.

  • decs (np.ndarray) – Declinations of the coordinates in radians.

  • beam_ra0 (float) – Right ascension of the beam center in radians.

  • beam_dec0 (float) – Declination of the beam center in radians.

  • j2000_latitudes (np.ndarray) – Latitudes in J2000 coordinates.

  • j2000_lsts (np.ndarray) – Local sidereal times in J2000 coordinates.

  • times (np.ndarray) – Array of observation times.

  • freqs (np.ndarray) – Array of frequencies.

  • station_ids (np.ndarray) – Array of station IDs.

  • full_accuracy (bool, optional) – Whether to use the full accuracy of the EveryBeam library. Defaults to True. If False, the array factor and element response are calculated separately (the two values that multiply to give the full response). The array factor is only calculated at the middle time and frequency, under the assumption that the range of frequencies and times is small enough that the array factor will not change significantly. Magnitude of the differences vary by frequency and direction so use with caution.

  • apply_beam_norms (bool, optional) – Whether to apply beam normalisation. Defaults to True. Achieved by calculating the beam response at beam centre, and multiplying all Jones by the inverse of this central beam response.

  • iau_order (bool, optional) – If True, use IAU polarisation ordering, so set jones[0,0] to the NS dipole and jones[1,1] to EW. If False, jones[0,0] is EW.

  • element_only (bool, optional) – Whether to use only the element response. Defaults to False. Use this to look at the dipole response only, not the beam formed response.

  • parallactic_rotate (bool, optional) – Whether to apply parallactic angle rotation. Defaults to False.

  • element_response_model (str, optional) – The Everybeam element response model to use. Defaults to ‘hamaker’. Avaible options are ‘hamaker’ (LOFAR), ‘skala40_wave’ (OSKAR), and ‘MWA’ (MWA).

  • use_local_mwa (bool, optional) – Whether to use the local MWA model. Defaults to True. The local MWA model takes za/az instead of RA/Dec.

Returns:

The calculated Jones matrices with shape (num_stations, num_times, num_freqs, num_coords_in_thread, 2, 2), as well as the thread ID. Use the thread ID to insert this thread output into the correct place in the final Jones matrix.

Return type:

Tuple[np.ndarray, int]