21 if (g.GetN()==0 || axis-g.GetX()[g.GetN()-1]<450)
25 ((TGraph*)g.DrawClone(
"C"))->SetBit(kCanDelete);
36 ((TGraph*)g.DrawClone(
"C"))->SetBit(kCanDelete);
45 po::options_description control(
"Makeplots");
49 (
"date-time", var<string>(),
"SQL time (UTC)")
50 (
"source-database", var<string>(
""),
"Database link as in\n\tuser:password@server[:port]/database.")
51 (
"max-current", var<double>(100),
"Maximum current to display in other plots.")
52 (
"max-zd", var<double>(50),
"Maximum zenith distance to display in other plots")
53 (
"no-limits",
po_switch(),
"Switch off limits in plots")
56 po::positional_options_description p;
57 p.add(
"date-time", 1);
66 "makeplots - The astronomy plotter\n" 68 "Calculates several plots for the sources in the database\n" 69 "helpful or needed for scheduling. The Plot is always calculated\n" 70 "for the night which starts at the same so. So no matter if\n" 71 "you specify '1974-09-09 00:00:00' or '1974-09-09 21:56:00'\n" 72 "the plots will refer to the night 1974-09-09/1974-09-10.\n" 73 "The advantage is that specification of the date as in\n" 74 "1974-09-09 is enough. Time axis starts and ends at nautical\n" 75 "twilight which is 12deg below horizon.\n" 77 "Usage: makeplots sql-datetime\n";
82 int main(
int argc,
const char* argv[])
102 if (conf.
Has(
"date-time"))
105 const double max_current = conf.
Get<
double>(
"max-current");
106 const double max_zd = conf.
Get<
double>(
"max-zd");
107 const double no_limits = conf.
Get<
bool>(
"no-limits");
115 const double jd = floor(time.
Mjd())+2400001;
117 cout <<
"Time: " << time << endl;
118 cout <<
"Base: " <<
Time(jd-0.5) << endl;
119 cout <<
"Set: " <<
Time(sun_set.set) << endl;
120 cout <<
"Rise: " <<
Time(sun_rise.rise) << endl;
122 const double sunset = sun_set.set;
123 const double sunrise = sun_rise.rise;
125 const string fDatabase = conf.
Get<
string>(
"source-database");
129 const mysqlpp::StoreQueryResult res =
130 Database(fDatabase).query(
"SELECT fSourceName, fRightAscension, fDeclination FROM Source WHERE fSourceTypeKEY=1").store();
137 TH1S hframe(
"",
"", 1,
Time(sunset).Mjd()*24*3600,
Time(sunrise).Mjd()*24*3600);
138 hframe.SetStats(kFALSE);
139 hframe.GetXaxis()->SetTimeFormat(
"%Hh%M%F1995-01-01 00:00:00 GMT");
140 hframe.GetXaxis()->SetTitle((
Time(jd).GetAsStr(
"%d/%m/%Y")+
" - "+
Time(jd+1).GetAsStr(
"%d/%m/%Y")+
" [UTC]").c_str());
141 hframe.GetXaxis()->CenterTitle();
142 hframe.GetYaxis()->CenterTitle();
143 hframe.GetXaxis()->SetTimeDisplay(
true);
144 hframe.GetYaxis()->SetTitleSize(0.040);
145 hframe.GetXaxis()->SetTitleSize(0.040);
146 hframe.GetXaxis()->SetTitleOffset(1.1);
147 hframe.GetYaxis()->SetLabelSize(0.040);
148 hframe.GetXaxis()->SetLabelSize(0.040);
153 c1.SetFrameBorderMode(0);
154 c1.SetLeftMargin(0.085);
155 c1.SetRightMargin(0.01);
156 c1.SetTopMargin(0.03);
158 hframe.GetYaxis()->SetTitle(
"Altitude [deg]");
159 hframe.SetMinimum(15);
160 hframe.SetMaximum(90);
166 c2.SetFrameBorderMode(0);
167 c2.SetLeftMargin(0.085);
168 c2.SetRightMargin(0.01);
169 c2.SetTopMargin(0.03);
171 hframe.GetYaxis()->SetTitle(
"Predicted Current [#muA]");
172 hframe.SetMinimum(0);
173 hframe.SetMaximum(100);
179 c3.SetFrameBorderMode(0);
180 c3.SetLeftMargin(0.085);
181 c3.SetRightMargin(0.01);
182 c3.SetTopMargin(0.03);
185 hframe.GetYaxis()->SetTitle(
"Estimated relative threshold");
186 hframe.GetYaxis()->SetMoreLogLabels();
187 hframe.SetMinimum(0.9);
188 hframe.SetMaximum(11);
194 c4.SetFrameBorderMode(0);
195 c4.SetLeftMargin(0.085);
196 c4.SetRightMargin(0.01);
197 c4.SetTopMargin(0.03);
199 hframe.GetYaxis()->SetTitle(
"Distance to moon [deg]");
200 hframe.SetMinimum(0);
201 hframe.SetMaximum(180);
205 Int_t style[] = { kSolid, kDashed, kDotted };
207 TLegend leg(0, 0, 1, 1);
212 for (vector<mysqlpp::Row>::const_iterator v=res.begin(); v<res.end(); v++, cnt++)
215 const string name = (*v)[0].c_str();
218 pos.ra = double((*v)[1])*15;
219 pos.dec = double((*v)[2]);
222 TGraph g1, g2, g3, g4, gr, gm;
223 g1.SetName(name.data());
224 g2.SetName(name.data());
225 g3.SetName(name.data());
226 g4.SetName(name.data());
232 g1.SetLineStyle(style[cnt/6]);
233 g2.SetLineStyle(style[cnt/6]);
234 g3.SetLineStyle(style[cnt/6]);
235 g4.SetLineStyle(style[cnt/6]);
236 g1.SetLineColor(color[cnt%6]);
237 g2.SetLineColor(color[cnt%6]);
238 g3.SetLineColor(color[cnt%6]);
239 g4.SetLineColor(color[cnt%6]);
243 leg.AddEntry(gm.Clone(),
"Moon",
"l");
244 leg.AddEntry(g1.Clone(), name.data(),
"l");
247 for (
double h=0; h<1; h+=1./(24*12))
260 const double ratio = pow(cos((90-hrz.alt)*M_PI/180), -2.664);
263 const double axis =
Time(so.
fJD).
Mjd()*24*3600;
273 if (no_limits || cur<max_current)
274 g1.SetPoint(g1.GetN(), axis, hrz.alt);
276 if (no_limits || 90-hrz.alt<max_zd)
277 g2.SetPoint(g2.GetN(), axis, cur);
279 if (no_limits || (cur<max_current && 90-hrz.alt<max_zd))
280 g3.SetPoint(g3.GetN(), axis, ratio*pow(cur/6.2, 0.394));
282 if (no_limits || (cur<max_current && 90-hrz.alt<max_zd))
285 g4.SetPoint(g4.GetN(), axis, angle);
289 gm.SetPoint(gm.GetN(), axis, so.
fMoonHrz.alt);
306 c5.SetFrameBorderMode(0);
311 c1.SaveAs((t+
"-ZenithDistance.eps").c_str());
312 c2.SaveAs((t+
"-PredictedCurrent.eps").c_str());
313 c3.SaveAs((t+
"-RelativeThreshold.eps").c_str());
314 c4.SaveAs((t+
"-MoonDist.eps").c_str());
315 c5.SaveAs((t+
"-Legend.eps").c_str());
317 c1.SaveAs((t+
"-ZenithDistance.root").c_str());
318 c2.SaveAs((t+
"-PredictedCurrent.root").c_str());
319 c3.SaveAs((t+
"-RelativeThreshold.root").c_str());
320 c4.SaveAs((t+
"-MoonDist.root").c_str());
322 c1.Print((t+
".pdf(").c_str(),
"pdf");
323 c2.Print((t+
".pdf" ).c_str(),
"pdf");
324 c3.Print((t+
".pdf" ).c_str(),
"pdf");
325 c4.Print((t+
".pdf" ).c_str(),
"pdf");
326 c5.Print((t+
".pdf)").c_str(),
"pdf");
Adds some functionality to boost::posix_time::ptime for our needs.
void SetPrintUsage(const std::function< void(void)> &func)
T Get(const std::string &var)
po::typed_value< bool > * po_switch()
void DrawClone(TCanvas &c, TGraph &g)
void SetArgumentPositions(const po::positional_options_description &desc)
void SetupConfiguration(Configuration &conf)
bool Has(const std::string &var)
void AddOptions(const po::options_description &opt, bool visible=true)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Commandline parsing, resource file parsing and database access.
void SetFromStr(const std::string &str, const char *fmt="%Y-%m-%d %H:%M:%S")
void CheckForGap(TCanvas &c, TGraph &g, double axis)
RstTime GetSolarRst(double jd, const LnLatPosn &obs, double hrz=LN_SOLAR_STANDART_HORIZON)
HrzPosn GetHrzFromEqu(const EquPosn &equ, const LnLatPosn &obs, double jd)
double GetAngularSeparation(const EquPosn &p1, const EquPosn &p2)
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
bool DoParse(int argc, const char **argv, const std::function< void()> &func=std::function< void()>())
double PredictI(const Nova::SolarObjects &so, const Nova::EquPosn &srcEqu)
int main(int argc, const char *argv[])