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
64 getArrayGeneric(rowNr, dataPtr);
65 }
66
68 getArrayGeneric(rowNr, dataPtr);
69 }
70
72 getArrayGeneric(rowNr, dataPtr);
73 }
74
81 const casacore::Array<casacore::Complex> *dataPtr) final {
82 putArrayGeneric(rowNr, dataPtr);
83 }
85 const casacore::Array<casacore::DComplex> *dataPtr) final {
86 putArrayGeneric(rowNr, dataPtr);
87 }
88 void putArraydoubleV(casacore::uInt rowNr, const casacore::Array<double> *dataPtr) final {
89 putArrayGeneric(rowNr, dataPtr);
90 }
91 void putArrayfloatV(casacore::uInt rowNr, const casacore::Array<float> *dataPtr) final {
92 putArrayGeneric(rowNr, dataPtr);
93 }
95 putArrayGeneric(rowNr, dataPtr);
96 }
97
98 void setOffset(uint64_t column_offset) { column_offset_ = column_offset; }
99 uint64_t getStoredSizeInBytes() const {
100 if (dtype() == casacore::TpBool) {
101 return (shape_[1] + 7) / 8;
102 } else {
103 const uint64_t type_size = SizeOfType(dtype());
104 return shape_[1] * type_size;
105 }
106 }
107
108 private:
109 StokesIStManColumn(const StokesIStManColumn &source) = delete;
110 void operator=(const StokesIStManColumn &source) = delete;
111
112 template <typename T>
114 bool ownership;
115 T *storage = dataPtr->getStorage(ownership);
116 const size_t n_values = shape_[1];
117 file_.Read(rowNr, column_offset_, storage, n_values);
118 ExpandFromStokesI(storage, n_values);
119 dataPtr->putStorage(storage, ownership);
120 }
121
122 template <typename T>
124 bool ownership;
125 const T *storage = dataPtr->getStorage(ownership);
126 const size_t n_values = shape_[1];
127 buffer_.Resize<T>(n_values);
128 const T *buffer = TransformToStokesI(storage, buffer_.Data<T>(), n_values);
129 file_.Write(rowNr, column_offset_, buffer, n_values);
130 dataPtr->freeStorage(storage, ownership);
131 }
132 void updateStride();
133
139};
140} // namespace casacore
141
142#include "StokesIStMan.h"
143
144namespace casacore {
145
146inline void StokesIStManColumn::updateStride() { parent_.CalculateAndUpdateStride(); }
147
148} // namespace casacore
149
150#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:74
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
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:559
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.