File: options.h

package info (click to toggle)
aoflagger 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 4,476 kB
  • sloc: cpp: 51,868; python: 152; sh: 25; makefile: 17
file content (178 lines) | stat: -rw-r--r-- 4,846 bytes parent folder | download
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#ifndef OPTIONS_H
#define OPTIONS_H

#include <boost/optional/optional.hpp>

#include "../structures/types.h"

#include "../util/logger.h"

#include <set>
#include <string>
#include <vector>

enum class BaselineSelection
{
	All, CrossCorrelations, AutoCorrelations, EqualToCurrent, AutoCorrelationsOfCurrentAntennae, Current
};

struct BaselineIntegration
{
	enum Mode {
		Count, Average, AverageAbs, Squared, Stddev
	};
	enum Differencing { NoDifference, TimeDifference, FrequencyDifference };
	
	boost::optional<bool> enable, withAutos, withFlagged;
	boost::optional<Mode> mode;
	boost::optional<Differencing> differencing;
	
	/**
	 * All options that are set in @ref other will override the settings
	 * in this.
	 */
	void Override(const BaselineIntegration& other)
	{
		if(other.enable)
			enable = other.enable;
		if(other.withAutos)
			withAutos = other.withAutos;
		if(other.withFlagged)
			withFlagged = other.withFlagged;
		if(other.mode)
			mode = other.mode;
		if(other.differencing)
			differencing = other.differencing;
	}
	
	bool operator==(const BaselineIntegration& other) const
	{
		return
			enable==other.enable &&
			withAutos==other.withAutos &&
			withFlagged==other.withFlagged &&
			mode==other.mode &&
			differencing==other.differencing;
	}
};

struct Options
{
	std::set<size_t> antennaeToInclude, antennaeToSkip;
	std::set<size_t> bands;
	boost::optional<BaselineSelection> baselineSelection;
	BaselineIntegration baselineIntegration;
	size_t chunkSize;
	boost::optional<bool> combineSPWs;
	std::string dataColumn;
	std::string executeFilename;
	std::string executeFunctionName;
	std::set<size_t> fields;
	boost::optional<BaselineIOMode> readMode;
	boost::optional<bool> readUVW;
	std::string scriptVersion;
	boost::optional<bool> skipFlagged;
	boost::optional<size_t> startTimestep, endTimestep;
	std::string strategyFilename;
	size_t threadCount;
	boost::optional<Logger::VerbosityLevel> logVerbosity;
	
	std::vector<std::string> preamble;
	std::string commandLine;
	std::vector<std::string> filenames;
	
	Options() :
		chunkSize(0),
		threadCount(0)
	{ }
	
	/**
	 * All options that are set in @ref other will override the settings
	 * in this.
	 */
	void Override(const Options& other)
	{
		if(!other.antennaeToInclude.empty())
			antennaeToInclude = other.antennaeToInclude;
		if(!other.antennaeToSkip.empty())
			antennaeToSkip = other.antennaeToSkip;
		if(!other.bands.empty())
			bands = other.bands;
		baselineIntegration.Override(other.baselineIntegration);
		if(other.baselineSelection)
			baselineSelection = other.baselineSelection;
		if(other.chunkSize)
			chunkSize = other.chunkSize;
		if(other.combineSPWs)
			combineSPWs = other.combineSPWs;
		if(!other.dataColumn.empty())
			dataColumn = other.dataColumn;
		if(!other.executeFilename.empty())
			executeFilename = other.executeFilename;
		if(!other.executeFunctionName.empty())
			executeFunctionName = other.executeFunctionName;
		if(!other.fields.empty())
			fields = other.fields;
		if(other.readMode)
			readMode = other.readMode;
		if(other.readUVW)
			readUVW = other.readUVW;
		if(!other.scriptVersion.empty())
			scriptVersion = other.scriptVersion;
		if(other.skipFlagged)
			skipFlagged = other.skipFlagged;
		if(other.startTimestep)
			startTimestep = other.startTimestep;
		if(other.endTimestep)
			endTimestep = other.endTimestep;
		if(!other.strategyFilename.empty())
			strategyFilename = other.strategyFilename;
		if(other.threadCount)
			threadCount = other.threadCount;
		if(other.logVerbosity)
			logVerbosity = other.logVerbosity;
		
		preamble.insert(preamble.begin(), other.preamble.begin(), other.preamble.end());
		if(!other.commandLine.empty())
			commandLine = other.commandLine;
		if(!other.filenames.empty())
			filenames = other.filenames;
	}
	
	bool operator==(const Options& rhs) const
	{
		return
			antennaeToInclude == rhs.antennaeToInclude &&
			antennaeToSkip == rhs.antennaeToSkip &&
			bands == rhs.bands &&
			baselineIntegration == rhs.baselineIntegration &&
			baselineSelection == rhs.baselineSelection &&
			chunkSize == rhs.chunkSize &&
			combineSPWs == rhs.combineSPWs &&
			dataColumn == rhs.dataColumn &&
			executeFilename == rhs.executeFilename &&
			executeFunctionName == rhs.executeFunctionName &&
			fields == rhs.fields &&
			readMode == rhs.readMode &&
			readUVW == rhs.readUVW &&
			scriptVersion == rhs.scriptVersion &&
			skipFlagged == rhs.skipFlagged &&
			startTimestep == rhs.startTimestep &&
			endTimestep == rhs.endTimestep &&
			strategyFilename == rhs.strategyFilename &&
			threadCount == rhs.threadCount &&
			logVerbosity == rhs.logVerbosity &&
			preamble == rhs.preamble &&
			commandLine == rhs.commandLine &&
			filenames == rhs.filenames;
	}
	
	bool operator!=(const Options& rhs) const
	{
		return !(*this == rhs);
	}
	
	size_t CalculateThreadCount() const;
};

#endif