Loading...
Searching...
No Matches
casacore::UvwFile Class Reference

Stores values of a UVW column in a compressed way. More...

`#include <UvwFile.h>`

## Public Member Functions

| UvwFile () noexcept=default
| UvwFile (UvwFile &&source) noexcept
| ~UvwFile () noexcept
UvwFile & | operator= (UvwFile &&rhs)
void | WriteUvw (uint64_t row, size_t antenna1, size_t antenna2, const double *uvw)
| Write a single row to the column.
void | ReadUvw (uint64_t row, size_t antenna1, size_t antenna2, double *uvw)
| Read a single row.
void | Close ()
uint64_t | NRows () const
std::string | Filename () const

## Static Public Member Functions

static UvwFile | CreateNew (const std::string &filename)
| Create a new UVW file on disk with the given filename.
static UvwFile | OpenExisting (const std::string &filename)
| Open an already existing UVW file from disk with the given filename.

## Private Member Functions

| UvwFile (const std::string &filename)
| Create a new file on disk.
| UvwFile (const std::string &filename, bool)
| Open an existing file from disk.
void | StoreOrCheck (size_t antenna, const std::array< double, 3 > &antenna_uvw)
| If this block does not have a value for the specified antenna, store the uvw value for it.
void | ActivateBlock (size_t block)
void | ReadActiveBlock ()
void | WriteActiveBlock ()
void | ReadHeader ()
void | WriteHeader ()
bool | IsSet (size_t antenna) const

## Static Private Member Functions

static bool | AreNear (std::array< double, 3 > a, std::array< double, 3 > b)
static bool | AreNear (double a, double b)
static std::string | UvwAsString (const std::array< double, 3 > &uvw)

## Private Attributes

BufferedColumnarFile | file_
uint64_t | n_rows_
| Number of rows in the Uvw column.
uint64_t | rows_per_block_
| A "block" is a contiguous number of baselines that together form one timestep.
uint64_t | active_block_
size_t | reference_antenna_
size_t | start_antenna_2_
| This value is used to determine the first baseline in the data, which is the baseline (reference_antenna_, start_antenna_2_).
size_t | n_antennas_
std::vector< std::array< double, 3 > > | block_uvws_
| UVW for each antenna in the block.
bool | block_is_changed_

## Static Private Attributes

static constexpr size_t | kHeaderSize
| The header: char[8] "Uvw-col\0" (=kMagicHeaderTag) uint64_t rows_per_block uint64_t reference_antenna uint64_t n_antenna.
static constexpr const char | kMagicHeaderTag [8]
static constexpr std::array< double, 3 > | kUnsetPosition

## Detailed Description

Stores values of a UVW column in a compressed way.

Instead of storing a UVW value per baseline, it stores one per antenna. It uses the fact that:

baseline_uvw = antenna2_uvw - antenna1_uvw.

By taking the first written antenna as reference antenna and storing the relative UVW distance of the other antennas towards the reference antenna, the baseline uvws can be reconstructed.

A small downside is that this requires the measurement set to be "reasonably" ordered: every timestep should have the same baselines in the same order. Also, it requires the baselines to be ordered such that a relation to the reference antenna can be made. A measurement set that is ordered either by antenna1 or antenna2 for which no baselines have been removed satisfies this. Removing an entire antenna is fine.

Example of acceptable antenna lists:

- [0,0] ; [0,1] ; [0,2] ; [1,1] ; [1,2] ; [2,2] Ordered by antenna1, no missing baselines, no missing antennas.
- [0,1] ; [0,2] ; [1,2] Ordered by antenna1, only auto-correlations are missing, no missing antennas.
- [0,0] ; [1,0] ; [2,0] ; [1,1] ; [2,1] ; [2,2] Ordered by antenna2, only auto-correlations are missing, no missing antennas.
- [1,3] ; [1,4] ; [3,4] Ordered by antenna1, misses antenna 0 and 2.

An example of a baseline ordering that is not accepted:

- [1, 2] ; [3, 4] The class will use 1 as reference antenna and calculate antenna 2 relative to that. However, it can't store 3 or 4 relative to 1.

Definition at line 49 of file UvwFile.h.

## Constructor & Destructor Documentation

## UvwFile() [1/4]

casacore::UvwFile::UvwFile | ( |  | ) |

default noexcept

Referenced by CreateNew(), OpenExisting(), operator=(), and UvwFile().

## UvwFile() [2/4]

casacore::UvwFile::UvwFile | ( | UvwFile && | source | ) |

inline noexcept

Definition at line 53 of file UvwFile.h.

References active_block_, block_is_changed_, block_uvws_, file_, casacore::move(), n_antennas_, n_rows_, reference_antenna_, rows_per_block_, start_antenna_2_, and UvwFile().

## ~UvwFile()

casacore::UvwFile::~UvwFile | ( |  | ) |

inline noexcept

Definition at line 73 of file UvwFile.h.

References Close().

## UvwFile() [3/4]

casacore::UvwFile::UvwFile | ( | const std::string & | filename | ) |

inline private

Create a new file on disk.

Definition at line 248 of file UvwFile.h.

References CreateNew(), file_, and kHeaderSize.

## UvwFile() [4/4]

casacore::UvwFile::UvwFile | ( | const std::string & | filename,
|  | bool | )

inline private

Open an existing file from disk.

The last parameter is a dummy parameter to distinguish it from the creating constructor.

Setting the size of block_uvws_ here, saves an extra size check in ActivateBlock().

Definition at line 256 of file UvwFile.h.

References active_block_, block_uvws_, file_, kHeaderSize, kUnsetPosition, n_antennas_, n_rows_, OpenExisting(), ReadHeader(), reference_antenna_, and rows_per_block_.

## Member Function Documentation

## ActivateBlock()

void casacore::UvwFile::ActivateBlock | ( | size_t | block | ) |

inline private

Definition at line 305 of file UvwFile.h.

References active_block_, block_is_changed_, ReadActiveBlock(), and WriteActiveBlock().

Referenced by ReadUvw(), and WriteUvw().

## AreNear() [1/2]

bool casacore::UvwFile::AreNear | ( | double | a,
|  | double | b )

inline static private

Definition at line 381 of file UvwFile.h.

## AreNear() [2/2]

bool casacore::UvwFile::AreNear | ( | std::array< double, 3 > | a,
|  | std::array< double, 3 > | b )

inline static private

Definition at line 378 of file UvwFile.h.

References AreNear().

Referenced by AreNear(), and StoreOrCheck().

## Close()

void casacore::UvwFile::Close | ( |  | ) |

inline

This handles two special cases: i) if only one block of visibilities is written, no repetition of baseline would have been identified yet. In that case, we now know the block size. ii) in case only a single auto-correlation (one antenna) is written without any cross-correlations, the compressed file will remain empty. We then have to identify how many rows are really in the MS, which is done by setting rows_per_block_ to the nr of rows. When reading such an MS, the fact that n_antennas_ == 1 is then a trigger to use rows_per_block_ as nrows, instead of the size of the compressed file.

Definition at line 215 of file UvwFile.h.

References block_is_changed_, block_uvws_, file_, n_antennas_, n_rows_, rows_per_block_, WriteActiveBlock(), and WriteHeader().

Referenced by operator=(), and ~UvwFile().

## CreateNew()

UvwFile casacore::UvwFile::CreateNew | ( | const std::string & | filename | ) |

inline static

Create a new UVW file on disk with the given filename.

Definition at line 100 of file UvwFile.h.

References UvwFile().

Referenced by UvwFile().

## Filename()

std::string casacore::UvwFile::Filename | ( |  | ) | const

inline

Definition at line 242 of file UvwFile.h.

References file_.

## IsSet()

bool casacore::UvwFile::IsSet | ( | size_t | antenna | ) | const

inline private

Definition at line 374 of file UvwFile.h.

References block_uvws_, and kUnsetPosition.

Referenced by StoreOrCheck(), and WriteUvw().

## NRows()

uint64_t casacore::UvwFile::NRows | ( |  | ) | const

inline

Definition at line 241 of file UvwFile.h.

References n_rows_.

## OpenExisting()

UvwFile casacore::UvwFile::OpenExisting | ( | const std::string & | filename | ) |

inline static

Open an already existing UVW file from disk with the given filename.

Definition at line 107 of file UvwFile.h.

References UvwFile().

Referenced by UvwFile().

## operator=()

UvwFile & casacore::UvwFile::operator= | ( | UvwFile && | rhs | ) |

inline

Definition at line 75 of file UvwFile.h.

References active_block_, block_is_changed_, block_uvws_, Close(), file_, n_antennas_, n_rows_, reference_antenna_, rows_per_block_, start_antenna_2_, and UvwFile().

## ReadActiveBlock()

void casacore::UvwFile::ReadActiveBlock | ( |  | ) |

inline private

Definition at line 316 of file UvwFile.h.

References active_block_, block_uvws_, file_, kUnsetPosition, n_antennas_, and reference_antenna_.

Referenced by ActivateBlock().

## ReadHeader()

void casacore::UvwFile::ReadHeader | ( |  | ) |

inline private

Definition at line 352 of file UvwFile.h.

References file_, kHeaderSize, kMagicHeaderTag, n_antennas_, reference_antenna_, and rows_per_block_.

Referenced by UvwFile().

## ReadUvw()

void casacore::UvwFile::ReadUvw | ( | uint64_t | row,
|  | size_t | antenna1,
|  | size_t | antenna2,
|  | double * | uvw )

inline

Read a single row.

This may be done in random order, but is most efficient when reading a file contiguously.

Parameters

  row | denotes the row in the Casacore measurement set to be read.

Definition at line 196 of file UvwFile.h.

References ActivateBlock(), block_uvws_, file_, n_antennas_, n_rows_, and rows_per_block_.

## StoreOrCheck()

void casacore::UvwFile::StoreOrCheck | ( | size_t | antenna,
|  | const std::array< double, 3 > & | antenna_uvw )

inline private

If this block does not have a value for the specified antenna, store the uvw value for it.

If it does have a value, the value is checked. This check has a relatively high tolerance (1e-5, fractionally) because it is only there to catch "significant" errors caused by e.g. writing in the wrong order.

Definition at line 288 of file UvwFile.h.

References AreNear(), block_is_changed_, block_uvws_, IsSet(), kUnsetPosition, and UvwAsString().

Referenced by WriteUvw().

## UvwAsString()

std::string casacore::UvwFile::UvwAsString | ( | const std::array< double, 3 > & | uvw | ) |

inline static private

Definition at line 385 of file UvwFile.h.

Referenced by StoreOrCheck().

## WriteActiveBlock()

void casacore::UvwFile::WriteActiveBlock | ( |  | ) |

inline private

Definition at line 337 of file UvwFile.h.

References active_block_, block_is_changed_, block_uvws_, file_, n_antennas_, and reference_antenna_.

Referenced by ActivateBlock(), and Close().

## WriteHeader()

void casacore::UvwFile::WriteHeader | ( |  | ) |

inline private

Definition at line 365 of file UvwFile.h.

References file_, kHeaderSize, kMagicHeaderTag, n_antennas_, reference_antenna_, and rows_per_block_.

Referenced by Close(), and WriteUvw().

## WriteUvw()

void casacore::UvwFile::WriteUvw | ( | uint64_t | row,
|  | size_t | antenna1,
|  | size_t | antenna2,
|  | const double * | uvw )

inline

Write a single row to the column.

This has to be done in a reasonable order; see the class description.

Parameters

  row | denotes the row in the Casacore measurement set to be read.

The row/block is zero when there's not yet a full block written.

This baseline is the first baseline of a new block, so the block size can be determined

baseline = a2 - a1 with a1 = 0

baseline = a2 - a1 with a2 = 0

baseline = a2 - a1. Given a1: a2 = baseline + a1

baseline = a2 - a1. Given a2: a1 = a2 - baseline

In the special case of a file with only auto-correlations, the positions of the antennas can not be established in this case, it's also not necessary, because a zero uvw can be returned for auto-correlations. However, it will cause StoreOrCheck() to be never called, and therefore the block is never written to the file, and upon read the nr. of rows can not be determined. So, if this is an auto-correlation that has not yet been written, mark the block as changed so it gets written.

Definition at line 116 of file UvwFile.h.

References ActivateBlock(), block_is_changed_, block_uvws_, file_, IsSet(), kUnsetPosition, n_antennas_, n_rows_, reference_antenna_, rows_per_block_, start_antenna_2_, StoreOrCheck(), and WriteHeader().

## Member Data Documentation

## active_block_

uint64_t casacore::UvwFile::active_block_

private

Definition at line 423 of file UvwFile.h.

Referenced by ActivateBlock(), operator=(), ReadActiveBlock(), UvwFile(), UvwFile(), and WriteActiveBlock().

## block_is_changed_

bool casacore::UvwFile::block_is_changed_

private

Definition at line 431 of file UvwFile.h.

Referenced by ActivateBlock(), Close(), operator=(), StoreOrCheck(), UvwFile(), WriteActiveBlock(), and WriteUvw().

## block_uvws_

std::vector<std::array<double, 3> > casacore::UvwFile::block_uvws_

private

UVW for each antenna in the block.

Definition at line 430 of file UvwFile.h.

Referenced by Close(), IsSet(), operator=(), ReadActiveBlock(), ReadUvw(), StoreOrCheck(), UvwFile(), UvwFile(), WriteActiveBlock(), and WriteUvw().

## file_

BufferedColumnarFile casacore::UvwFile::file_

private

Definition at line 403 of file UvwFile.h.

Referenced by Close(), Filename(), operator=(), ReadActiveBlock(), ReadHeader(), ReadUvw(), UvwFile(), UvwFile(), UvwFile(), WriteActiveBlock(), WriteHeader(), and WriteUvw().

## kHeaderSize

size_t casacore::UvwFile::kHeaderSize

static constexpr private

The header: char[8] "Uvw-col\0" (=kMagicHeaderTag) uint64_t rows_per_block uint64_t reference_antenna uint64_t n_antenna.

Definition at line 398 of file UvwFile.h.

Referenced by ReadHeader(), UvwFile(), UvwFile(), and WriteHeader().

## kMagicHeaderTag

const char casacore::UvwFile::kMagicHeaderTag[8]

static constexpr private

Definition at line 399 of file UvwFile.h.

Referenced by ReadHeader(), and WriteHeader().

## kUnsetPosition

std::array<double, 3> casacore::UvwFile::kUnsetPosition

static constexpr private

Definition at line 400 of file UvwFile.h.

Referenced by IsSet(), ReadActiveBlock(), StoreOrCheck(), UvwFile(), and WriteUvw().

## n_antennas_

size_t casacore::UvwFile::n_antennas_

private

Definition at line 428 of file UvwFile.h.

Referenced by Close(), operator=(), ReadActiveBlock(), ReadHeader(), ReadUvw(), UvwFile(), UvwFile(), WriteActiveBlock(), WriteHeader(), and WriteUvw().

## n_rows_

uint64_t casacore::UvwFile::n_rows_

private

Number of rows in the Uvw column.

It is increased when writing a new Uvw row using WriteUvw(). This concept of a "row" is different from a row in the BufferedColumnarFile (i.e., `file_` ), as for each block (see below), only the uvw per antenna are stored, and these form the rows in that file.

Definition at line 411 of file UvwFile.h.

Referenced by Close(), NRows(), operator=(), ReadUvw(), UvwFile(), UvwFile(), and WriteUvw().

## reference_antenna_

size_t casacore::UvwFile::reference_antenna_

private

Definition at line 424 of file UvwFile.h.

Referenced by operator=(), ReadActiveBlock(), ReadHeader(), UvwFile(), UvwFile(), WriteActiveBlock(), WriteHeader(), and WriteUvw().

## rows_per_block_

uint64_t casacore::UvwFile::rows_per_block_

private

A "block" is a contiguous number of baselines that together form one timestep.

This is the same as saying they form one (triangular) correlation matrix. It can have auto-correlation but this is not required. A block may have missing antennas, but has some constraints on the ordering; see the class description. Per block, the UVW values are calculated per antenna. This value specifies the number of table rows in one block, i.e. the number of set elements in the correlation matrix.

Definition at line 422 of file UvwFile.h.

Referenced by Close(), operator=(), ReadHeader(), ReadUvw(), UvwFile(), UvwFile(), WriteHeader(), and WriteUvw().

## start_antenna_2_

size_t casacore::UvwFile::start_antenna_2_

private

This value is used to determine the first baseline in the data, which is the baseline (reference_antenna_, start_antenna_2_).

Definition at line 427 of file UvwFile.h.

Referenced by operator=(), UvwFile(), and WriteUvw().

The documentation for this class was generated from the following file:

- tables/AlternateMans/UvwFile.h