Changeset 19555 for trunk/FACT++
- Timestamp:
- 06/07/19 16:53:02 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/scheduler.cc
r19530 r19555 22 22 // ----------------------------------------------------------------------- 23 23 24 /* 25 void SetupConfiguration(Configuration &conf); 24 enum VisibilityCriterion 26 25 { 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 34 struct VisibilityConditions : map<VisibilityCriterion, float> 40 35 { 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 }; 52 46 53 47 struct CheckVisibility 54 48 { 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; 62 50 63 51 // Output … … 85 73 moon_dist = Nova::GetAngularSeparation(equ, solarobj.fMoonEqu); 86 74 vis_sun = Nova::GetSolarRst(jd, -12); 87 vis_obj = Nova::GetObjectRst(equ, jd, zd_max);75 vis_obj = Nova::GetObjectRst(equ, jd, conditions[kZenithMax]); 88 76 89 77 current = FACT::PredictI(solarobj, equ); … … 93 81 threshold = position.zd<90 ? ratio*pow(current/6.2, 0.394) : -1; 94 82 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<c urrent_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]; 100 88 101 89 visible = valid_moon && valid_zd && valid_sun && valid_current; 102 90 } 103 91 104 CheckVisibility(const Nova::EquPosn &equ, const double &jd)92 CheckVisibility(const VisibilityConditions &cond, const Nova::EquPosn &equ, const double &jd) : conditions(cond) 105 93 { 106 94 calc(equ, jd); 107 95 } 108 96 109 CheckVisibility(const Nova::EquPosn &equ)97 CheckVisibility(const VisibilityConditions &cond, const Nova::EquPosn &equ) : conditions(cond) 110 98 { 111 99 calc(equ, Time().JD()); 112 100 } 113 101 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) 115 103 { 116 104 Nova::EquPosn equ; … … 120 108 } 121 109 122 CheckVisibility(const double &ra, const double &dec)110 CheckVisibility(const VisibilityConditions &cond, const double &ra, const double &dec) : conditions(cond) 123 111 { 124 112 Nova::EquPosn equ; … … 423 411 { 424 412 private: 413 map<uint16_t, VisibilityConditions> fVisibilityCriteria; 414 425 415 string fUri; 426 416 Database fConnection; … … 684 674 const bool prio = prioritized_sources.find(source.key)!=prioritized_sources.end(); 685 675 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) 687 679 { 688 Warn( "Relative threshold too high... skipping.");680 Warn(Tools::Form("Relative threshold [%6.2f] too high... skipping.", check.threshold)); 689 681 return false; 690 682 } … … 1101 1093 1102 1094 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"; 1104 1096 1105 1097 Info(out); 1106 1098 Info(paket.description); 1107 1099 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])); 1111 1106 if (check.valid_sun) 1112 1107 { 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])); 1116 1111 //Info(string("Rel. threshold: ")+(check.valid_threshold?"OK ":"failed")+" ["+Tools::Form("%5.1f", check.threshold)+"]"); 1117 1112 } … … 1331 1326 }*/ 1332 1327 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 1333 1335 int EvalOptions(Configuration &conf) 1334 1336 { … … 1336 1338 fKeepAliveInterval = conf.Get<uint16_t>("keep-alive"); 1337 1339 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 1338 1349 return -1; 1339 1350 }
Note:
See TracChangeset
for help on using the changeset viewer.