Changeset 18943 for trunk/Mars/fact/processing/magicweather.C
- Timestamp:
- 02/09/18 13:29:52 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/fact/processing/magicweather.C
r18942 r18943 1 void magic temp(const char *fname, double beg=0, double end=100000)1 void magicweather(const char *fname, double beg=0, double end=100000) 2 2 { 3 3 fits file(fname); … … 7 7 8 8 Double_t time; 9 Float_t temp; 10 file.SetPtrAddress("Time", &time); 11 file.SetPtrAddress("T", &temp); 9 Float_t temp, hum, pres, dew, wind, gust; 10 file.SetPtrAddress("Time", &time); 11 file.SetPtrAddress("T", &temp); 12 file.SetPtrAddress("H", &hum); 13 file.SetPtrAddress("P", &pres); 14 file.SetPtrAddress("T_dew", &dew); 15 file.SetPtrAddress("v", &wind); 16 file.SetPtrAddress("v_max", &gust); 12 17 13 18 UInt_t offset = file.GetUInt("MJDREF"); … … 18 23 end+=offset; 19 24 20 double avg = 0;21 double rms = 0;22 25 int cnt = 0; 26 double avg_t = 0; 27 double rms_t = 0; 28 double avg_h = 0; 29 double rms_h = 0; 30 double avg_p = 0; 31 double rms_p = 0; 32 double avg_d = 0; 33 double rms_d = 0; 34 double avg_w = 0; 35 double rms_w = 0; 36 double avg_g = 0; 37 double rms_g = 0; 23 38 24 double last = -1; 39 double last_t = -1; 40 double last_h = -1; 41 double last_p = -1; 42 double last_d = -1; 43 double last_w = -1; 44 double last_g = -1; 25 45 double diff = -1; 46 double diff2 = -1; 26 47 27 48 while (file.GetNextRow()) … … 31 52 32 53 if (time>end) 54 { 55 diff2 = time-end; 56 if (diff2<diff) 57 { 58 last_t = temp; 59 last_h = hum; 60 last_p = pres; 61 last_d = dew; 62 last_w = wind; 63 last_g = gust; 64 diff=diff2; 65 } 33 66 break; 67 } 34 68 35 69 if (time<beg) 36 70 { 37 last = temp; 71 last_t = temp; 72 last_h = hum; 73 last_p = pres; 74 last_d = dew; 75 last_w = wind; 76 last_g = gust; 38 77 diff = beg-time; 39 78 continue; 40 79 } 41 80 42 avg += temp; 43 rms += temp*temp; 81 avg_t += temp; 82 rms_t += temp*temp; 83 avg_h += hum; 84 rms_h += hum*hum; 85 avg_p += pres; 86 rms_p += pres*pres; 87 avg_d += dew; 88 rms_d += dew*dew; 89 avg_w += wind; 90 rms_w += wind*wind; 91 avg_g += gust; 92 rms_g += gust*gust; 44 93 cnt ++; 45 94 } … … 47 96 if (cnt==0) 48 97 { 49 if (diff <5./24/3600)98 if (diff>5./24/3600) 50 99 return; 51 100 52 cout << "result " << last << " 0 " << endl; 101 //only give output if values within 5 min before/after are available 102 cout << "result " << last_t << " 0 " << last_h << " 0 " 103 << last_p << " 0 " << last_d << " 0 " 104 << last_w << " 0 " << last_g << " 0 " << endl; 53 105 return; 54 106 } 55 107 56 avg /= cnt; 57 rms /= cnt; 108 avg_t /= cnt; 109 rms_t /= cnt; 110 avg_h /= cnt; 111 rms_h /= cnt; 112 avg_p /= cnt; 113 rms_p /= cnt; 114 avg_d /= cnt; 115 rms_d /= cnt; 116 avg_w /= cnt; 117 rms_w /= cnt; 118 avg_g /= cnt; 119 rms_g /= cnt; 58 120 59 rms = sqrt(rms-avg*avg); 121 rms_t = sqrt(rms_t-avg_t*avg_t); 122 rms_h = sqrt(rms_h-avg_h*avg_h); 123 rms_p = sqrt(rms_p-avg_p*avg_p); 124 rms_d = sqrt(rms_d-avg_d*avg_d); 125 rms_w = sqrt(rms_w-avg_w*avg_w); 126 rms_g = sqrt(rms_g-avg_g*avg_g); 60 127 61 cout << "result " << avg << " " << rms << endl; 128 cout << "result " << avg_t << " " << rms_t << " " << avg_h << " " << rms_h << " " 129 << avg_p << " " << rms_p << " " << avg_d << " " << rms_d << " " 130 << avg_w << " " << rms_w << " " << avg_g << " " << rms_g << " " << endl; 62 131 }
Note:
See TracChangeset
for help on using the changeset viewer.