1#ifndef CASACORE_SISCO_ST_MAN_COLUMN_H_
2#define CASACORE_SISCO_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>
9#include <casacore/tables/Tables/ScalarColumn.h>
36 if (
dtype != casacore::TpComplex) {
37 throw std::runtime_error(
38 "Sisco storage manager column can only be used for a data column "
39 "with single precision complex values");
68 if (
shape.size() != 2) {
69 throw std::runtime_error(
70 "Sisco storage manager is used for a column with " +
71 std::to_string(
shape.size()) +
72 " dimensions, but it can only be used for "
73 "columns with exactly 2 dimensions");
114 if (
shape.size() >= 2) {
115 const int n_polarizations =
shape[0];
116 const size_t n_channels =
shape[1];
120 Complex *storage =
array.getStorage(ownership);
122 for (
int polarization = 0; polarization != n_polarizations;
125 for (
size_t channel = 0; channel != n_channels; ++channel) {
126 storage[channel * n_polarizations + polarization] =
130 array.putStorage(storage, ownership);
157 if (
array.shape().size() >= 2) {
158 const int n_polarizations =
array.shape()[0];
159 const size_t n_channels =
array.shape()[1];
163 const std::complex<float> *storage =
array.getStorage(ownership);
165 for (
int polarization = 0; polarization != n_polarizations;
168 field_id, data_desc_id, antenna1, antenna2, polarization);
169 for (
size_t channel = 0; channel != n_channels; ++channel) {
171 storage[channel * n_polarizations + polarization];
175 array.freeStorage(storage, ownership);
203 std::copy_n(
reinterpret_cast<const char *
>(&
kVersionMajor), 2,
205 std::copy_n(
reinterpret_cast<const char *
>(&
kVersionMinor), 2,
207 std::span<const std::byte> header(
208 reinterpret_cast<const std::byte *
>(header_buffer),
kHeaderSize);
222 std::span<std::byte> header(
reinterpret_cast<std::byte *
>(header_buffer),
228 std::copy_n(&header_buffer[0],
kMagicSize, magic_tag);
230 reinterpret_cast<char *
>(&version_major));
231 std::copy_n(&header_buffer[
kMagicSize + 2], 2,
232 reinterpret_cast<char *
>(&version_minor));
234 throw std::runtime_error(
235 "The file on disk is written as a Sisco version " +
236 std::to_string(version_major) +
237 " file, whereas this Casacore version supports only version " +
264 const int n_polarizations =
shape[0];
265 const int n_channels =
shape[1];
266 for (
int polarization = 0; polarization != n_polarizations;
269 field_id, data_desc_id, antenna1, antenna2, polarization);
270 reader_->Request(baseline_id, n_channels);
279 int antenna2,
int polarization) {
280 const std::array<int, 5> baseline{field_id, data_desc_id, antenna1,
281 antenna2, polarization};
288 return iterator->second;
303 if (
shape.size() >= 2) {
304 const int n_polarizations =
shape[0];
305 const int n_channels =
shape[1];
308 for (
int polarization = 0; polarization != n_polarizations;
319 static constexpr char kMagic[] =
"Sisco\0\0\0";
Non-templated base class for templated Array class.
static constexpr uint16_t kVersionMinor
rownr_t current_shape_reading_row_
std::optional< ShapesFileWriter > shapes_writer_
static constexpr char kMagic[]
std::vector< IPosition > shape_buffer_
A circular buffer to store the already read shapes.
std::optional< sisco::SiscoReader > reader_
size_t shape_write_position_
SiscoStManColumn(SiscoStMan &parent, DataType dtype)
Constructor, to be overloaded by subclass.
void setShapeColumn(const IPosition &shape) final
Set the dimensions of values in this column.
void putArrayV(rownr_t row, const ArrayBase &dataPtr) final
Write values into a particular row.
IPosition shape(unsigned row) final
bool canChangeShape() const final
Can the data manager handle chaging the shape of an existing array?
static constexpr size_t kMagicSize
IPosition shape(rownr_t row) final
Get the dimensions of the values in a particular row.
bool isShapeDefined(rownr_t row) final
Is the value shape defined in the given row?
std::optional< ShapesFileReader > shapes_reader_
bool isWritable() const final
Whether this column is writable.
std::map< std::array< int, 5 >, size_t > baseline_ids_
SiscoStManColumn(const SiscoStManColumn &source)=delete
ScalarColumn< int > antenna2_column_
void operator=(const SiscoStManColumn &source)=delete
void setShape(rownr_t, const IPosition &) final
Set the shape of an (variable-shaped) array in the given row.
void setShape(unsigned, const IPosition &) final
size_t shape_read_position_
size_t GetBaselineId(int field_id, int data_desc_id, int antenna1, int antenna2, int polarization)
void getArrayV(rownr_t row, ArrayBase &dataPtr) final
Read the values for a particular row.
ScalarColumn< int > data_desc_id_column_
static constexpr uint16_t kVersionMajor
static constexpr char kShapesExtension[]
ScalarColumn< int > antenna1_column_
ScalarColumn< int > field_id_column_
std::optional< sisco::SiscoWriter > writer_
bool isShapeDefined(unsigned) final
std::string ShapesFilename() const
static constexpr size_t kHeaderSize
std::vector< std::complex< float > > buffer_
The Stokes I storage manager behaves like a full set of (4) polarizations but only stores the Stokes ...
StManColumn(int dataType)
Default constructor.
this file contains all the compiler specific defines
TYPE * array
the allocated array
uInt64 rownr_t
Define the type of a row number in a table.