-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQDC.hpp
More file actions
157 lines (130 loc) · 4.37 KB
/
QDC.hpp
File metadata and controls
157 lines (130 loc) · 4.37 KB
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
#ifndef QDC_hpp
#define QDC_hpp
//#include <stdint.h>
#include <string>
#include <vector>
#include <fstream>
#include "EMApplication.hpp"
using namespace std;
using namespace EM;
#include "QDComp.hpp"
// Documentation
class QDCInit;
class QDC : public EMApplication {
friend class QDCInit;
public:
const char* name() {return "QDC";}
const char* author() {return "Peter Crosthwaite; for INTERMAGNET http:://www.intermagnet.org";}
const char* copyright() {return "Geoscience Australia";}
unsigned versionMajor() {return 0;}
unsigned versionMinor() {return 1;}
unsigned versionRelease(){return 0;}
const char* about() { return
"QDC = Quasi Definitive Comparison; written for geomagnetic observatory data comparison.\n"
"\n"
"QDC reports statistics of the vector difference DataSetA-DataSetB.\n"
"\n"
"Each data set consists of 1 or more files specified as \"format:filename\".\n"
"DataSetA might be DEFINITIVE data and DataSetB might be QUASIDEFINITIVE data,\n"
"however they are only required to have the same recording interval (e.g. 1-minute).\n"
"The data sets must also have the same recorded elements (e.g. \"HDZ*\") unless they\n"
"are converted to \"XYZ\" using the --XYZ option.\n"
"\n"
"Recognised file formats are {iaga2002, iaf}.\n"
"Recognised recorded elements are {XYZ*, HDZ*}.\n"
"\n"
"There should be no data gaps (except those represented by MISSING data values).\n"
"\n"
"Other uses:\n"
"\tCompare preliminary data from two variometers at one station.\n"
"\tCompare definitive data from two nearby stations.\n"
"\tetc.\n"
"\n"
"Please report BUGS and modification requests to geomag@ga.gov.au\n"
;}
const char* example() { return
"QDC -a iaf:cnb09dec.bin -b iaga2002:CNB200912010000pmin.min -b iaga2002:CNB200912020000pmin.min --ByDayByMonth --XYZ\n"
"\n"
"\tConvert the data to XYZ, and report the Monthly statistics of the Daily averages.\n"
"\tAll days with any amount of data are used. NO \"90%\" RULE IS APPLIED, nor is any other rule.\n"
"\n"
"QDC -FF -EQDC\n"
"\twhere a text file named F contains\n"
"\t\tdsa=iaf:cnb09dec.bin\n"
"\t\tdsb=iaga2002:CNB200912010000pmin.min\n"
"\t\tdsb=iaga2002:CNB200912020000pmin.min\n"
"\t\tXYZ=true\n"
"\tand where an environment variable is set as follows\n"
"\t\tset QDCByDayByMonth=true\n"
"\n"
"\tSame as previous example.\n"
"\n"
"QDC -a iaf:cnb09jan.bin -b iaga2002:CNB200901010000pmin.min --ByDayByMonthbyYear \n"
"\n"
"\tReport the Yearly statistics of the Monthly average of the Daily averages.\n"
"\tAll months with any amount of data are used, as are all days with any amount of data.\n"
"\tNO \"90%\" RULE IS APPLIED, nor is any other rule.\n"
;}
QDC();
virtual ~QDC();
int main();
class DataSource {
public:
DataSource(const string& n){
size_t colon=n.find(':');
if (colon==string::npos) {
format="";
name=n;
} else {
format=n.substr(0,colon);
name=n.substr(colon+1,string::npos);
}
s = new(ifstream);
s->open(name.c_str(),ios_base::in);
}
DataSource(){}
void connect(){s->open(name.c_str(),ios_base::in|ios_base::binary);}
void disconnect(){s->close();}
SingleSource* extract();
bool operator!(){return !(*s);}
string format;
string name;
ifstream *s;
class Hints {
public:
Hints(Data::Format f=Data::Unknown, size_t sz=0, TimeInterval t=TimeInterval(0,0,0,0,1,0)):fmt(f),n(sz),interval(t){}
Data::Format fmt;
size_t n;
TimeInterval interval;
};
private:
Hints getHints(); // return information for creating SingleSource
};
private:
//ofstream _out;
vector<DataSource> _dsa;
vector<DataSource> _dsb;
bool _bRepByDayByAll;
bool _bRepByDayByMonthByAll;
bool _bRepByDayByMonthByYearByAll;
bool _bRepByDayByYearByAll;
bool _bRepByMonthByAll;
bool _bRepByMonthByYearByAll;
bool _bRepByYearByAll;
bool _bRepByDayByYear;
bool _bRepByDayByMonthByYear;
bool _bRepByMonthByYear;
bool _bRepByDayByMonth;
// and the 4 Basic accumulations of Raw data
bool _bRepByDay;
bool _bRepByMonth;
bool _bRepByYear;
bool _bRepByAll;
bool _bRepD;
bool _bRepM;
bool _bRepY;
bool _bRepA;
bool _bXYZ;
void extractDataFromSource(DataSource&s, MultiSource& m);
};
#endif