File: msinfo.cpp

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 (140 lines) | stat: -rw-r--r-- 4,436 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
137
138
139
140
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <vector>

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

#include "structures/measurementset.h"
#include "structures/antennainfo.h"

#include "strategy/algorithms/thresholdtools.h"

using namespace std;

std::string BoolToStr(bool val)
{
	if(val)
		return "true";
	else
		return "false";
}

int main(int argc, char *argv[])
{
	if(argc < 2) {
		cout << "This program will provide you general information about a measurement set.\nUsage:\n\t" << argv[0] << " [options] <measurement set>\n"
		     << endl;
		exit(-1);
	}

#ifdef HAS_LOFARSTMAN
	register_lofarstman();
#endif // HAS_LOFARSTMAN

	//bool saveFlagLength = false;
	//string flagLengthFile;
	bool antennaeList = false;
	int pindex = 1;
	while(pindex < argc && argv[pindex][0] == '-') {
		string parameter = argv[pindex]+1;
		if(parameter == "antennae")
		{
			antennaeList = true;
		} else
		/*if(parameter == "flaglength") {
			saveFlagLength = true;
			flagLengthFile = argv[pindex+1];
			++pindex;
		} else*/
		{
			cerr << "Bad parameter: -" << parameter << endl;
			exit(-1);
		}
		++pindex;
	}
	
	string measurementFile = argv[pindex];
	if(antennaeList)
	{
		MeasurementSet set(measurementFile);
		const size_t antennaCount = set.AntennaCount();
		for(size_t i=0;i<antennaCount;++i)
		{
			cout.width(16);
			cout.precision(16);
			const AntennaInfo antenna = set.GetAntennaInfo(i);
			cout << antenna.id << '\t' << antenna.position.Latitude()*180.0/M_PI << '\t' << antenna.position.Longitude()*180.0/M_PI << '\t' << antenna.position.Altitude() << '\n';
		}
	}
	else {
		cout << "Opening measurementset " << measurementFile << endl; 
		MeasurementSet set(measurementFile);
		size_t antennaCount = set.AntennaCount();
		cout
			<< "Telescope name: " << set.TelescopeName() << '\n'
			<< "Number of antennea: " << antennaCount << '\n'
			<< "Number of time scans: " << set.TimestepCount() << '\n'
			<< "Number of channels/band: " << set.FrequencyCount(0) << '\n'
			<< "Number of fields: " << set.FieldCount() << '\n'
			<< "Number of bands: " << set.BandCount() << '\n';
		casacore::Table *table = new casacore::MeasurementSet(set.Path());
		cout << "Has DATA column: " << BoolToStr(table->tableDesc().isColumn("DATA")) << "\n";
		cout << "Has CORRECTED_DATA column: " << BoolToStr(table->tableDesc().isColumn("CORRECTED_DATA")) << "\n";
		cout << "Has MODEL_DATA column: " << BoolToStr(table->tableDesc().isColumn("MODEL_DATA")) << "\n";
		delete table;
		std::vector<long double> baselines;
		for(size_t i=0;i<antennaCount;++i)
		{
			cout << "==Antenna " << i << "==\n";
			AntennaInfo info = set.GetAntennaInfo(i);
			cout <<
				"Diameter: " << info.diameter << "\n"
				"Name: " << info.name << "\n"
				"Position: " << info.position.ToString() << "\n"
				"Mount: " << info.mount << "\n"
				"Station: " << info.station << "\n"
				"Providing baselines: ";
			for(size_t j=0;j<antennaCount;++j) {
				AntennaInfo info2 = set.GetAntennaInfo(j);
				Baseline b(info.position, info2.position);
				long double dist = b.Distance();
				long double angle = b.Angle() * 180.0 / M_PIn;
				cout << dist << "m/" << angle << "` ";
				baselines.push_back(dist);
			}
			cout << "\n" << endl;
		}
		sort(baselines.begin(), baselines.end());
		cout << "All provided baselines: ";
		unsigned i=0;
		while(i<baselines.size()-1) {
			if(baselines[i+1]-baselines[i] < 1.0)
				baselines.erase(baselines.begin() + i);
			else
				++i;
		}
		for(vector<long double>::const_iterator i=baselines.begin();i!=baselines.end();++i)
			cout << (*i) << " ";
		cout << endl;

		for(unsigned i=0;i!=set.BandCount();++i) {
			cout << "== Spectral band index " << i << " ==" << endl;
			BandInfo bandInfo = set.GetBandInfo(i);
			cout << "Channel count: " << bandInfo.channels.size() << std::endl;
			cout << "Channels: ";
			for(unsigned j=0;j<bandInfo.channels.size();++j) {
				if(j > 0) cout << ", ";
				cout << round(bandInfo.channels[j].frequencyHz/1000000) << "MHz";
			}
			cout << endl;
		}
		
		for(unsigned i=0;i<set.FieldCount();++i) {
			FieldInfo fieldInfo = set.GetFieldInfo(i);
			cout << "Field " << i << ":\n\tdelay direction=" << fieldInfo.delayDirectionDec << " dec, " << fieldInfo.delayDirectionRA << "ra.\n\tdelay direction (in degrees)=" << (fieldInfo.delayDirectionDec/M_PIn*180.0L) << " dec," << (fieldInfo.delayDirectionRA/M_PIn*180.0L) << " ra." << endl;
		}

		return EXIT_SUCCESS;
	}
}