Visibility Block¶
-
class
oskar.
VisBlock
¶ This class provides a Python interface to an OSKAR visibility block.
The
oskar.VisBlock
class encapuslates a portion (or a block) of visibility data generated byoskar.Interferometer
. It should always be interpreted using the correspondingoskar.VisHeader
, as the data will be meaningless if taken out of context.To create a
oskar.VisBlock
, use thecreate_from_header()
method.To read a visibility data block from an OSKAR binary file, first call the
oskar.VisHeader.read()
class method. This will return a tuple containing both the header data and also a handle to the binary file, which can be used to read subsequentoskar.VisBlock
data structures from the same file using theread()
method on this class. See below for an example of how this can be done.To access the visibility data, use the method
cross_correlations()
(andauto_correlations()
, if present), which return references to numpy arrays. Similarly, the methodsbaseline_uu_metres()
,baseline_vv_metres()
andbaseline_ww_metres()
return references to the baseline coordinate data in the block.The visibility data array is four-dimensional and has the shape
(num_times_per_block, num_channels, num_baselines, num_pols)
, where the polarisation dimension is the fastest varying and the time dimension is the slowest varying. The baseline coordinate arrays have dimensions(num_times_per_block, num_baselines)
. These are standard numpy arrays which can be accessed from Python in the normal way. Use thenum_times
property to determine the actual number of usable time samples in the block.Note that since these are array references, it is possible to modify data inside the visibility block as well as read it: This allows easy post-processing of visibility data, for example, by subtracting data in one visibility block from another, or by modifying visibilities as they are generated using a subclass of
oskar.Interferometer
in theprocess_block()
method.Examples
To read all visibility blocks from a file
example.vis
:>>> (header, handle) = oskar.VisHeader.read('example.vis') >>> block = oskar.VisBlock.create_from_header(header) >>> print(header.num_blocks) 3 >>> for i in range(header.num_blocks): >>> block.read(header, handle, i) >>> print(block.start_time_index) 0 8 16
To get the shape of the visibility data block numpy array:
>>> (header, handle) = oskar.VisHeader.read('example.vis') >>> block = oskar.VisBlock.create_from_header(header) >>> vis = block.cross_correlations() >>> # Shape is (num_times_per_block, num_channels, num_baselines, num_pols) >>> print(vis.shape) (8, 3, 435, 4)
-
auto_correlations
()¶ Returns an array reference to the auto correlations.
-
baseline_uu_metres
()¶ Returns an array reference to the block baseline uu coordinates.
-
baseline_vv_metres
()¶ Returns an array reference to the block baseline vv coordinates.
-
baseline_ww_metres
()¶ Returns an array reference to the block baseline ww coordinates.
-
classmethod
create_from_header
(header)¶ Creates a visibility block from a header.
Parameters: header (oskar.VisHeader) – Visibility data header.
-
cross_correlations
()¶ Returns an array reference to the cross correlations.
-
num_baselines
¶ Returns the number of baselines.
-
num_channels
¶ Returns the number of frequency channels.
-
num_pols
¶ Returns the number of polarisations.
-
num_stations
¶ Returns the number of stations.
-
num_times
¶ Returns the number of time samples.
-
start_channel_index
¶ Returns the start channel index.
-
start_time_index
¶ Returns the start time index.
-
read
(header, binary_handle, block_index)¶ Reads visibility data from a binary file into the visibility block.
Use
oskar.VisHeader.read()
to obtain the header and binary file handle.Parameters: - header (oskar.VisHeader) – Visibility data header.
- binary_handle (oskar.Binary) – Handle to binary file.
- block_index (int) – Visibility block index to read.
-