Changeset 20040 for trunk/Mars/hawc
- Timestamp:
- 02/02/21 18:30:39 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/processing/drstemp.C
r20030 r20040 1 void drstemp 82(fits &file, double beg, double end)1 void drstemp(const char *fname, double beg=0, double end=100000) 2 2 { 3 fits file(fname); 4 5 //file.PrintColumns(); 6 //file.PrintKeys(); 7 3 8 UInt_t offset = file.GetUInt("MJDREF"); 4 9 if (beg < 30000) … … 10 15 file.SetPtrAddress("Time", &time); 11 16 12 float *temp = (float*)file.SetPtrAddress("temp"); 13 14 double avgmin = 0; 15 double avgmax = 0; 16 double rmsmin = 0; 17 double rmsmax = 0; 18 19 int cnt = 0; 20 21 double lastavgmin = -1; 22 double lastavgmax = -1; 23 double lastrmsmin = -1; 24 double lastrmsmax = -1; 25 26 double diff = -1; 27 28 while (file.GetNextRow()) 29 { 30 time += offset; 31 32 if (time>end) 33 break; 34 35 double mn = 0; 36 double mx = 0; 37 double rn = 0; 38 double rx = 0; 39 for (int i=1; i<=2; i++) 40 { 41 mn += temp[i]; 42 rn += temp[i]*temp[i]; 43 44 mx += temp[i+41]; 45 rx += temp[i+41]*temp[i+41]; 46 } 47 mn /= 40; 48 mx /= 40; 49 rn /= 40; 50 rx /= 40; 51 52 if (time<beg) 53 { 54 lastavgmin = mn; 55 lastavgmax = mx; 56 lastrmsmin = sqrt(rn-mn*mn); 57 lastrmsmax = sqrt(rx-mx*mx); 58 diff = beg-time; 59 continue; 60 } 61 62 avgmin += mn; 63 avgmax += mx; 64 65 rmsmin += sqrt(rn-mn*mn); 66 rmsmax += sqrt(rx-mx*mx); 67 68 cnt ++; 69 } 70 71 if (cnt==0) 72 { 73 if (diff<5./24/3600) 74 return; 75 76 cout << "result " << lastavgmin << ", " << lastavgmax << ", " << lastrmsmin << ", " << lastrmsmax << endl; 77 return; 78 } 79 80 avgmin /= cnt; 81 avgmax /= cnt; 82 rmsmin /= cnt; 83 rmsmax /= cnt; 84 85 cout << "result " << avgmin << ", " << avgmax << ", " << rmsmin << ", " << rmsmax << endl; 86 } 87 88 void drstemp160(fits &file, double beg, double end) 89 { 90 UInt_t offset = file.GetUInt("MJDREF"); 91 if (beg < 30000) 92 beg+=offset; 93 if (end < 30000) 94 end+=offset; 95 96 double time; 97 file.SetPtrAddress("Time", &time); 98 99 float *temp = (float*)file.SetPtrAddress("temp"); 17 float temp[160]; 18 file.SetPtrAddress("temp", temp, 160); 100 19 101 20 double avg = 0; … … 145 64 return; 146 65 147 cout << "result " << lastavg << ", " << last avg << ", " << lastrms << ", " << lastrms << endl;66 cout << "result " << lastavg << ", " << lastrms << endl; 148 67 return; 149 68 } … … 152 71 rms /= cnt; 153 72 154 cout << "result " << avg << ", " << avg << ", " << rms << ", " <<rms << ", " << endl;73 cout << "result " << avg << ", " << rms << ", " << endl; 155 74 } 156 157 void drstemp(const char *fname, double beg=0, double end=100000)158 {159 fits file(fname);160 161 //file.PrintColumns();162 //file.PrintKeys();163 164 float temp[160];165 // if (file.SetPtrAddress("temp", temp, 82))166 // {167 // drstemp82(file, beg, end);168 // return;169 // }170 171 file.SetPtrAddress("temp", temp, 160);172 drstemp160(file, beg, end);173 }
Note:
See TracChangeset
for help on using the changeset viewer.