wodenpy.use_libwoden

Ways to interact with the C/CUDA via ctypes.

array_layout_struct

class array_layout_struct.Array_Layout[source]

A ctypes structure representing the layout of an array of antennas.

ant_X

Pointer to an array of antenna X positions.

Type:

POINTER(c_double)

ant_Y

Pointer to an array of antenna Y positions.

Type:

POINTER(c_double)

ant_Z

Pointer to an array of antenna Z positions.

Type:

POINTER(c_double)

X_diff_metres

Pointer to an array of X position differences in metres.

Type:

POINTER(c_double)

Y_diff_metres

Pointer to an array of Y position differences in metres.

Type:

POINTER(c_double)

Z_diff_metres

Pointer to an array of Z position differences in metres.

Type:

POINTER(c_double)

ant_east

Pointer to an array of antenna east positions.

Type:

POINTER(c_double)

ant_north

Pointer to an array of antenna north positions.

Type:

POINTER(c_double)

ant_height

Pointer to an array of antenna height positions.

Type:

POINTER(c_double)

latitude

The latitude of the array.

Type:

c_double

num_baselines

The number of baselines in the array.

Type:

c_int

num_tiles

The number of tiles in the array.

Type:

c_int

lst_base

The local sidereal time of the array.

Type:

c_double

array_layout_struct.setup_array_layout(woden_settings: Woden_Settings_Float | Woden_Settings_Double, args: Namespace) Array_Layout[source]
Given the populated Woden_Settings struct and the command line arguments, set up the array_layout struct, and fill it with the correct values, as well as doing the equivalent of a “malloc” for the arrays:
  • array_layout.ant_X

  • array_layout.ant_Y

  • array_layout.ant_Z

  • array_layout.X_diff_metres

  • array_layout.Y_diff_metres

  • array_layout.Z_diff_metres

Parameters:
  • woden_settings (Union[Woden_Settings_Float, Woden_Settings_Double]) – Populated Woden_Settings struct.

  • args (argparse.Namespace) – Input arguments from the command line that have been checked using wodenpy.use_libwoden.check_args.check_args.

Returns:

array_layout – Initialised Array_Layout struct.

Return type:

Array_Layout

beam_settings

class beam_settings.BeamTypes(value)[source]

Enumeration of beam types used in WODEN.

This class allows us to label the WODEN primary beam models with a unique name/value, but as it’s an enum each label only takes 8 bytes of memory, so we can stack loads of them into an array. We can also do numpy operations on them like np.where.

NO_BEAM

No beam type.

Type:

int

GAUSS_BEAM

Gaussian beam type.

Type:

int

FEE_BEAM

FEE beam type.

Type:

int

ANALY_DIPOLE

Analytical dipole beam type.

Type:

int

FEE_BEAM_INTERP

Interpolated FEE beam type.

Type:

int

MWA_ANALY

MWA analytical beam type.

Type:

int

shapelets

shapelets.calc_basis_func_1D_numpy(n: int, x: float | ndarray, beta=1) ndarray[source]

Calculate shapelet basis function values to use in WODEN. These values work with models fitted using SHAMFI https://github.com/JLBLine/SHAMFI

See Line et al. 2020 https://doi.org/10.1017/pasa.2020.18 for more information on shapelet fitting

Parameters:
  • n (int) – Order of shapelet basis function to calculate

  • x (Union[float, np.ndarray]) – Coordinate(s) to evaluate the basis function at

  • beta (int, optional) – The x-coord scaling factor, should be 1 when used with WODEN, by default 1

Returns:

The basis function values

Return type:

np.ndarray

shapelets.create_sbf(precision='double', sbf_N=101, sbf_c=5000, sbf_dx=0.01)[source]

Creates a ctypes array of float or doubles, containing shapelet basis functions to feed into run_woden.

All settings default to settings hard-coded into libwoden_double.so, so only mess with them if you know what you’re doing. A future iteration of WODEN could have sbf_N, sbf_c, sbf_dx put into woden_settings to allow for on-the-fly basis function adjustment.

With the defaults listed below, each basis function will be calculate over a range of x = -50 to x = 50, with a resolution of x = 0.01 (for a total of 10001 x values per basis function).

The final array is 1D, populated by basis function n = 0 for all x values, up to basis function n = (sbf_N - 1).

Parameters:
  • precision (str, optional) – Precision to return. If set to ‘float’, uses c_float, if set to double uses c_double. By default set to “double”.

  • sbf_N (int, optional) – Sets what order of basis function to generate up to, by default 101

  • sbf_c (int, optional) – Sets the central array value, where x = 0 will be, by default 5000

  • sbf_dx (float, optional) – The x resolution of each array element, by default 0.01

Returns:

All of the basis functions stored in a 1D array of len = 2*sbf_c + 1

Return type:

c_float_Array or c_double_Array

shapelets.numpy_eval_hermite(n: int, x: float | ndarray) float | ndarray[source]

This function duplicates what scipy.special.eval_hermite does:

Evaluate physicist’s Hermite polynomial at a point.

Have found that installing scipy on some clusters can be problematic (looking at you Pawsey) so implement a numpy version to sidestep needed scipy.

See https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.eval_hermite.html#scipy-special-eval-hermite for more detail

Parameters:
  • n (int) – Order of hermite polynomial

  • x (Union[float, np.ndarray]) – Coordinate(s) to evaluate the polynomial at

Returns:

The evaulated polynomial values

Return type:

Union[float, np.ndarray]

skymodel_structs

class skymodel_structs.Components_Double[source]

A class structured equivalently to a components_t struct, used by the C and CUDA code in libwoden_double.so

Variables:
  • ras (POINTER(double)) – COMPONENT right ascensions (radians)

  • decs (POINTER(double)) – COMPONENT declinations (radians)

  • power_ref_freqs (POINTER(double)) – COMPONENT Flux density reference frequencies (Hz)

  • power_ref_stokesI (POINTER(user_precision_t)) – COMPONENT Stokes I reference flux density (Jy)

  • power_ref_stokesQ (POINTER(user_precision_t)) – COMPONENT Stokes Q reference flux density (Jy)

  • power_ref_stokesU (POINTER(user_precision_t)) – COMPONENT Stokes U reference flux density (Jy)

  • power_ref_stokesV (POINTER(user_precision_t)) – COMPONENT Stokes V reference flux density (Jy)

  • power_SIs (POINTER(user_precision_t)) – COMPONENT spectral indexes

  • curve_ref_freqs (POINTER(double)) – COMPONENT Flux density reference frequencies (Hz)

  • curve_ref_stokesI (POINTER(user_precision_t)) – COMPONENT Stokes I reference flux density (Jy)

  • curve_ref_stokesQ (POINTER(user_precision_t)) – COMPONENT Stokes Q reference flux density (Jy)

  • curve_ref_stokesU (POINTER(user_precision_t)) – COMPONENT Stokes U reference flux density (Jy)

  • curve_ref_stokesV (POINTER(user_precision_t)) – COMPONENT Stokes V reference flux density (Jy)

  • curve_SIs (POINTER(user_precision_t)) – COMPONENT spectral indexes

  • curve_qs (POINTER(user_precision_t)) – COMPONENT curvature

  • power_comp_inds (POINTER(int)) – The indexes of all power-law models w.r.t ra,dec

  • curve_comp_inds (POINTER(int)) – The indexes of all curved power-law models w.r.t ra,dec

  • list_comp_inds (POINTER(int)) – The indexes of all list models w.r.t ra,dec

  • list_freqs (POINTER(double)) – COMPONENT Flux density references frequencies (Hz)

  • list_stokesI (POINTER(user_precision_t)) – COMPONENT Stokes I list flux density (Jy)

  • list_stokesQ (POINTER(user_precision_t)) – COMPONENT Stokes Q list flux density (Jy)

  • list_stokesU (POINTER(user_precision_t)) – COMPONENT Stokes U list flux density (Jy)

  • list_stokesV (POINTER(user_precision_t)) – COMPONENT Stokes V list flux density (Jy)

  • num_list_values (POINTER(int)) – How many freq/flux values are in each COMPONENT lis

  • list_start_indexes (POINTER(int)) – How many freq/flux values are in each COMPONENT lis

  • otal_num_flux_entires – The total number of freq/flux values are in all lists POINTER(int) combine

  • extrap_stokesI (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes I flux densities (Jy)

  • extrap_stokesQ (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes Q flux densities (Jy)

  • extrap_stokesU (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes U flux densities (Jy)

  • extrap_stokesV (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes V flux densities (Jy)

  • shape_coeffs (POINTER(user_precision_t)) – Scaling coefficients for SHAPELET basis functions

  • n1s (POINTER(user_precision_t)) – 1st basis function order for SHAPELET basis functions

  • n2s (POINTER(user_precision_t)) – 2nd basis function order for SHAPELET basis functions

  • majors (POINTER(user_precision_t)) – GAUSSIAN/SHAPELET major axis (beta1, radians)

  • minors (POINTER(user_precision_t)) – GAUSSIAN/SHAPELET minor axis (beta2, radians)

  • pas (POINTER(user_precision_t)) – GAUSSIAN/SHAPELET position angles (radians)

  • param_indexes (POINTER(user_precision_t)) – An index value to match each coeff, n1, and n2 to the correct ra, dec, major, minor, pa for a SHAPELET

  • azs (POINTER(user_precision_t)) – SHAPELET source azimuth angles for all time steps

  • zas (POINTER(user_precision_t)) – SHAPELET source zenith angles for all time steps

  • beam_has – Hour angle of COMPONENTs for all time steps, used for beam calculPOINTER(double) ations

  • beam_decs – Declinations of COMPONENTs for all time steps, used for beam calculPOINTER(double) ations

  • num_primarybeam_values (POINTER(int)) – Number of beam calculations needed for COMPONENTs

  • gxs (POINTER(user_precision_complex_t)) – North-South Beam gain values for all directions, frequencies, and times for these COMPONENT

  • Dxs (POINTER(user_precision_complex_t)) – North-South Beam leakage values for all directions, frequencies, and times for these COMPONENT

  • Dys (POINTER(user_precision_complex_t)) – East-West Beam leakage values for all directions, frequencies, and times for these COMPONENT

  • gys (POINTER(user_precision_complex_t)) – East-West Beam gain values for all directions, frequencies, and times for these COMPONENT

  • ls (POINTER(double)) – Device memory l cosine direction coords for these COMPONENTs

  • ms (POINTER(double)) – Device memory m cosine direction coords for these COMPONENTs

  • ns (POINTER(double)) – Device memory n cosine direction coords for these COMPONENTs

class skymodel_structs.Components_Float[source]

A class structured equivalently to a components_t struct, used by the C and CUDA code in libwoden_float.so

Variables:
  • ras (POINTER(double)) – COMPONENT right ascensions (radians)

  • decs (POINTER(double)) – COMPONENT declinations (radians)

  • power_ref_freqs (POINTER(double)) – COMPONENT Flux density reference frequencies (Hz)

  • power_ref_stokesI (POINTER(user_precision_t)) – COMPONENT Stokes I reference flux density (Jy)

  • power_ref_stokesQ (POINTER(user_precision_t)) – COMPONENT Stokes Q reference flux density (Jy)

  • power_ref_stokesU (POINTER(user_precision_t)) – COMPONENT Stokes U reference flux density (Jy)

  • power_ref_stokesV (POINTER(user_precision_t)) – COMPONENT Stokes V reference flux density (Jy)

  • power_SIs (POINTER(user_precision_t)) – COMPONENT spectral indexes

  • curve_ref_freqs (POINTER(double)) – COMPONENT Flux density reference frequencies (Hz)

  • curve_ref_stokesI (POINTER(user_precision_t)) – COMPONENT Stokes I reference flux density (Jy)

  • curve_ref_stokesQ (POINTER(user_precision_t)) – COMPONENT Stokes Q reference flux density (Jy)

  • curve_ref_stokesU (POINTER(user_precision_t)) – COMPONENT Stokes U reference flux density (Jy)

  • curve_ref_stokesV (POINTER(user_precision_t)) – COMPONENT Stokes V reference flux density (Jy)

  • curve_SIs (POINTER(user_precision_t)) – COMPONENT spectral indexes

  • curve_qs (POINTER(user_precision_t)) – COMPONENT curvature

  • power_comp_inds (POINTER(int)) – The indexes of all power-law models w.r.t ra,dec

  • curve_comp_inds (POINTER(int)) – The indexes of all curved power-law models w.r.t ra,dec

  • list_comp_inds (POINTER(int)) – The indexes of all list models w.r.t ra,dec

  • list_freqs (POINTER(double)) – COMPONENT Flux density references frequencies (Hz)

  • list_stokesI (POINTER(user_precision_t)) – COMPONENT Stokes I list flux density (Jy)

  • list_stokesQ (POINTER(user_precision_t)) – COMPONENT Stokes Q list flux density (Jy)

  • list_stokesU (POINTER(user_precision_t)) – COMPONENT Stokes U list flux density (Jy)

  • list_stokesV (POINTER(user_precision_t)) – COMPONENT Stokes V list flux density (Jy)

  • num_list_values (POINTER(int)) – How many freq/flux values are in each COMPONENT lis

  • list_start_indexes (POINTER(int)) – How many freq/flux values are in each COMPONENT lis

  • otal_num_flux_entires – The total number of freq/flux values are in all lists POINTER(int) combine

  • extrap_stokesI (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes I flux densities (Jy)

  • extrap_stokesQ (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes Q flux densities (Jy)

  • extrap_stokesU (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes U flux densities (Jy)

  • extrap_stokesV (POINTER(user_precision_t)) – extrapolated COMPONENT Stokes V flux densities (Jy)

  • shape_coeffs (POINTER(user_precision_t)) – Scaling coefficients for SHAPELET basis functions

  • n1s (POINTER(user_precision_t)) – 1st basis function order for SHAPELET basis functions

  • n2s (POINTER(user_precision_t)) – 2nd basis function order for SHAPELET basis functions

  • majors (POINTER(user_precision_t)) – GAUSSIAN/SHAPELET major axis (beta1, radians)

  • minors (POINTER(user_precision_t)) – GAUSSIAN/SHAPELET minor axis (beta2, radians)

  • pas (POINTER(user_precision_t)) – GAUSSIAN/SHAPELET position angles (radians)

  • param_indexes (POINTER(user_precision_t)) – An index value to match each coeff, n1, and n2 to the correct ra, dec, major, minor, pa for a SHAPELET

  • azs (POINTER(user_precision_t)) – SHAPELET source azimuth angles for all time steps

  • zas (POINTER(user_precision_t)) – SHAPELET source zenith angles for all time steps

  • beam_has (POINTER(double)) – Hour angle of COMPONENTs for all time steps, used for beam calculations

  • beam_decs (POINTER(double)) – Declinations of COMPONENTs for all time steps, used for beam calculations

  • num_primarybeam_values (POINTER(int)) – Number of beam calculations needed for COMPONENTs

  • gxs (POINTER(user_precision_complex_t)) – North-South Beam gain values for all directions, frequencies, and times for these COMPONENT

  • Dxs (POINTER(user_precision_complex_t)) – North-South Beam leakage values for all directions, frequencies, and times for these COMPONENT

  • Dys (POINTER(user_precision_complex_t)) – East-West Beam leakage values for all directions, frequencies, and times for these COMPONENT

  • gys (POINTER(user_precision_complex_t)) – East-West Beam gain values for all directions, frequencies, and times for these COMPONENT

  • ls (POINTER(double)) – Device memory l cosine direction coords for these COMPONENTs

  • ms (POINTER(double)) – Device memory m cosine direction coords for these COMPONENTs

  • ns (POINTER(double)) – Device memory n cosine direction coords for these COMPONENTs

class skymodel_structs.Source_Catalogue_Double[source]

A class structured equivalent to a source_t struct, used by the C and CUDA code in libwoden_double.so

num_sources

The number of sources in the catalogue

Type:

int

num_shapelets

The total number of shapelets components in the catalogue

Type:

int

sources

A pointer to an array of Source_Double objects representing the sources in the catalogue

Type:

POINTER(Source_Double)

class skymodel_structs.Source_Catalogue_Float[source]

A class structured equivalent to a source_t struct, used by the C and CUDA code in libwoden_float.so

num_sources

The number of sources in the catalogue

Type:

int

num_shapelets

The total number of shapelets components in the catalogue

Type:

int

sources

A pointer to an array of Source_Float objects representing the sources in the catalogue

Type:

POINTER(Source_Float)

class skymodel_structs.Source_Double[source]

A class structured equivalent to a source_t struct, used by the C and CUDA code in libwoden_double.so

Variables:
  • name (c_char*32) – Source name

  • n_comps (c_int) – Total number of COMPONENTs in source

  • n_points (c_int) – Number of POINT source COMPONENTs

  • n_point_lists (c_int) – Number of POINTs with LIST type flux

  • n_point_powers (c_int) – Number of POINTs with POWER_LAW type flux

  • n_point_curves (c_int) – Number of POINTs with CURVED_POWER_LAW type flux

  • n_gauss (c_int) – Number of GAUSSIAN source COMPONENTs

  • n_gauss_lists (c_int) – Number of GAUSSIANs with LIST type flux

  • n_gauss_powers (c_int) – Number of GAUSSIANs with POWER_LAW type flux

  • n_gauss_curves (c_int) – Number of GAUSSIANs with CURVED_POWER_LAW type flux

  • n_shapes (c_int) – Number of SHAPELET source COMPONENTs

  • n_shape_lists (c_int) – Number of SHAPELETs with LIST type flux

  • n_shape_powers (c_int) – Number of SHAPELETs with POWER_LAW type flux

  • n_shape_curves (c_int) – Number of SHAPELETs with CURVED_POWER_LAW type flux

  • n_shape_coeffs (c_int) – Total number of SHAPELET coefficients

  • point_components (Components_Double) – Components_Double holding component information for all POINT COMPONENTs in this SOURCE

  • gauss_components (Components_Double) – Components_Double holding component information for all GAUSSIAN COMPONENTs in this SOURCE

  • shape_components (Components_Double) – Components_Double holding component information for all SHAPELET COMPONENTs in this SOURCE

  • d_point_components (Components_Double) – Components_Double holding component information on the device for all POINT COMPONENTs in this SOURCE

  • d_gauss_components (Components_Double) – Components_Double holding component information on the device for all GAUSSIAN COMPONENTs in this SOURCE

  • d_shape_components (Components_Double) – Components_Double holding component information on the device for all SHAPELET COMPONENTs in this SOURCE

class skymodel_structs.Source_Float[source]

A class structured equivalent to a source_t struct, used by the C and CUDA code in libwoden_float.so

Variables:
  • name (c_char*32) – Source name

  • n_comps (c_int) – Total number of COMPONENTs in source

  • n_points (c_int) – Number of POINT source COMPONENTs

  • n_point_lists (c_int) – Number of POINTs with LIST type flux

  • n_point_powers (c_int) – Number of POINTs with POWER_LAW type flux

  • n_point_curves (c_int) – Number of POINTs with CURVED_POWER_LAW type flux

  • n_gauss (c_int) – Number of GAUSSIAN source COMPONENTs

  • n_gauss_lists (c_int) – Number of GAUSSIANs with LIST type flux

  • n_gauss_powers (c_int) – Number of GAUSSIANs with POWER_LAW type flux

  • n_gauss_curves (c_int) – Number of GAUSSIANs with CURVED_POWER_LAW type flux

  • n_shapes (c_int) – Number of SHAPELET source COMPONENTs

  • n_shape_lists (c_int) – Number of SHAPELETs with LIST type flux

  • n_shape_powers (c_int) – Number of SHAPELETs with POWER_LAW type flux

  • n_shape_curves (c_int) – Number of SHAPELETs with CURVED_POWER_LAW type flux

  • n_shape_coeffs (c_int) – Total number of SHAPELET coefficients

  • point_components (Components_Float) – Components_Float holding component information for all POINT COMPONENTs in this SOURCE

  • gauss_components (Components_Float) – Components_Float holding component information for all GAUSSIAN COMPONENTs in this SOURCE

  • shape_components (Components_Float) – Components_Float holding component information for all SHAPELET COMPONENTs in this SOURCE

  • d_point_components (Components_Float) – Components_Float holding component information on the device for all POINT COMPONENTs in this SOURCE

  • d_gauss_components (Components_Float) – Components_Float holding component information on the device for all GAUSSIAN COMPONENTs in this SOURCE

  • d_shape_components (Components_Float) – Components_Float holding component information on the device for all SHAPELET COMPONENTs in this SOURCE

skymodel_structs.setup_chunked_source(chunk_map: Skymodel_Chunk_Map, num_freqs: int, num_times: int, beamtype: int, precision='double') Source_Float | Source_Double[source]

Sets up a ctypes structure class to contain a chunked sky model. This class is compatible with the C/CUDA code, and will allocate the correct amount of memory, based on whether the precision is either ‘double’ or ‘float’.

Parameters:
  • chunk_map (Skymodel_Chunk_Map) – Object containing information about the chunk of the sky model.

  • num_freqs (int) – The number of frequency channels.

  • num_times (int) – The number of time samples.

  • beamtype (int) – The type of primary beam.

  • precision (str, optional) – The precision to use. Can be either “float” or “double. Defaults to “double”.

Returns:

The ctypes structure class containing the chunked sky model.

Return type:

Source_Float or Source_Double

skymodel_structs.setup_components(chunk_map: Skymodel_Chunk_Map, chunked_source: Source_Float | Source_Double, num_freqs: int, num_times: int, comp_type: CompTypes, beamtype: int, c_user_precision: c_float | c_double)[source]

Given the mapping information in chunk_map, initialise the necessary components in chunked_source for the given comp_type, this being one of

  • chunked_source.point_components

  • chunked_source.gaussion_components

  • chunked_source.shape_components

This setup includes allocating memory.

Parameters:
  • chunk_map (Skymodel_Chunk_Map) – Object containing information about the chunk of the sky model.

  • chunked_source (Union) – [Source_Float, Source_Double] object containing the chunked source information.

  • num_freqs (int) – representing the number of frequencies.

  • num_times (int) – representing the number of times.

  • comp_type (CompTypes) – enum representing the type of component.

  • beamtype (int) – representing the type of beam.

  • c_user_precision (Union) – [c_float, c_double] representing the user precision.

skymodel_structs.setup_source_catalogue(num_sources: int, num_shapelets: int, precision='double')[source]

Creates a source catalogue object with the specified number of sources and shapelets.

Parameters:
  • num_sources (int) – The number of sources in the catalogue.

  • num_shapelets (int) – The number of shapelets for each source.

  • precision (str) – The precision of the source catalogue. Can be “float” or “double”. Default is “double”.

Returns:

source_catalogue – The initialised source_catalogue object.

Return type:

(Source_Catalogue_Float or Source_Catalogue_Double)

use_libwoden

use_libwoden.load_in_woden_library(precision='double')[source]

Load in the WODEN C and CUDA code via a dynamic library, with the required precision (either load libwoden_float.so or libwoden_double.so)

Parameters:

precision (str, optional) – Choose to use “float” precision or “double”. By default ‘double’

Returns:

run_woden – The C wrapper function run_woden, which runs the C/CUDA code. This function takes the following args when precision=”double”

  • ctypes.POINTER(Woden_Settings_Double)

  • ctypes.POINTER(Visi_Set_Double)

  • ctypes.POINTER(Source_Catalogue_Double)

  • ctypes.POINTER(Array_Layout)

  • ctypes.POINTER(ctypes.c_double)

This function takes the following args when precision=”float”
  • ctypes.POINTER(Woden_Settings_Float)

  • ctypes.POINTER(Visi_Set_Float)

  • ctypes.POINTER(Source_Catalogue_Float)

  • ctypes.POINTER(Array_Layout)

  • ctypes.POINTER(ctypes.c_float)

Return type:

_NamedFuncPointer

visibility_set

class visibility_set.Visi_Set_Double[source]

A class structured equivalently to a visi_set struct, used by the C and CUDA code in libwoden_double.so

Variables:
  • us_metres (POINTER(c_double)) – Output \(u\) for all time steps, frequency steps, and baselines

  • vs_metres (POINTER(c_double)) – Output \(v\) for all time steps, frequency steps, and baselines

  • ws_metres (POINTER(c_double)) – Output \(w\) for all time steps, frequency steps, and baselines

  • allsteps_sha0s (POINTER(c_double)) – Sine of hour angle of phase centre for all time steps, frequency steps, and baselines

  • allsteps_cha0s (POINTER(c_double)) – Cosine of hour angle of phase centre for all time steps, frequency steps, and baselines

  • allsteps_lsts (POINTER(c_double)) – Local sidereal time for all time steps, frequency steps, and baselines (radians)

  • allsteps_wavelengths (POINTER(c_double)) – Wavelengths for all time steps, frequency steps, and baselines (metres)

  • channel_frequencies (POINTER(c_double)) – Frequencies for all frequency steps (Hz)

  • sum_visi_XX_real (POINTER(c_double)) – Real values for XX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_XX_imag (POINTER(c_double)) – Imaginary values for XX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_XY_real (POINTER(c_double)) – Real values for XY polarisation for all time steps, frequency steps, and baselines

  • sum_visi_XY_imag (POINTER(c_double)) – Imaginary values for XY polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YX_real (POINTER(c_double)) – Real values for YX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YX_imag (POINTER(c_double)) – Imaginary values for YX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YY_real (POINTER(c_double)) – Real values for YY polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YY_imag (POINTER(c_double)) – Imaginary values for YY polarisation for all time steps, frequency steps, and baselines

class visibility_set.Visi_Set_Float[source]

A class structured equivalently to a visi_set struct, used by the C and CUDA code in libwoden_float.so

Variables:
  • us_metres (POINTER(c_float)) – Output \(u\) for all time steps, frequency steps, and baselines

  • vs_metres (POINTER(c_float)) – Output \(v\) for all time steps, frequency steps, and baselines

  • ws_metres (POINTER(c_float)) – Output \(w\) for all time steps, frequency steps, and baselines

  • allsteps_sha0s (POINTER(c_float)) – Sine of hour angle of phase centre for all time steps, frequency steps, and baselines

  • allsteps_cha0s (POINTER(c_float)) – Cosine of hour angle of phase centre for all time steps, frequency steps, and baselines

  • allsteps_lsts (POINTER(c_float)) – Local sidereal time for all time steps, frequency steps, and baselines (radians)

  • allsteps_wavelengths (POINTER(c_float)) – Wavelengths for all time steps, frequency steps, and baselines (metres)

  • channel_frequencies (POINTER(c_float)) – Frequencies for all frequency steps (Hz)

  • sum_visi_XX_real (POINTER(c_float)) – Real values for XX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_XX_imag (POINTER(c_float)) – Imaginary values for XX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_XY_real (POINTER(c_float)) – Real values for XY polarisation for all time steps, frequency steps, and baselines

  • sum_visi_XY_imag (POINTER(c_float)) – Imaginary values for XY polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YX_real (POINTER(c_float)) – Real values for YX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YX_imag (POINTER(c_float)) – Imaginary values for YX polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YY_real (POINTER(c_float)) – Real values for YY polarisation for all time steps, frequency steps, and baselines

  • sum_visi_YY_imag (POINTER(c_float)) – Imaginary values for YY polarisation for all time steps, frequency steps, and baselines

visibility_set.load_visibility_set(visibility_set=None, num_baselines=None, num_freq_channels=None, num_time_steps=None, precision=None, do_autos=False, num_ants=0)[source]

Read the WODEN ctype output and shove into a numpy arrays, ready to be put into a uvfits file. By default, WODEN only outputs cross-correlations. In this case, the output binary is ordered by baseline (fastest changing), frequency, and time (slowest changing). Visibility coords and data are read in, with the visi data output into an array of shape=(num_time_steps*num_baselines,1,1,num_freq_channels,4,3)), which is appropriate for a uvfits file. Needs to know whether WODEN was run with ‘float’ (32 bit) or ‘double’ (64 bit) precision to read in the data correctly.

If WODEN was run with do_autos=True, then auto correlations are also in the output binary. These are stored AFTER the cross-correlations, and orders by antenna (fastest changing), frequency, and time (slowest changing). In this case the data are output into an array of shape=(num_time_steps*(num_baselines+num_ants),1,1,num_freq_channels,4,3)), where we say a baseline is only defined between to different antennas. The visibilities are output to match the BASELINE array, which orders the autos and crosses via antenna pairs as (1,1), (1,2), (1,3) .. (2,2), (2,3) etc etc meaning the autos and crosses are mixed.

Parameters:
  • filename (string) – Name of WODEN binary file to read from

  • num_baselines (int) – Number of baselines in the binary file

  • num_freq_channels (int) – Number of frequencies in the binary file

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

  • precision (string) – Precision WODEN was run with - either ‘float’ or ‘double’

  • do_autos (int) – if True, data has auto-correlations in

  • do_autos – Number of antennas in the array

Returns:

  • uus (float array) – The \(u\) coordinates (seconds). These are zero for auto-correlations.

  • vvs (float array) – The \(v\) coordinates (seconds). These are zero for auto-correlations.

  • wws (float array) – The \(w\) coordinates (seconds). These are zero for auto-correlations.

  • v_container (float array) – Visibility data with shape=(num_time_steps*num_baselines,1,1,num_freq_channels,4,3))

visibility_set.setup_visi_set(num_visis: int, precision='double') Structure[source]

Sets up a ctypes structure class to contain the visibility outputs. This class is compatible with the C/CUDA code, and will allocate the correct amount of memory, based on whether the precision is either ‘double’ or ‘float’.

Parameters:
  • num_visis (int) – Number of visibilities to assign memory for

  • precision (str, optional) – Precision to be used, either ‘float’ or ‘double. Defaults to ‘double’

Returns:

visibility_set – An initialised wodenpy.use_libwoden.use_ctypes.Visi_Set_Float or wodenpy.use_libwoden.use_ctypes.Visi_Set_Double class, compatible with libwoden_float.so or libwoden_double.so.

Return type:

ctypes.Structure

visibility_set.setup_visi_set_array(num_bands: int, num_visis: int, precision='double') Structure[source]

We feed an array of visibility_sets to woden.c, this sets up the array and populates with empty visibility_sets of the correct precision

Parameters:
  • num_visis (int) – Number of visibilities to assign memory for

  • precision (str, optional) – Precision to be used, either ‘float’ or ‘double. Defaults to ‘double’

Returns:

An initialised array of num_bands times wodenpy.use_libwoden.use_ctypes.Visi_Set_Float or wodenpy.use_libwoden.use_ctypes.Visi_Set_Double class, compatible with libwoden_float.so or libwoden_double.so.

Return type:

ctypes.Structure

woden_settings

class woden_settings.Woden_Settings_Double[source]

A class structured equivalently to a visi_set struct, used by the C and CUDA code in libwoden_double.so

Variables:
  • lst_base (c_double) – Local sidereal time for first time step (radians)

  • lst_obs_epoch_base (c_double) – Local sidereal time for first time step (radians) for the observation epoch (e.g. in 2020 for a 2020 obs)

  • ra0 (c_double) – Right ascension of phase centre (radians)

  • dec0 (c_double) – Declination of phase centre (radians)

  • sdec0 (c_double) – Sine of Declination of phase centre (radians)

  • cdec0 (c_double) – Cosine of Declination of phase centre (radians)

  • num_baselines (c_int) – Number of baselines this array layout has

  • num_ants (c_int) – Number of antennas this array layout has (MWA calls this number of tiles)

  • num_freqs (c_int) – Number of frequencies per coarse band

  • frequency_resolution (c_double) – Frequency resolution of a fine channel (Hz)

  • base_low_freq (c_double) – The lowest fine channel frequency of band 1

  • num_time_steps (c_int) – Number of time steps to simulate

  • time_res (c_double) – Time resolution of simulation (seconds)

  • cat_filename (POINTER(c_char)) – Path to WODEN-style sky model

  • num_bands (c_int) – Number of coarse frequency bands to simulate

  • band_nums (POINTER(c_int)) – Which number coarse bands to simulate (e.g 1,4,6)

  • sky_crop_type (c_int) – Whether to crop sky models by SOURCE or COMPONENT

  • beamtype (c_int) – What type of primary beam to simulate with

  • gauss_beam_FWHM (c_double) – FWHM of Gaussian primary beam (degrees)

  • gauss_beam_ref_freq (c_double) – Reference frequency for given Gaussian primary beam FWHM

  • chunking_size (c_uint64) – Maximum number of COMPONENTs to include in a single chunk

  • hdf5_beam_path (POINTER(c_char)) – Path to *.hf file containing MWA FEE beam spherical harmonic information

  • jd_date (c_double) – Julian date at beginning of simulation

  • array_layout_file (c_int) – Do we have a path to the array layout or not

  • array_layout_file_path (POINTER(c_char)) – ath to file containing E,N,H coords of array layout

  • latitude (c_double) – Latitude of the array to simulate (radians)

  • latitude_obs_epoch_base (c_double) – Latitude of the array at the observation epoch (radians)

  • longitude (c_double) – Longitude of the array to simulate (radians)

  • FEE_ideal_delays ((c_double*16)) – Delay values specifying the pointing for the MWA FEE beam model

  • coarse_band_width (c_double) – Frequency bandwidth of a single coarse band (Hz)

  • gauss_ra_point (c_double) – The initial Right Ascension to point the Gaussian beam at (radians)

  • gauss_dec_point (c_double) – The initial Declination to point the Gaussian beam at (radians)

  • num_cross (c_int) – Total number of cross-correlations to simulate, so freqs*times*baselines

  • num_autos (c_int) – Total number of auto-correlations to simulate, so freqs*times*baselines

  • num_visis (c_int) – Total number of visibilities to simulate, so num_cross + num_autos

  • base_band_freq (c_double) – The lowest fine channel frequency in the current band being simulated

  • do_precession (c_int) – Boolean of whether to apply precession to the array layout or not

  • lsts (POINTER(c_double)) – Array to hold LSTs for all time centroids (these are different when precession is happening)

  • latitudes (POINTER(c_double)) – Array to hold latitudes for all time centroids (these are different when precession is happening)

  • mjds (POINTER(c_double)) – Array to hold modified julian dates for all time centroids

  • do_autos (c_int) – Boolean of whether to simulate autos or not (0 False, 1 True)

  • do_QUV (c_int) – Boolean of whether to use Stokes Q,U,V (0 False, 1 True)

class woden_settings.Woden_Settings_Float[source]

A class structured equivalently to a visi_set struct, used by the C and CUDA code in libwoden_float.so

cvar c_double lst_base:

Local sidereal time for first time step (radians)

Variables:
  • lst_obs_epoch_base (c_double) – Local sidereal time for first time step (radians) for the observation epoch (e.g. in 2020 for a 2020 obs)

  • ra0 (c_double) – Right ascension of phase centre (radians)

  • dec0 (c_double) – Declination of phase centre (radians)

  • sdec0 (c_double) – Sine of Declination of phase centre (radians)

  • cdec0 (c_double) – Cosine of Declination of phase centre (radians)

  • num_baselines (c_int) – Number of baselines this array layout has

  • num_ants (c_int) – Number of antennas this array layout has (MWA calls this number of tiles)

  • num_freqs (c_int) – Number of frequencies per coarse band

  • frequency_resolution (c_double) – Frequency resolution of a fine channel (Hz)

  • base_low_freq (c_double) – The lowest fine channel frequency of band 1

  • num_time_steps (c_int) – Number of time steps to simulate

  • time_res (c_double) – Time resolution of simulation (seconds)

  • cat_filename (POINTER(c_char)) – Path to WODEN-style sky model

  • num_bands (c_int) – Number of coarse frequency bands to simulate

  • band_nums (POINTER(c_int)) – Which number coarse bands to simulate (e.g 1,4,6)

  • sky_crop_type (c_int) – Whether to crop sky models by SOURCE or COMPONENT

  • beamtype (c_int) – What type of primary beam to simulate with

  • gauss_beam_FWHM (c_float) – FWHM of Gaussian primary beam (degrees)

  • gauss_beam_ref_freq (c_double) – Reference frequency for given Gaussian primary beam FWHM

  • chunking_size (c_uint64) – Maximum number of COMPONENTs to include in a single chunk

  • hdf5_beam_path (POINTER(c_char)) – Path to *.hf file containing MWA FEE beam spherical harmonic information

  • jd_date (c_double) – Julian date at beginning of simulation

  • array_layout_file (c_int) – Do we have a path to the array layout or not

  • array_layout_file_path (POINTER(c_char)) – ath to file containing E,N,H coords of array layout

  • latitude (c_double) – Latitude of the array to simulate (radians)

  • latitude_obs_epoch_base (c_double) – Latitude of the array at the observation epoch (radians)

  • longitude (c_float) – Longitude of the array to simulate (radians)

  • FEE_ideal_delays ((c_float*16)) – Delay values specifying the pointing for the MWA FEE beam model

  • coarse_band_width (c_double) – Frequency bandwidth of a single coarse band (Hz)

  • gauss_ra_point (c_double) – The initial Right Ascension to point the Gaussian beam at (radians)

  • gauss_dec_point (c_double) – The initial Declination to point the Gaussian beam at (radians)

  • num_cross (c_int) – Total number of cross-correlations to simulate, so freqs*times*baselines

  • num_autos (c_int) – Total number of auto-correlations to simulate, so freqs*times*baselines

  • num_visis (c_int) – Total number of visibilities to simulate, so num_cross + num_autos

  • base_band_freq (c_double) – The lowest fine channel frequency in the current band being simulated

  • do_precession (c_int) – Boolean of whether to apply precession to the array layout or not

  • lsts (POINTER(c_double)) – Array to hold LSTs for all time centroids (these are different when precession is happening)

  • latitudes (POINTER(c_double)) – Array to hold latitudes for all time centroids (these are different when precession is happening)

  • mjds (POINTER(c_double)) – Array to hold modified julian dates for all time centroids

  • do_autos (c_int) – Boolean of whether to simulate autos or not (0 False, 1 True)

  • do_QUV (c_int) – Boolean of whether to use Stokes Q,U,V (0 False, 1 True)

woden_settings.command(cmd)[source]

Runs the command string cmd using subprocess.call

Parameters:

cmd (string) – The command to run on the command line

woden_settings.create_woden_settings(args: Namespace, jd_date: float, lst: float) Woden_Settings_Float | Woden_Settings_Double[source]

Given the parsed and checked arguments in args, populate a woden_settings ctypes.Structure that can be passed into libwoden_float.so or libwoden_double.so, depending on the desired precision.

Parameters:
  • args (argparse.Namespace) – The populated arguments args = parser.parse_args()` as returned from the parser given by check_args()

  • jd_date (float) – The julian date of the first time step of the observation

  • lst (float) – The LST of the first time step of the observation (degrees)

Returns:

woden_settings – Populated ctype struct that can be passed into the C/CUDA code

Return type:

Woden_Settings_Float or Woden_Settings_Double

woden_settings.setup_lsts_and_phase_centre(woden_settings: Woden_Settings_Float | Woden_Settings_Double) ndarray[source]

Calculate the Local Sidereal Time (LST) for each time step of an observation, and set the phase centre coordinates. If woden_settings.do_precession == True, the returned LSTs are precessed back to J2000.

Parameters:

woden_settings ((Union[Woden_Settings_Float, Woden_Settings_Double])) – A populated Woden_Settings object containing the observation parameters.

Returns:

lsts – An array of LST values, one for each time step of the observation.

Return type:

np.ndarray: