Changeset 19555 for trunk/FACT++


Ignore:
Timestamp:
06/07/19 16:53:02 (6 years ago)
Author:
tbretz
Message:
Implemnted the possibility to setup individual conditions for individual type-IDs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/scheduler.cc

    r19530 r19555  
    2222// -----------------------------------------------------------------------
    2323
    24 /*
    25 void SetupConfiguration(Configuration &conf);
     24enum VisibilityCriterion
    2625{
    27     po::options_description control("Makeschedule");
    28     control.add_options()
    29         ("uri", var<string>(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
    30         ;
    31 
    32     // po::positional_options_description p;
    33     // p.add("date", 1); // The first positional options
    34 
    35     conf.AddOptions(control);
    36     //conf.SetArgumentPositions(p);
    37 }
    38 
    39 void PrintUsage();
     26    kMoonMin,
     27    kMoonMax,
     28    kSunMax,
     29    kZenithMax,
     30    kCurrentMax,
     31    kThresholdMax,
     32};
     33
     34struct VisibilityConditions : map<VisibilityCriterion, float>
    4035{
    41     cout <<
    42         "makeschedule - Creates an automatic schedule\n"
    43         "\n"
    44         "Usage: makeschedule [yyyy-mm-dd]\n";
    45     cout << endl;
    46 }
    47 
    48 void PrintHelp();
    49 {
    50     cout << endl;
    51 }*/
     36    VisibilityConditions()
     37    {
     38        operator[](kMoonMin)      =  10;
     39        operator[](kMoonMax)      = 170;
     40        operator[](kSunMax)       = -12;
     41        operator[](kZenithMax)    =  75;
     42        operator[](kCurrentMax)   = 110;
     43        operator[](kThresholdMax) =  10;
     44    }
     45};
    5246
    5347struct CheckVisibility
    5448{
    55     // Input
    56     float moon_min      =  10;
    57     float moon_max      = 170;
    58     float sun_max       = -12;
    59     float zd_max        =  75;
    60     float current_max   = 110;
    61     float threshold_max =  10;
     49    VisibilityConditions conditions;
    6250
    6351    // Output
     
    8573        moon_dist = Nova::GetAngularSeparation(equ, solarobj.fMoonEqu);
    8674        vis_sun   = Nova::GetSolarRst(jd, -12);
    87         vis_obj   = Nova::GetObjectRst(equ, jd, zd_max);
     75        vis_obj   = Nova::GetObjectRst(equ, jd, conditions[kZenithMax]);
    8876
    8977        current   = FACT::PredictI(solarobj, equ);
     
    9381        threshold = position.zd<90 ? ratio*pow(current/6.2, 0.394) : -1;
    9482
    95         valid_moon      = moon_dist>moon_min && moon_dist<moon_max;
    96         valid_zd        = position.zd<zd_max;
    97         valid_sun       = solarobj.fSunHrz.alt<sun_max;
    98         valid_current   = current<current_max;
    99         valid_threshold = threshold>0 && threshold<threshold_max;
     83        valid_moon      = moon_dist>conditions[kMoonMin] && moon_dist<conditions[kMoonMax];
     84        valid_zd        = position.zd<conditions[kZenithMax];
     85        valid_sun       = solarobj.fSunHrz.alt<conditions[kSunMax];
     86        valid_current   = current<conditions[kCurrentMax];
     87        valid_threshold = threshold>0 && threshold<conditions[kThresholdMax];
    10088
    10189        visible = valid_moon && valid_zd && valid_sun && valid_current;
    10290    }
    10391
    104     CheckVisibility(const Nova::EquPosn &equ, const double &jd)
     92    CheckVisibility(const VisibilityConditions &cond, const Nova::EquPosn &equ, const double &jd) : conditions(cond)
    10593    {
    10694        calc(equ, jd);
    10795    }
    10896
    109     CheckVisibility(const Nova::EquPosn &equ)
     97    CheckVisibility(const VisibilityConditions &cond, const Nova::EquPosn &equ) : conditions(cond)
    11098    {
    11199        calc(equ, Time().JD());
    112100    }
    113101
    114     CheckVisibility(const double &ra, const double &dec, const double &jd)
     102    CheckVisibility(const VisibilityConditions &cond, const double &ra, const double &dec, const double &jd): conditions(cond)
    115103    {
    116104        Nova::EquPosn equ;
     
    120108    }
    121109
    122     CheckVisibility(const double &ra, const double &dec)
     110    CheckVisibility(const VisibilityConditions &cond, const double &ra, const double &dec) : conditions(cond)
    123111    {
    124112        Nova::EquPosn equ;
     
    423411{
    424412private:
     413    map<uint16_t, VisibilityConditions> fVisibilityCriteria;
     414
    425415    string   fUri;
    426416    Database fConnection;
     
    684674            const bool prio = prioritized_sources.find(source.key)!=prioritized_sources.end();
    685675
    686             if ((check.threshold>3 && !prio) || check.threshold>10)
     676            // Special check for the threshold. Threshold condition atm only
     677            // applies for pointings and is different for prioritized sources
     678            if ((check.threshold>3 && !prio) || !check.valid_threshold)
    687679            {
    688                 Warn("Relative threshold too high... skipping.");
     680                Warn(Tools::Form("Relative threshold [%6.2f] too high... skipping.", check.threshold));
    689681                return false;
    690682            }
     
    11011093
    11021094        ostringstream out;
    1103         out << name << " [" << paket.name << ":" << grb.type << "]: RA=" << grb.ra/15. << "h DEC=" << grb.dec << "\u00b0 ERR=" << grb.err;
     1095        out << name << " [" << paket.name << ":" << grb.type << "]: RA=" << grb.ra/15. << "h DEC=" << grb.dec << "\u00b0 ERR=" << grb.err << "\u00b0";
    11041096
    11051097        Info(out);
    11061098        Info(paket.description);
    11071099
    1108         const CheckVisibility check(grb.ra, grb.dec);
    1109 
    1110         Info(string("Sun altitude:   ")+(check.valid_sun      ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.solarobj.fSunHrz.alt)+"\u00b0]");
     1100        // The []-operator automatically creates a default entry if not yet existing
     1101        auto &conditions = fVisibilityCriteria[grb.type];
     1102
     1103        const CheckVisibility check(conditions, grb.ra, grb.dec);
     1104
     1105        Info("Sun altitude:  "+Tools::Form("%5.1f\u00b0 ", check.solarobj.fSunHrz.alt)+(check.valid_sun?"OK    ":"failed")+Tools::Form(" [alt < %5.1f\u00b0]", conditions[kSunMax]));
    11111106        if (check.valid_sun)
    11121107        {
    1113             Info(string("Moon distance:  ")+(check.valid_moon     ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.moon_dist)+"\u00b0]");
    1114             Info(string("Zenith angle:   ")+(check.valid_zd       ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.position.zd)+"\u00b0]");
    1115             Info(string("Current:        ")+(check.valid_current  ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.current)+" \u00b5A]");
     1108            Info("Moon distance: "+Tools::Form("%5.1f\u00b0 ", check.moon_dist)  +(check.valid_moon   ?"OK    ":"failed")+Tools::Form(" [%5.1f\u00b0 < d < %5.1f\u00b0]", conditions[kMoonMin], conditions[kMoonMax]));
     1109            Info("Zenith angle:  "+Tools::Form("%5.1f\u00b0 ", check.position.zd)+(check.valid_zd     ?"OK    ":"failed")+Tools::Form(" [zd < %5.1f\u00b0]", conditions[kZenithMax]));
     1110            Info("Current:       "+Tools::Form("%5.1f\u00b5A", check.current)    +(check.valid_current?"OK    ":"failed")+Tools::Form(" [I < %5.1f\u00b5A]", conditions[kCurrentMax]));
    11161111            //Info(string("Rel. threshold: ")+(check.valid_threshold?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.threshold)+"]");
    11171112        }
     
    13311326    }*/
    13321327
     1328    void AddCriteria(const vector<uint16_t> &ids, const VisibilityCriterion &crit, const float &limit)
     1329    {
     1330        // The []-operator automatically creates a default entry if not yet existing
     1331        for (auto id=ids.begin(); id!=ids.end(); id++)
     1332            fVisibilityCriteria[*id][crit] = limit;
     1333    }
     1334
    13331335    int EvalOptions(Configuration &conf)
    13341336    {
     
    13361338        fKeepAliveInterval = conf.Get<uint16_t>("keep-alive");
    13371339        fUri = conf.Get<string>("schedule-database");
     1340
     1341        const vector<uint16_t> GRBs =
     1342        {
     1343            60, 61, 62, 97, 110, 111, 112, 115, 53, 54, 55, 56, 100, 101, 102
     1344        };
     1345
     1346        AddCriteria(GRBs, kCurrentMax, 30);
     1347        AddCriteria(GRBs, kZenithMax,  45);
     1348
    13381349        return -1;
    13391350    }
Note: See TracChangeset for help on using the changeset viewer.