casacore
Loading...
Searching...
No Matches
StokesIStManColumn.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
6#include <casacore/casa/Arrays/Array.h>
7#include <casacore/casa/Arrays/IPosition.h>
8
10#include "MorphingArray.h"
11#include "StokesIConversions.h"
12
13#include <optional>
14
15namespace casacore {
16
17class StokesIStMan;
18
24 public:
31 casacore::DataType dtype)
32 : casacore::StManColumn(dtype), parent_(parent), file_(file) {}
33
38 casacore::Bool isWritable() const final { return true; }
39
42 if (shape.size() != 2) {
43 throw std::runtime_error("StokesIStMan is used for a column with " +
44 std::to_string(shape.size()) +
45 " dimensions, but it can only be used for "
46 "columns with exactly 2 dimensions");
47 }
48 shape_ = shape;
50 }
51
56 const casacore::IPosition &shape() const { return shape_; }
57
65 getArrayGeneric(rowNr, dataPtr);
66 }
67
69 casacore::Array<float> *dataPtr) final {
70 getArrayGeneric(rowNr, dataPtr);
71 }
72
74 casacore::Array<casacore::Bool> *dataPtr) final {
75 getArrayGeneric(rowNr, dataPtr);
76 }
77
84 casacore::uInt rowNr,
85 const casacore::Array<casacore::Complex> *dataPtr) final {
86 putArrayGeneric(rowNr, dataPtr);
87 }
89 casacore::uInt rowNr,
90 const casacore::Array<casacore::DComplex> *dataPtr) final {
91 putArrayGeneric(rowNr, dataPtr);
92 }
94 const casacore::Array<double> *dataPtr) final {
95 putArrayGeneric(rowNr, dataPtr);
96 }
98 const casacore::Array<float> *dataPtr) final {
99 putArrayGeneric(rowNr, dataPtr);
100 }
102 const casacore::Array<casacore::Bool> *dataPtr) final {
103 putArrayGeneric(rowNr, dataPtr);
104 }
105
106 void setOffset(uint64_t column_offset) { column_offset_ = column_offset; }
107 uint64_t getStoredSizeInBytes() const {
108 if (dtype() == casacore::TpBool) {
109 return (shape_[1] + 7) / 8;
110 } else {
111 const uint64_t type_size = SizeOfType(dtype());
112 return shape_[1] * type_size;
113 }
114 }
115
116 private:
117 StokesIStManColumn(const StokesIStManColumn &source) = delete;
118 void operator=(const StokesIStManColumn &source) = delete;
119
120 template <typename T>
122 bool ownership;
123 T *storage = dataPtr->getStorage(ownership);
124 const size_t n_values = shape_[1];
125 file_.Read(rowNr, column_offset_, storage, n_values);
126 ExpandFromStokesI(storage, n_values);
127 dataPtr->putStorage(storage, ownership);
128 }
129
130 template <typename T>
132 const casacore::Array<T> *dataPtr) {
133 bool ownership;
134 const T *storage = dataPtr->getStorage(ownership);
135 const size_t n_values = shape_[1];
136 buffer_.Resize<T>(n_values);
137 const T *buffer = TransformToStokesI(storage, buffer_.Data<T>(), n_values);
138 file_.Write(rowNr, column_offset_, buffer, n_values);
139 dataPtr->freeStorage(storage, ownership);
140 }
141 void updateStride();
142
148};
149} // namespace casacore
150
151#include "StokesIStMan.h"
152
153namespace casacore {
154
156 parent_.CalculateAndUpdateStride();
157}
158
159} // namespace casacore
160
161#endif
Array class for which the type is determined only at runtime.
void freeStorage(const T *&storage, bool deleteIt) const
If deleteIt is set, delete "storage".
void putStorage(T *&storage, bool deleteAndCopy)
putStorage() is normally called after a call to getStorage() (cf).
T * getStorage(bool &deleteIt)
Generally use of this should be shunned, except to use a FORTRAN routine or something similar.
StManColumn(int dataType)
Default constructor.
Definition StManColumn.h:78
void putArrayfloatV(casacore::uInt rowNr, const casacore::Array< float > *dataPtr) final
void putArrayDComplexV(casacore::uInt rowNr, const casacore::Array< casacore::DComplex > *dataPtr) final
void getArrayGeneric(casacore::uInt rowNr, casacore::Array< T > *dataPtr)
void getArrayfloatV(casacore::uInt rowNr, casacore::Array< float > *dataPtr) final
void getArrayComplexV(casacore::uInt rowNr, casacore::Array< casacore::Complex > *dataPtr) final
Read the values for a particular row.
void setOffset(uint64_t column_offset)
const casacore::IPosition & shape() const
void putArrayGeneric(casacore::uInt rowNr, const casacore::Array< T > *dataPtr)
StokesIStManColumn(StokesIStMan &parent, BufferedColumnarFile &file, casacore::DataType dtype)
Constructor, to be overloaded by subclass.
void getArrayBoolV(casacore::uInt rowNr, casacore::Array< casacore::Bool > *dataPtr) final
Get the array value in the given row.
casacore::IPosition shape(casacore::rownr_t) final
Get the shape of the item in the given row.
void putArraydoubleV(casacore::uInt rowNr, const casacore::Array< double > *dataPtr) final
void putArrayBoolV(casacore::uInt rowNr, const casacore::Array< casacore::Bool > *dataPtr) final
Put the array value into the given row.
StokesIStManColumn(const StokesIStManColumn &source)=delete
casacore::Bool isWritable() const final
Whether this column is writable.
void operator=(const StokesIStManColumn &source)=delete
void putArrayComplexV(casacore::uInt rowNr, const casacore::Array< casacore::Complex > *dataPtr) final
Write values into a particular row.
void setShapeColumn(const casacore::IPosition &shape) final
Set the dimensions of values in this column.
casacore::IPosition shape(casacore::uInt) final
Get the dimensions of the values in a particular row.
The Stokes I storage manager behaves like a full set of (4) polarizations but only stores the Stokes ...
bool Bool
Define the standard types used by Casacore.
uInt64 rownr_t
Define the type of a row number in a table.
this file contains all the compiler specific defines
Definition mainpage.dox:28
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:550
T * TransformToStokesI(const T *input, T *buffer, size_t n)
Calculates for every set of 4 input values the Stokes-I values by doing out = 0.5 * (in_pp + in_qq),...
VarBufferedColumnarFile< 100 *1024 > BufferedColumnarFile
void ExpandFromStokesI(T *data, size_t n)
Expands n values from single Stokes I values to have 4 values, in place.