Last change
on this file since 19690 was 15224, checked in by Daniela Dorner, 12 years ago |
added (macro to extract outside temperature from the file MAGIC_WEATHER_DATA)
|
File size:
1.1 KB
|
Line | |
---|
1 | void magictemp(const char *fname, double beg=0, double end=100000)
|
---|
2 | {
|
---|
3 | fits file(fname);
|
---|
4 |
|
---|
5 | //file.PrintColumns();
|
---|
6 | //file.PrintKeys();
|
---|
7 |
|
---|
8 | Double_t time;
|
---|
9 | Float_t temp;
|
---|
10 | file.SetPtrAddress("Time", &time);
|
---|
11 | file.SetPtrAddress("T", &temp);
|
---|
12 |
|
---|
13 | UInt_t offset = file.GetUInt("MJDREF");
|
---|
14 | //cout << "offset: " << offset << endl;
|
---|
15 | if (beg < 30000)
|
---|
16 | beg+=offset;
|
---|
17 | if (end < 30000)
|
---|
18 | end+=offset;
|
---|
19 |
|
---|
20 | double avg = 0;
|
---|
21 | double rms = 0;
|
---|
22 | int cnt = 0;
|
---|
23 |
|
---|
24 | double last = -1;
|
---|
25 | double diff = -1;
|
---|
26 |
|
---|
27 | while (file.GetNextRow())
|
---|
28 | {
|
---|
29 | time += offset;
|
---|
30 | //cout << time << " " << temp << endl;
|
---|
31 |
|
---|
32 | if (time>end)
|
---|
33 | break;
|
---|
34 |
|
---|
35 | if (time<beg)
|
---|
36 | {
|
---|
37 | last = temp;
|
---|
38 | diff = beg-time;
|
---|
39 | continue;
|
---|
40 | }
|
---|
41 |
|
---|
42 | avg += temp;
|
---|
43 | rms += temp*temp;
|
---|
44 | cnt ++;
|
---|
45 | }
|
---|
46 |
|
---|
47 | if (cnt==0)
|
---|
48 | {
|
---|
49 | if (diff<5./24/3600)
|
---|
50 | return;
|
---|
51 |
|
---|
52 | cout << "result " << last << " 0 " << endl;
|
---|
53 | return;
|
---|
54 | }
|
---|
55 |
|
---|
56 | avg /= cnt;
|
---|
57 | rms /= cnt;
|
---|
58 |
|
---|
59 | rms = sqrt(rms-avg*avg);
|
---|
60 |
|
---|
61 | cout << "result " << avg << " " << rms << endl;
|
---|
62 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.