1 |
|
---|
2 |
|
---|
3 | void currents(const char *fname, double beg=0, double end=100000)
|
---|
4 | {
|
---|
5 | fits file(fname);
|
---|
6 |
|
---|
7 | //file.PrintColumns();
|
---|
8 | //file.PrintKeys();
|
---|
9 |
|
---|
10 | Double_t time;
|
---|
11 | Double_t jd;
|
---|
12 |
|
---|
13 | Float_t med, dev;
|
---|
14 | file.SetPtrAddress("Time", &time);
|
---|
15 | file.SetPtrAddress("I_med", &med);
|
---|
16 | file.SetPtrAddress("I_dev", &dev);
|
---|
17 |
|
---|
18 | UInt_t offset = file.GetUInt("MJDREF");
|
---|
19 | if (beg < 30000)
|
---|
20 | beg+=offset;
|
---|
21 | if (end < 30000)
|
---|
22 | end+=offset;
|
---|
23 |
|
---|
24 | double med_beg = 0;
|
---|
25 | double med_end = 0;
|
---|
26 | double med_avg = 0;
|
---|
27 | double med_rms = 0;
|
---|
28 | double dev_avg = 0;
|
---|
29 | double dev_rms = 0;
|
---|
30 | int cnt = 0;
|
---|
31 | int cnt_beg = 0;
|
---|
32 | int cnt_end = 0;
|
---|
33 |
|
---|
34 | double med_last = -1;
|
---|
35 | double dev_last = -1;
|
---|
36 | double diff = -1;
|
---|
37 |
|
---|
38 | double calc_dev_avg = 0;
|
---|
39 |
|
---|
40 | while (file.GetNextRow())
|
---|
41 | {
|
---|
42 | time += offset;
|
---|
43 | jd = time + 2400000.5;
|
---|
44 |
|
---|
45 | if (time>end)
|
---|
46 | break;
|
---|
47 |
|
---|
48 | if (time<beg)
|
---|
49 | {
|
---|
50 | med_last = med;
|
---|
51 | dev_last = dev;
|
---|
52 | diff = beg-time;
|
---|
53 | continue;
|
---|
54 | }
|
---|
55 |
|
---|
56 | med_avg += med;
|
---|
57 | med_rms += med*med;
|
---|
58 | dev_avg += dev;
|
---|
59 | dev_rms += dev*dev;
|
---|
60 |
|
---|
61 | if (time<beg+15./24/3600)
|
---|
62 | {
|
---|
63 | med_beg += med;
|
---|
64 | cnt_beg++;
|
---|
65 | }
|
---|
66 | if (time>end-15./24/3600)
|
---|
67 | {
|
---|
68 | med_end += med;
|
---|
69 | cnt_end++;
|
---|
70 | }
|
---|
71 |
|
---|
72 | //calculate the moon
|
---|
73 | Nova::EquPosn moon = Nova::GetLunarEquCoords(jd, 0.01);
|
---|
74 | // get local position of moon
|
---|
75 | Nova::HrzPosn hrzm = Nova::GetHrzFromEqu(moon, jd);
|
---|
76 |
|
---|
77 | //calculate the light condition
|
---|
78 | double calt = sin(hrzm.alt*TMath::DegToRad());
|
---|
79 | double disk = Nova::GetLunarDisk(jd);
|
---|
80 | double lc = calt*pow(disk, 2.5);
|
---|
81 |
|
---|
82 | double Ical = lc>0 ? 4.5+103.0*lc : 4.5;
|
---|
83 | calc_dev_avg += med - Ical;
|
---|
84 |
|
---|
85 | cnt++;
|
---|
86 | }
|
---|
87 |
|
---|
88 | if (cnt==0)
|
---|
89 | {
|
---|
90 | if (diff<5./24/3600)
|
---|
91 | return;
|
---|
92 |
|
---|
93 | cout << "result " << med_last << " 0 " << dev_last << " 0 0 0 0" << endl;
|
---|
94 | return;
|
---|
95 | }
|
---|
96 |
|
---|
97 | med_beg = cnt_beg>0 ? med_beg/cnt_beg : -1;
|
---|
98 | med_end = cnt_end>0 ? med_end/cnt_end : -1;
|
---|
99 |
|
---|
100 | med_avg /= cnt;
|
---|
101 | med_rms /= cnt;
|
---|
102 | med_rms = sqrt(med_rms-med_avg*med_avg);
|
---|
103 |
|
---|
104 | dev_avg /= cnt;
|
---|
105 | dev_rms /= cnt;
|
---|
106 | dev_rms = sqrt(dev_rms-dev_avg*dev_avg);
|
---|
107 | calc_dev_avg = calc_dev_avg / cnt;
|
---|
108 |
|
---|
109 | cout << "result " << med_avg << " " << med_rms << " " << dev_avg << " " << dev_rms << " " << med_beg << " " << med_end << " " << calc_dev_avg << endl;
|
---|
110 | }
|
---|