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) : StManColumn(DataType::TpDouble), file_(file) {}
19
20 Bool isWritable() const final { return true; }
21
23 void setShapeColumn(const IPosition &shape) final {
24 if (shape.size() != 1 || shape[0] != 3) {
25 throw std::runtime_error(
26 "UvwStMan can only be used for array columns with 1 dimension of "
27 "size 3");
28 }
29 }
30
31 IPosition shape(uInt) final { return IPosition{3}; }
32
33 IPosition shape(rownr_t) final { return IPosition{3}; }
34
35 void getArrayV(rownr_t row, ArrayBase &dataPtr) final {
36 Array<double> &array = static_cast<Array<double> &>(dataPtr);
37 bool ownership;
38 double *storage = array.getStorage(ownership);
39 const int antenna1 = antenna1_column_(row);
40 const int antenna2 = antenna2_column_(row);
41 file_.ReadUvw(row, antenna1, antenna2, storage);
42 array.putStorage(storage, ownership);
43 }
44
50 void putArrayV(rownr_t row, const ArrayBase &dataPtr) final {
51 const Array<double> &array = static_cast<const Array<double> &>(dataPtr);
52 bool ownership;
53 const double *storage = array.getStorage(ownership);
54 const int antenna1 = antenna1_column_(row);
55 const int antenna2 = antenna2_column_(row);
56 file_.WriteUvw(row, antenna1, antenna2, storage);
57 array.freeStorage(storage, ownership);
58 }
59
60 void Prepare(Table &table) {
61 antenna1_column_ = ScalarColumn<int>(table, "ANTENNA1");
62 antenna2_column_ = ScalarColumn<int>(table, "ANTENNA2");
63 }
64
65 private:
66 UvwStManColumn(const UvwStManColumn &source) = delete;
67 void operator=(const UvwStManColumn &source) = delete;
68
72};
73} // namespace casacore
74
75#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:69
StManColumn(int dataType)
Default constructor.
Definition StManColumn.h:74
Stores values of a UVW column in a compressed way.
Definition UvwFile.h:49
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)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
T * array
The actual storage.
Definition Block.h:689
unsigned int uInt
Definition aipstype.h:49
T * storage()
If you really, really, need a "raw" pointer to the beginning of the storage area this will give it to...
Definition Block.h:559
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