casacore
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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
 
UvwFileoperator= (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:

An example of a baseline ordering that is not accepted:

Definition at line 49 of file UvwFile.h.

Constructor & Destructor Documentation

◆ UvwFile() [1/4]

casacore::UvwFile::UvwFile ( )
defaultnoexcept

Referenced by CreateNew(), and OpenExisting().

◆ UvwFile() [2/4]

casacore::UvwFile::UvwFile ( UvwFile &&  source)
inlinenoexcept

Definition at line 53 of file UvwFile.h.

References casacore::RowBasedFile::n_rows_.

◆ ~UvwFile()

casacore::UvwFile::~UvwFile ( )
inlinenoexcept

Definition at line 73 of file UvwFile.h.

References Close().

◆ UvwFile() [3/4]

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

Create a new file on disk.

Definition at line 224 of file UvwFile.h.

◆ UvwFile() [4/4]

casacore::UvwFile::UvwFile ( const std::string &  filename,
bool   
)
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_.

Member Function Documentation

◆ ActivateBlock()

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

Definition at line 279 of file UvwFile.h.

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

Referenced by ReadUvw(), and WriteUvw().

◆ AreNear() [1/2]

static bool casacore::UvwFile::AreNear ( double  a,
double  b 
)
inlinestaticprivate

Definition at line 355 of file UvwFile.h.

◆ AreNear() [2/2]

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

Definition at line 352 of file UvwFile.h.

References AreNear().

Referenced by AreNear(), and StoreOrCheck().

◆ Close()

void casacore::UvwFile::Close ( )
inline

◆ CreateNew()

static UvwFile casacore::UvwFile::CreateNew ( const std::string &  filename)
inlinestatic

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

Definition at line 100 of file UvwFile.h.

References UvwFile().

◆ Filename()

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

◆ IsSet()

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

Definition at line 348 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 217 of file UvwFile.h.

References n_rows_.

◆ OpenExisting()

static UvwFile casacore::UvwFile::OpenExisting ( const std::string &  filename)
inlinestatic

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

Definition at line 107 of file UvwFile.h.

References UvwFile().

◆ operator=()

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

◆ ReadActiveBlock()

void casacore::UvwFile::ReadActiveBlock ( )
inlineprivate

◆ ReadHeader()

void casacore::UvwFile::ReadHeader ( )
inlineprivate

◆ 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
rowdenotes 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().

◆ StoreOrCheck()

void casacore::UvwFile::StoreOrCheck ( size_t  antenna,
const std::array< double, 3 > &  antenna_uvw 
)
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().

◆ UvwAsString()

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

Definition at line 359 of file UvwFile.h.

Referenced by StoreOrCheck().

◆ WriteActiveBlock()

void casacore::UvwFile::WriteActiveBlock ( )
inlineprivate

◆ WriteHeader()

void casacore::UvwFile::WriteHeader ( )
inlineprivate

◆ 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
rowdenotes 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().

Member Data Documentation

◆ active_block_

uint64_t casacore::UvwFile::active_block_
private

Definition at line 397 of file UvwFile.h.

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

◆ block_is_changed_

bool casacore::UvwFile::block_is_changed_
private

Definition at line 405 of file UvwFile.h.

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

◆ block_uvws_

std::vector<std::array<double, 3> > casacore::UvwFile::block_uvws_
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().

◆ file_

BufferedColumnarFile casacore::UvwFile::file_
private

◆ kHeaderSize

constexpr size_t casacore::UvwFile::kHeaderSize
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().

◆ kMagicHeaderTag

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

Definition at line 373 of file UvwFile.h.

Referenced by ReadHeader(), and WriteHeader().

◆ kUnsetPosition

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

Definition at line 374 of file UvwFile.h.

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

◆ n_antennas_

size_t casacore::UvwFile::n_antennas_
private

◆ 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 385 of file UvwFile.h.

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

◆ reference_antenna_

size_t casacore::UvwFile::reference_antenna_
private

◆ 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 396 of file UvwFile.h.

Referenced by Close(), operator=(), ReadHeader(), ReadUvw(), 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 401 of file UvwFile.h.

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


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