Changeset 18943 for trunk/Mars/fact


Ignore:
Timestamp:
02/09/18 13:29:52 (7 years ago)
Author:
Daniela Dorner
Message:
added more values and fixed bug with diff
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/fact/processing/magicweather.C

    r18942 r18943  
    1 void magictemp(const char *fname, double beg=0, double end=100000)
     1void magicweather(const char *fname, double beg=0, double end=100000)
    22{
    33    fits file(fname);
     
    77
    88    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);
    1217
    1318    UInt_t offset = file.GetUInt("MJDREF");
     
    1823        end+=offset;
    1924
    20     double avg  = 0;
    21     double rms  = 0;
    2225    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;
    2338
    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;
    2545    double diff = -1;
     46    double diff2 = -1;
    2647
    2748    while (file.GetNextRow())
     
    3152
    3253        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            }
    3366            break;
     67        }
    3468
    3569        if (time<beg)
    3670        {
    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;
    3877            diff = beg-time;
    3978            continue;
    4079        }
    4180
    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;
    4493        cnt ++;
    4594    }
     
    4796    if (cnt==0)
    4897    {
    49         if (diff<5./24/3600)
     98        if (diff>5./24/3600)
    5099            return;
    51100
    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;
    53105        return;
    54106    }
    55107
    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;
    58120
    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);
    60127
    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;
    62131}
Note: See TracChangeset for help on using the changeset viewer.