File: casamaskreader.cpp

package info (click to toggle)
wsclean 2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,196 kB
  • sloc: cpp: 34,504; ansic: 234; python: 174; makefile: 10
file content (40 lines) | stat: -rw-r--r-- 967 bytes parent folder | download | duplicates (3)
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
#include "casamaskreader.h"

#include <casacore/tables/Tables/Table.h>
#include <casacore/tables/Tables/ArrayColumn.h>

#include "uvector.h"

CasaMaskReader::CasaMaskReader(const std::string& path) : _path(path)
{
	casacore::Table table(path);
	casacore::ROArrayColumn<float> mapCol(table, "map");
	casacore::IPosition shape = mapCol.shape(0);
	_width = shape(0);
	_height = shape(1);
	_nPolarizations = shape(2);
	_nChannels = shape(3);
}

void CasaMaskReader::Read(bool* mask)
{
	casacore::Table table(_path);
	casacore::ROArrayColumn<float> mapCol(table, "map");
	casacore::Array<float> data(mapCol.get(0));
	for(size_t i=0; i!=_width*_height; ++i)
		mask[i] = false;
	casacore::Array<float>::contiter iter = data.cbegin();
	bool* maskPtr = mask;
	for(size_t j=0; j!=_nChannels*_nPolarizations; ++j)
	{
		for(size_t y=0; y!=_height; ++y)
		{
			for(size_t x=0; x!=_width; ++x)
			{
				*maskPtr = *maskPtr || (*iter!=0.0);
				++iter;
				++maskPtr;
			}
		}
	}
}