Interferometer

class oskar.Interferometer(precision=None, settings=None)

This class provides a Python interface to the OSKAR interferometer simulator.

Use the oskar.Interferometer class to run interferometry simulations from Python using OSKAR. It requires a model of the sky, a model of the telescope and the observation parameters as inputs, and it produces a set of simulated visibility data and (u,v,w) coordinates as outputs.

The most basic way to use this class is as follows:

  1. Create a oskar.SettingsTree object for the oskar_sim_interferometer application and set required parameters either individually or using a Python dictionary. These parameters are the same as the ones which appear in the OSKAR GUI. (The allowed keys and values are detailed in the settings documentation.)
  2. Create a oskar.Interferometer object and pass it the settings via the constructor.
  3. Call the run() method.

A more flexible way is to partially set the parameters using a oskar.SettingsTree and then override some of them before calling run(). In particular, the sky model and/or telescope model can be set separately using the set_sky_model() and set_telescope_model() methods, which is useful if some parameters need to be changed as part of a loop in a script.

Examples

See the example scripts section for some examples of how to use oskar.Interferometer.

Note

It may sometimes be necessary to access the simulated visibility data directly as it is generated, instead of loading it afterwards from a Measurement Set or file. This can be significantly more efficient than loading and saving visibility data on disk if it needs to be modified or processed on-the-fly.

To do this, create a new class which inherits oskar.Interferometer and implement a new process_block() method. After instantiating it and calling run() on the new subclass, the process_block() method will be entered automatically each time a new visibility block has been simulated and is ready to process. Use the vis_header() method to obtain access to the visibility data header if required. The visibility data and (u,v,w) coordinates can then be accessed or manipulated directly using the accessor methods on the oskar.VisHeader and oskar.VisBlock classes.

__init__(precision=None, settings=None)

Creates an OSKAR interferometer simulator.

Parameters:
  • precision (Optional[str]) – Either ‘double’ or ‘single’ to specify the numerical precision of the simulation. Default ‘double’.
  • settings (Optional[oskar.SettingsTree]) – Optional settings to use to set up the simulator.
process_block(block, block_index)

Virtual function to process each visibility block in a worker thread.

The default implementation simply calls write_block() to write the data to any open files. Inherit this class and override this method to process the visibilities differently.

Parameters:
  • block (oskar.VisBlock) – A handle to the block to be processed.
  • block_index (int) – The index of the visibility block.
run()

Runs the interferometer simulator.

The method process_block() is called for each simulated visibility block, where a handle to the block is supplied as an argument. Inherit this class and override process_block() to process the visibilities differently.

set_coords_only(value)

Sets whether the simulator provides baseline coordinates only.

Parameters:value (bool) – If set, simulate coordinates only.
set_gpus(device_ids)

Sets the GPU device IDs to use.

Parameters:device_ids (int, array-like or None) – A list of the GPU IDs to use, or -1 to use all. If None, then no GPUs will be used.
set_horizon_clip(value)

Sets whether horizon clipping is performed.

Parameters:value (bool) – If set, apply horizon clipping.
set_max_sources_per_chunk(value)

Sets the maximum number of sources processed concurrently on one GPU.

Parameters:value (int) – Number of sources per chunk.
set_max_times_per_block(value)

Sets the maximum number of times in a visibility block.

Parameters:value (int) – Number of time samples per block.
set_num_devices(value)

Sets the number of compute devices to use.

A compute device may be either a local CPU core, or a GPU. To use only a single CPU core for simulation, and no GPUs, call:

set_gpus(None) set_num_devices(1)

Parameters:value (int) – Number of compute devices to use.
set_observation_frequency(start_frequency_hz, inc_hz=0.0, num_channels=1)

Sets observation start frequency, increment, and number of channels.

Parameters:
  • start_frequency_hz (float) – Frequency of the first channel, in Hz.
  • inc_hz (Optional[float]) – Frequency increment, in Hz.
  • num_channels (Optional[int]) – Number of frequency channels.
set_observation_time(start_time_mjd_utc, length_sec, num_time_steps)

Sets observation start time, length, and number of samples.

Parameters:
  • start_time_mjd_utc (float) – Observation start time, as MJD(UTC).
  • length_sec (float) – Observation length in seconds.
  • num_time_steps (int) – Number of time steps to simulate.
set_output_measurement_set(filename)

Sets the name of the output CASA Measurement Set.

Parameters:filename (str) – Output filename.
set_output_vis_file(filename)

Sets the name of the output OSKAR visibility file.

Parameters:filename (str) – Output filename.
set_settings_path(filename)

Sets the path to the input settings file or script.

This is used only to store the file in the output visibility data.

Parameters:filename (str) – Filename.
set_sky_model(sky_model)

Sets the sky model used for the simulation.

Parameters:sky_model (oskar.Sky) – Sky model object.
set_telescope_model(telescope_model)

Sets the telescope model used for the simulation.

Parameters:telescope_model (oskar.Telescope) – Telescope model object.
vis_header()

Returns the visibility header.

Returns:A handle to the visibility header.
Return type:header (oskar.VisHeader)
write_block(block, block_index)

Writes a finalised visibility block.

Parameters:
  • block (oskar.VisBlock) – The block to write.
  • block_index (int) – The simulation block index to write.
coords_only

Returns whether the simulator provides baseline coordinates only.

Returns:If set, simulate coordinates only.
Return type:bool
num_devices

Returns the number of compute devices selected.

Returns:The number of compute devices selected.
Return type:int
num_gpus

Returns the number of GPUs selected.

Returns:The number of GPUs selected.
Return type:int
num_vis_blocks

Returns the number of visibility blocks required for the simulation.

Returns:The number of visibility blocks required for the simulation.
Return type:int