casacore
|
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 |
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:
An example of a baseline ordering that is not accepted:
|
defaultnoexcept |
Referenced by CreateNew(), and OpenExisting().
|
inlinenoexcept |
Definition at line 53 of file UvwFile.h.
References casacore::RowBasedFile::n_rows_.
|
inlinenoexcept |
|
inlineprivate |
|
inlineprivate |
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 232 of file UvwFile.h.
References active_block_, block_uvws_, file_, kUnsetPosition, n_antennas_, n_rows_, casacore::VarBufferedColumnarFile< BufferSize >::NRows(), ReadHeader(), reference_antenna_, and rows_per_block_.
|
inlineprivate |
Definition at line 279 of file UvwFile.h.
References active_block_, block_is_changed_, ReadActiveBlock(), and WriteActiveBlock().
Referenced by ReadUvw(), and WriteUvw().
|
inlinestaticprivate |
|
inlinestaticprivate |
Definition at line 352 of file UvwFile.h.
References AreNear().
Referenced by AreNear(), and StoreOrCheck().
|
inline |
Definition at line 203 of file UvwFile.h.
References block_is_changed_, block_uvws_, casacore::VarBufferedColumnarFile< BufferSize >::Close(), file_, casacore::VarBufferedColumnarFile< BufferSize >::IsOpen(), n_antennas_, n_rows_, rows_per_block_, WriteActiveBlock(), and WriteHeader().
Referenced by operator=(), and ~UvwFile().
|
inlinestatic |
|
inline |
Definition at line 218 of file UvwFile.h.
References file_, and casacore::VarBufferedColumnarFile< BufferSize >::Filename().
|
inlineprivate |
Definition at line 348 of file UvwFile.h.
References block_uvws_, and kUnsetPosition.
Referenced by StoreOrCheck(), and WriteUvw().
|
inline |
|
inlinestatic |
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_, and start_antenna_2_.
|
inlineprivate |
Definition at line 290 of file UvwFile.h.
References active_block_, block_uvws_, file_, kUnsetPosition, n_antennas_, casacore::VarBufferedColumnarFile< BufferSize >::NRows(), casacore::VarBufferedColumnarFile< BufferSize >::Read(), and reference_antenna_.
Referenced by ActivateBlock().
|
inlineprivate |
Definition at line 326 of file UvwFile.h.
References file_, kHeaderSize, kMagicHeaderTag, n_antennas_, casacore::VarBufferedColumnarFile< BufferSize >::ReadHeader(), reference_antenna_, and rows_per_block_.
Referenced by UvwFile().
|
inline |
Read a single row.
This may be done in random order, but is most efficient when reading a file contiguously.
row | denotes the row in the Casacore measurement set to be read. |
Definition at line 185 of file UvwFile.h.
References ActivateBlock(), block_uvws_, file_, casacore::VarBufferedColumnarFile< BufferSize >::IsOpen(), n_antennas_, n_rows_, and rows_per_block_.
Referenced by casacore::UvwStManColumn::getArrayV().
|
inlineprivate |
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 262 of file UvwFile.h.
References AreNear(), block_is_changed_, block_uvws_, IsSet(), kUnsetPosition, and UvwAsString().
Referenced by WriteUvw().
|
inlinestaticprivate |
Definition at line 359 of file UvwFile.h.
Referenced by StoreOrCheck().
|
inlineprivate |
Definition at line 311 of file UvwFile.h.
References active_block_, block_is_changed_, block_uvws_, file_, n_antennas_, reference_antenna_, and casacore::VarBufferedColumnarFile< BufferSize >::Write().
Referenced by ActivateBlock(), and Close().
|
inlineprivate |
Definition at line 339 of file UvwFile.h.
References file_, kHeaderSize, kMagicHeaderTag, n_antennas_, reference_antenna_, rows_per_block_, and casacore::VarBufferedColumnarFile< BufferSize >::WriteHeader().
Referenced by Close(), and WriteUvw().
|
inline |
Write a single row to the column.
This has to be done in a reasonable order; see the class description.
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
Definition at line 116 of file UvwFile.h.
References ActivateBlock(), block_uvws_, file_, casacore::VarBufferedColumnarFile< BufferSize >::IsOpen(), IsSet(), kUnsetPosition, n_antennas_, n_rows_, reference_antenna_, rows_per_block_, start_antenna_2_, StoreOrCheck(), and WriteHeader().
Referenced by casacore::UvwStManColumn::putArrayV().
|
private |
Definition at line 397 of file UvwFile.h.
Referenced by ActivateBlock(), operator=(), ReadActiveBlock(), UvwFile(), and WriteActiveBlock().
|
private |
Definition at line 405 of file UvwFile.h.
Referenced by ActivateBlock(), Close(), operator=(), StoreOrCheck(), and WriteActiveBlock().
|
private |
UVW for each antenna in the block.
Definition at line 404 of file UvwFile.h.
Referenced by Close(), IsSet(), operator=(), ReadActiveBlock(), ReadUvw(), StoreOrCheck(), UvwFile(), WriteActiveBlock(), and WriteUvw().
|
private |
Definition at line 377 of file UvwFile.h.
Referenced by Close(), Filename(), operator=(), ReadActiveBlock(), ReadHeader(), ReadUvw(), UvwFile(), WriteActiveBlock(), WriteHeader(), and WriteUvw().
|
staticconstexprprivate |
The header: char[8] "Uvw-col\0" (=kMagicHeaderTag) uint64_t rows_per_block uint64_t reference_antenna uint64_t n_antenna.
Definition at line 372 of file UvwFile.h.
Referenced by ReadHeader(), and WriteHeader().
|
staticconstexprprivate |
Definition at line 373 of file UvwFile.h.
Referenced by ReadHeader(), and WriteHeader().
|
staticconstexprprivate |
Definition at line 374 of file UvwFile.h.
Referenced by IsSet(), ReadActiveBlock(), StoreOrCheck(), UvwFile(), and WriteUvw().
|
private |
Definition at line 402 of file UvwFile.h.
Referenced by Close(), operator=(), ReadActiveBlock(), ReadHeader(), ReadUvw(), UvwFile(), WriteActiveBlock(), WriteHeader(), and WriteUvw().
|
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 385 of file UvwFile.h.
Referenced by Close(), NRows(), operator=(), ReadUvw(), UvwFile(), and WriteUvw().
|
private |
Definition at line 398 of file UvwFile.h.
Referenced by operator=(), ReadActiveBlock(), ReadHeader(), UvwFile(), WriteActiveBlock(), WriteHeader(), and WriteUvw().
|
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 396 of file UvwFile.h.
Referenced by Close(), operator=(), ReadHeader(), ReadUvw(), UvwFile(), WriteHeader(), and WriteUvw().
|
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 401 of file UvwFile.h.
Referenced by operator=(), and WriteUvw().