|
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(), OpenExisting(), operator=(), and UvwFile().
|
inlinenoexcept |
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().
|
inlinenoexcept |
|
inlineprivate |
Create a new file on disk.
Definition at line 248 of file UvwFile.h.
References CreateNew(), file_, and kHeaderSize.
|
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 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_.
|
inlineprivate |
Definition at line 305 of file UvwFile.h.
References active_block_, block_is_changed_, ReadActiveBlock(), and WriteActiveBlock().
Referenced by ReadUvw(), and WriteUvw().
|
inlinestaticprivate |
|
inlinestaticprivate |
Definition at line 378 of file UvwFile.h.
References AreNear().
Referenced by AreNear(), and StoreOrCheck().
|
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().
|
inlinestatic |
|
inline |
|
inlineprivate |
Definition at line 374 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_, start_antenna_2_, and UvwFile().
|
inlineprivate |
Definition at line 316 of file UvwFile.h.
References active_block_, block_uvws_, file_, kUnsetPosition, n_antennas_, and reference_antenna_.
Referenced by ActivateBlock().
|
inlineprivate |
Definition at line 352 of file UvwFile.h.
References file_, kHeaderSize, kMagicHeaderTag, n_antennas_, 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 196 of file UvwFile.h.
References ActivateBlock(), block_uvws_, file_, n_antennas_, n_rows_, and rows_per_block_.
|
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 288 of file UvwFile.h.
References AreNear(), block_is_changed_, block_uvws_, IsSet(), kUnsetPosition, and UvwAsString().
Referenced by WriteUvw().
|
inlinestaticprivate |
Definition at line 385 of file UvwFile.h.
Referenced by StoreOrCheck().
|
inlineprivate |
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().
|
inlineprivate |
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().
|
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
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().
|
private |
Definition at line 423 of file UvwFile.h.
Referenced by ActivateBlock(), operator=(), ReadActiveBlock(), UvwFile(), UvwFile(), and WriteActiveBlock().
|
private |
Definition at line 431 of file UvwFile.h.
Referenced by ActivateBlock(), Close(), operator=(), StoreOrCheck(), UvwFile(), WriteActiveBlock(), and WriteUvw().
|
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().
|
private |
Definition at line 403 of file UvwFile.h.
Referenced by Close(), Filename(), operator=(), ReadActiveBlock(), ReadHeader(), ReadUvw(), UvwFile(), UvwFile(), 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 398 of file UvwFile.h.
Referenced by ReadHeader(), UvwFile(), UvwFile(), and WriteHeader().
|
staticconstexprprivate |
Definition at line 399 of file UvwFile.h.
Referenced by ReadHeader(), and WriteHeader().
|
staticconstexprprivate |
Definition at line 400 of file UvwFile.h.
Referenced by IsSet(), ReadActiveBlock(), StoreOrCheck(), UvwFile(), and WriteUvw().
|
private |
Definition at line 428 of file UvwFile.h.
Referenced by Close(), operator=(), ReadActiveBlock(), ReadHeader(), ReadUvw(), UvwFile(), 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 411 of file UvwFile.h.
Referenced by Close(), NRows(), operator=(), ReadUvw(), UvwFile(), UvwFile(), and WriteUvw().
|
private |
Definition at line 424 of file UvwFile.h.
Referenced by operator=(), ReadActiveBlock(), ReadHeader(), UvwFile(), 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 422 of file UvwFile.h.
Referenced by Close(), operator=(), ReadHeader(), ReadUvw(), UvwFile(), 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 427 of file UvwFile.h.
Referenced by operator=(), UvwFile(), and WriteUvw().