File: weightmode.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 (77 lines) | stat: -rw-r--r-- 2,004 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
#ifndef WEIGHTMODE_H
#define WEIGHTMODE_H

#include <string>
#include <sstream>

class WeightMode
{
public:
	enum WeightingEnum { NaturalWeighted, UniformWeighted, BriggsWeighted };
		
	explicit WeightMode(WeightingEnum mode) : _mode(mode), _briggsRobustness(0.0), _superWeight(1.0)
	{ }
	
	WeightMode(const WeightMode& source)
	: _mode(source._mode), _briggsRobustness(source._briggsRobustness), _superWeight(source._superWeight)
	{ }
	
	WeightMode& operator=(const WeightMode& source)
	{
		_mode = source._mode;
		_briggsRobustness = source._briggsRobustness;
		_superWeight = source._superWeight;
		return *this;
	}
	
	bool operator==(const WeightMode& rhs)
	{
		if(_mode != rhs._mode || _superWeight != rhs._superWeight)
			return false;
		else if(_mode == BriggsWeighted)
			return _briggsRobustness == rhs._briggsRobustness;
		else
			return true;
	}
	
	static WeightMode Briggs(double briggsRobustness)
	{
		WeightMode m(BriggsWeighted);
		m._briggsRobustness = briggsRobustness;
		return m;
	}
	
	WeightingEnum Mode() const { return _mode; }
	bool IsNatural() const { return _mode == NaturalWeighted; }
	bool IsUniform() const { return _mode == UniformWeighted; }
	bool IsBriggs() const { return _mode == BriggsWeighted; }
	
	double BriggsRobustness() const { return _briggsRobustness; }
	double SuperWeight() const { return _superWeight; }
	
	void SetSuperWeight(double superWeight) { _superWeight = superWeight; }
	void SetMode(const WeightMode& mode) { _mode = mode._mode; _briggsRobustness = mode._briggsRobustness; }
	
	bool RequiresGridding() const { return true; } // { IsUniform() || IsBriggs(); }
	
	std::string ToString() const 
	{
		switch(_mode)
		{
			case UniformWeighted: return "uniform";
			case NaturalWeighted: return "natural";
			case BriggsWeighted:
			{
				std::ostringstream s;
				s << "Briggs'(" << _briggsRobustness << ")";
				return s.str();
			}
			default: return "?";
		}
	}
private:
	enum WeightingEnum _mode;
	double _briggsRobustness, _superWeight;
};

#endif