File: msrowdata.h

package info (click to toggle)
aoflagger 2.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,232 kB
  • sloc: cpp: 61,805; python: 60; sh: 23; makefile: 8
file content (67 lines) | stat: -rw-r--r-- 2,279 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef MS_ROW_DATA_H
#define MS_ROW_DATA_H

#include <string.h>

#include <casacore/ms/MeasurementSets/MSColumns.h>

#include "types.h"

#include "../util/serializable.h"

/**
 * Encapsulates the information that is contained in the Data column in one row
 * of a measurement set.
 * If some of the meta data needs to be stored as well, use the MSRowDataExt class.
 * @see MSRowDataExt
 */
class MSRowData : public Serializable
{
	public:
		MSRowData() = default;
    
		MSRowData(unsigned polarizationCount, unsigned channelCount) :
		_polarizationCount(polarizationCount),
		_channelCount(channelCount),
		_realData(polarizationCount * channelCount),
		_imagData(polarizationCount * channelCount)
		{ }
		
		virtual void Serialize(std::ostream &stream) const final override
		{
			SerializeToUInt32(stream, _polarizationCount);
			SerializeToUInt32(stream, _channelCount);
			for(num_t val : _realData)
				SerializeToFloat(stream, val);
			for(num_t val : _imagData)
				SerializeToFloat(stream, val);
		}
		
		virtual void Unserialize(std::istream &stream) final override
		{
			_polarizationCount = UnserializeUInt32(stream);
			_channelCount = UnserializeUInt32(stream);
			const size_t size = _polarizationCount * _channelCount;
      _realData.resize(size);
      _imagData.resize(size);
			for(size_t i=0 ; i<size; ++i)
				_realData[i] = UnserializeFloat(stream);
			for(size_t i=0 ; i<size; ++i)
				_imagData[i] = UnserializeFloat(stream);
		}
		unsigned PolarizationCount() const { return _polarizationCount; }
		unsigned ChannelCount() const { return _channelCount; }
		const num_t *RealPtr() const { return _realData.data(); }
		const num_t *ImagPtr() const { return _imagData.data(); }
		num_t *RealPtr() { return _realData.data(); }
		num_t *ImagPtr() { return _imagData.data(); }
		const num_t *RealPtr(size_t channel) const { return &_realData[_polarizationCount * channel]; }
		const num_t *ImagPtr(size_t channel) const { return &_imagData[_polarizationCount * channel]; }
		num_t *RealPtr(size_t channel) { return &_realData[_polarizationCount * channel]; }
		num_t *ImagPtr(size_t channel) { return &_imagData[_polarizationCount * channel]; }
	private:
		unsigned _polarizationCount, _channelCount;
    std::vector<num_t> _realData, _imagData;
};

#endif