casacore
Loading...
Searching...
No Matches
UvwStManColumn.h
Go to the documentation of this file.
1#ifndef CASACORE_STOKES_I_ST_MAN_COLUMN_H_
2#define CASACORE_STOKES_I_ST_MAN_COLUMN_H_
3
4#include <casacore/tables/DataMan/StManColumn.h>
5#include <casacore/tables/Tables/ScalarColumn.h>
6
7#include <casacore/casa/Arrays/Array.h>
8#include <casacore/casa/Arrays/IPosition.h>
9
10#include "UvwFile.h"
11
12#include <optional>
13
14namespace casacore {
15
16class UvwStManColumn final : public StManColumn {
17 public:
18 explicit UvwStManColumn(UvwFile &file)
19 : StManColumn(DataType::TpDouble), file_(file) {}
20
21 Bool isWritable() const final { return true; }
22
24 void setShapeColumn(const IPosition &shape) final {
25 if (shape.size() != 1 || shape[0] != 3) {
26 throw std::runtime_error(
27 "UvwStMan can only be used for array columns with 1 dimension of "
28 "size 3");
29 }
30 }
31
32 IPosition shape(uInt) final { return IPosition{3}; }
33
34 IPosition shape(rownr_t) final { return IPosition{3}; }
35
36 void getArrayV(rownr_t row, ArrayBase &dataPtr) final {
37 Array<double> &array = static_cast<Array<double> &>(dataPtr);
38 bool ownership;
39 double *storage = array.getStorage(ownership);
40 const int antenna1 = antenna1_column_(row);
41 const int antenna2 = antenna2_column_(row);
42 file_.ReadUvw(row, antenna1, antenna2, storage);
43 array.putStorage(storage, ownership);
44 }
45
51 void putArrayV(rownr_t row, const ArrayBase &dataPtr) final {
52 const Array<double> &array = static_cast<const Array<double> &>(dataPtr);
53 bool ownership;
54 const double *storage = array.getStorage(ownership);
55 const int antenna1 = antenna1_column_(row);
56 const int antenna2 = antenna2_column_(row);
57 file_.WriteUvw(row, antenna1, antenna2, storage);
58 array.freeStorage(storage, ownership);
59 }
60
61 void Prepare(Table &table) {
62 antenna1_column_ = ScalarColumn<int>(table, "ANTENNA1");
63 antenna2_column_ = ScalarColumn<int>(table, "ANTENNA2");
64 }
65
66 private:
67 UvwStManColumn(const UvwStManColumn &source) = delete;
68 void operator=(const UvwStManColumn &source) = delete;
69
73};
74} // namespace casacore
75
76#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:71
size_t size() const
Definition IPosition.h:570
Stores values of a UVW column in a compressed way.
Definition UvwFile.h:49
void WriteUvw(uint64_t row, size_t antenna1, size_t antenna2, const double *uvw)
Write a single row to the column.
Definition UvwFile.h:116
void ReadUvw(uint64_t row, size_t antenna1, size_t antenna2, double *uvw)
Read a single row.
Definition UvwFile.h:185
UvwStManColumn(UvwFile &file)
IPosition shape(rownr_t) final
Get the shape of the item in the given row.
void operator=(const UvwStManColumn &source)=delete
IPosition shape(uInt) final
void setShapeColumn(const IPosition &shape) final
Set the dimensions of values in this column.
ScalarColumn< int > antenna2_column_
Bool isWritable() const final
Test if data can be put into this column.
void getArrayV(rownr_t row, ArrayBase &dataPtr) final
Get the array value in the given row.
UvwStManColumn(const UvwStManColumn &source)=delete
ScalarColumn< int > antenna1_column_
void putArrayV(rownr_t row, const ArrayBase &dataPtr) final
Write values into a particular row.
void Prepare(Table &table)
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition ExprNode.h:1933
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44