File: msselection.h

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 (136 lines) | stat: -rw-r--r-- 3,519 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef MS_SELECTION
#define MS_SELECTION

#include <cstring>
#include <casacore/casa/Arrays/Vector.h>

class MSSelection
{
public:
	enum EvenOddSelection { AllTimesteps, EvenTimesteps, OddTimesteps };
	
	MSSelection() :
		_fieldId(0),
		_bandId(0),
		_startChannel(0), _endChannel(0),
		_startTimestep(0), _endTimestep(0),
		_minUVWInM(0.0), _maxUVWInM(0.0),
		_autoCorrelations(false),
		_evenOddSelection(AllTimesteps)
	{ }
	
	bool HasChannelRange() const { return _endChannel != 0; }
	bool HasInterval() const { return _endTimestep != 0; }
	bool HasMinUVWInM() const { return _minUVWInM != 0.0; }
	bool HasMaxUVWInM() const { return _maxUVWInM != 0.0; }
	
	size_t ChannelRangeStart() const { return _startChannel; }
	size_t ChannelRangeEnd() const { return _endChannel; }
	
	size_t IntervalStart() const { return _startTimestep; }
	size_t IntervalEnd() const { return _endTimestep; }
	
	size_t FieldId() const { return _fieldId; }
	
	double MinUVWInM() const { return _minUVWInM; }
	double MaxUVWInM() const { return _maxUVWInM; }
	
	bool IsSelected(size_t fieldId, size_t timestep, size_t antenna1, size_t antenna2, const casacore::Vector<double>& uvw) const
	{
		if(HasMinUVWInM() || HasMaxUVWInM())
		{
			double u = uvw(0), v = uvw(1), w = uvw(2);
			return IsSelected(fieldId, timestep, antenna1, antenna2, sqrt(u*u + v*v + w*w));
		}
		else {
			return IsSelected(fieldId, timestep, antenna1, antenna2, 0.0);
		}
	}
	
	bool IsSelected(size_t fieldId, size_t timestep, size_t antenna1, size_t antenna2, double uvwInMeters) const
	{
		if(fieldId != _fieldId)
			return false;
		else if(HasInterval() && (timestep < _startTimestep || timestep >= _endTimestep))
			return false;
		else if(!_autoCorrelations && (antenna1 == antenna2))
			return false;
		else if(HasMinUVWInM() && uvwInMeters < _minUVWInM)
			return false;
		else if(HasMaxUVWInM() && uvwInMeters > _maxUVWInM)
			return false;
		else if(_evenOddSelection!=AllTimesteps)
		{
			if(_evenOddSelection==EvenTimesteps && timestep%2!=0)
				return false;
			else if(_evenOddSelection==OddTimesteps && timestep%2!=1)
				return false;
		}
		return true;
	}
	
	bool IsFieldSelected(size_t fieldId) const
	{
		return fieldId == _fieldId;
	}
	
	bool IsTimeSelected(size_t timestep)
	{
		if(HasInterval() && (timestep < _startTimestep || timestep >= _endTimestep))
			return false;
		else if(_evenOddSelection!=AllTimesteps)
		{
			if(_evenOddSelection==EvenTimesteps && timestep%2!=0)
				return false;
			else if(_evenOddSelection==OddTimesteps && timestep%2!=1)
				return false;
		}
		return true;
	}
	
	void SetFieldId(size_t fieldId)
	{ 
		_fieldId = fieldId; 
	}
	void SetBandId(size_t bandId)
	{
		_bandId = bandId;
	}
	void SetChannelRange(size_t startChannel, size_t endChannel)
	{
		_startChannel = startChannel;
		_endChannel = endChannel;
	}
	void SetNoChannelRange()
	{
		_startChannel = 0;
		_endChannel = 0;
	}
	void SetInterval(size_t startTimestep, size_t endTimestep)
	{
		_startTimestep = startTimestep;
		_endTimestep = endTimestep;
	}
	void SetMinUVWInM(double minUVW)
	{
		_minUVWInM = minUVW;
	}
	void SetMaxUVWInM(double maxUVW)
	{
		_maxUVWInM = maxUVW;
	}
	void SetEvenOrOddTimesteps(EvenOddSelection evenOrOdd)
	{
		_evenOddSelection = evenOrOdd;
	}
	static MSSelection Everything() { return MSSelection(); }
private:
	size_t _fieldId, _bandId;
	size_t _startChannel, _endChannel;
	size_t _startTimestep, _endTimestep;
	double _minUVWInM, _maxUVWInM;
	bool _autoCorrelations;
	enum EvenOddSelection _evenOddSelection;
};

#endif