1#ifndef CASACORE_STOKES_I_ST_MAN_COLUMN_H_
2#define CASACORE_STOKES_I_ST_MAN_COLUMN_H_
4#include <casacore/tables/DataMan/StManColumn.h>
6#include <casacore/casa/Arrays/Array.h>
7#include <casacore/casa/Arrays/IPosition.h>
24 for (
size_t i = 0; i != n; ++i) {
25 const size_t index = n - i - 1;
26 const T
value = data[index];
27 data[index * 4] =
value;
28 data[index * 4 + 1] = T();
29 data[index * 4 + 2] = T();
30 data[index * 4 + 3] =
value;
36 for (
size_t i = 0; i != n; ++i) {
37 const size_t index = n - i - 1;
38 const bool value = data[index];
39 data[index * 4] =
value;
40 data[index * 4 + 1] =
value;
41 data[index * 4 + 2] =
value;
42 data[index * 4 + 3] =
value;
55 for (
size_t i = 0; i != n; ++i) {
58 new (&buffer[i *
sizeof(T)]) T((input[i * 4] + input[i * 4 + 3]) * T(0.5));
59 if (input[i * 4 + 1] != T(0.0) || input[i * 4 + 2] != T(0.0))
60 throw std::runtime_error(
61 "Stokes-I stman cannot store data for which the 2nd and 3rd "
62 "correlation are non-zero");
68 return reinterpret_cast<T *
>(buffer);
73 for (
size_t i = 0; i != n; ++i) {
74 const bool a = input[i * 4];
75 const bool b = input[i * 4 + 1];
76 const bool c = input[i * 4 + 2];
77 const bool d = input[i * 4 + 3];
78 if (a != b || a != c || a != d)
79 throw std::runtime_error(
80 "Stokes-I stman cannot store boolean data for which not all "
81 "correlations are equal");
82 new (&buffer[i])
bool(a);
84 return reinterpret_cast<bool *
>(buffer);
99 casacore::DataType
dtype)
111 throw std::runtime_error(
"StokesIStMan is used for a column with " +
113 " dimensions, but it can only be used for "
114 "columns with exactly 2 dimensions");
176 if (
dtype() == casacore::TpBool) {
177 return (
shape_[1] + 7) / 8;
179 const uint64_t type_size = SizeOfType(
dtype());
180 return shape_[1] * type_size;
188 template <
typename T>
192 const size_t n_values =
shape_[1];
198 template <
typename T>
202 const T *storage = dataPtr->
getStorage(ownership);
203 const size_t n_values =
shape_[1];
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.
void resize(size_t newSize, bool copy=true)
Old values are copied on resize if copy==true.
Base class for columns of the StokesIStMan.
void putArrayfloatV(casacore::uInt rowNr, const casacore::Array< float > *dataPtr) final
void putArrayDComplexV(casacore::uInt rowNr, const casacore::Array< casacore::DComplex > *dataPtr) final
BufferedColumnarFile & file_
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)
uint64_t getStoredSizeInBytes() const
const casacore::IPosition & shape() const
std::vector< char > buffer_
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 ...
uint64_t CalculateAndUpdateStride()
void Read(uint64_t row, uint64_t column_offset, float *data, uint64_t n)
Read one cell containing an array of floats.
void Write(uint64_t row, uint64_t column_offset, const float *data, uint64_t n)
Write one cell containing an array of floats.
this file contains all the compiler specific defines
T * TransformToStokesI(const T *input, char *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),...
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void ExpandFromStokesI(T *data, size_t n)
Expands n values from single Stokes I values to have 4 values, in place.
uInt64 rownr_t
Define the type of a row number in a table.