Line | |
---|
1 | void drstemp(const char *fname, double beg=0, double end=100000)
|
---|
2 | {
|
---|
3 | fits file(fname);
|
---|
4 |
|
---|
5 | //file.PrintColumns();
|
---|
6 | //file.PrintKeys();
|
---|
7 |
|
---|
8 | UInt_t offset = file.GetUInt("MJDREF");
|
---|
9 | if (beg < 30000)
|
---|
10 | beg+=offset;
|
---|
11 | if (end < 30000)
|
---|
12 | end+=offset;
|
---|
13 |
|
---|
14 | double time;
|
---|
15 | file.SetPtrAddress("Time", &time);
|
---|
16 |
|
---|
17 | float temp[160];
|
---|
18 | file.SetPtrAddress("temp", temp, 160);
|
---|
19 |
|
---|
20 | double avg = 0;
|
---|
21 | double rms = 0;
|
---|
22 |
|
---|
23 | int cnt = 0;
|
---|
24 |
|
---|
25 | double lastavg = -1;
|
---|
26 | double lastrms = -1;
|
---|
27 |
|
---|
28 | double diff = -1;
|
---|
29 |
|
---|
30 | while (file.GetNextRow())
|
---|
31 | {
|
---|
32 | time += offset;
|
---|
33 |
|
---|
34 | if (time>end)
|
---|
35 | break;
|
---|
36 |
|
---|
37 | double mn = 0;
|
---|
38 | double rn = 0;
|
---|
39 | for (int i=0; i<=7; i++)
|
---|
40 | {
|
---|
41 | mn += temp[i];
|
---|
42 | rn += temp[i]*temp[i];
|
---|
43 | }
|
---|
44 | mn /= 8;
|
---|
45 | rn /= 8;
|
---|
46 |
|
---|
47 | if (time<beg)
|
---|
48 | {
|
---|
49 | lastavg = mn;
|
---|
50 | lastrms = sqrt(rn-mn*mn);
|
---|
51 | diff = beg-time;
|
---|
52 | continue;
|
---|
53 | }
|
---|
54 |
|
---|
55 | avg += mn;
|
---|
56 | rms += sqrt(rn-mn*mn);
|
---|
57 |
|
---|
58 | cnt ++;
|
---|
59 | }
|
---|
60 |
|
---|
61 | if (cnt==0)
|
---|
62 | {
|
---|
63 | if (diff<5./24/3600)
|
---|
64 | return;
|
---|
65 |
|
---|
66 | cout << "result " << lastavg << ", " << lastrms << endl;
|
---|
67 | return;
|
---|
68 | }
|
---|
69 |
|
---|
70 | avg /= cnt;
|
---|
71 | rms /= cnt;
|
---|
72 |
|
---|
73 | cout << "result " << avg << ", " << rms << endl;
|
---|
74 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.