Changeset 14716
- Timestamp:
- 12/03/12 20:38:22 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/makeplots.cc
r14705 r14716 41 41 return acos(arg) * 180/M_PI; 42 42 } 43 44 void CheckForGap(TCanvas &c, TGraph &g, double axis) 45 { 46 if (g.GetN()==0 || axis-g.GetX()[g.GetN()-1]<450) 47 return; 48 49 c.cd(); 50 ((TGraph*)g.DrawClone("C"))->SetBit(kCanDelete); 51 while (g.GetN()) 52 g.RemovePoint(0); 53 } 54 43 55 44 56 // ======================================================================== … … 71 83 "makeplots - The astronomy plotter\n" 72 84 "\n" 85 "Calculates several plots for the sources in the database\n" 86 "helpful or needed for scheduling. The Plot is always calculated\n" 87 "for the night which starts at the same so. So no matter if\n" 88 "you specify '1974-09-09 00:00:00' or '1974-09-09 21:56:00'\n" 89 "the plots will refer to the night 1974-09-09/1974-09-10.\n" 90 "The advantage is that specification of the date as in\n" 91 "1974-09-09 is enough.\n" 92 "\n" 73 93 "Usage: makeplots sql-datetime [--ra={ra} --dec={dec}]\n"; 74 94 cout << endl; … … 109 129 const double no_limits = conf.Get<bool>("no-limits"); 110 130 111 ln_rst_time sun_astronomical; 112 ln_get_solar_rst_horizon(time.JD(), &observer, -12, &sun_astronomical); 113 114 const double jd = floor(time.JD()); 115 const double mjd = floor(time.Mjd())+49718-0.5; 116 117 const double jd0 = fmod(sun_astronomical.set, 1); 118 const double jd1 = fmod(sun_astronomical.rise, 1); 119 120 cout << "JD0=" << jd+jd0 << endl; 121 cout << "JD1=" << jd+jd1 << endl; 131 // -12: astronomical twilight 132 ln_rst_time sun_set; // Sun set with the same date than th provided date 133 ln_rst_time sun_rise; // Sun rise on the following day 134 ln_get_solar_rst_horizon(time.JD()-0.5, &observer, -12, &sun_set); 135 ln_get_solar_rst_horizon(time.JD()+0.5, &observer, -12, &sun_rise); 136 137 const double jd = floor(time.Mjd())+2400001; 138 const double mjd = floor(time.Mjd())+49718+0.5; 139 140 cout << "Time: " << time << endl; 141 cout << "Set: " << Time(sun_set.set) << endl; 142 cout << "Rise: " << Time(sun_rise.rise) << endl; 143 144 const double jd0 = fmod(sun_set.set, 1); // ~0.3 145 const double jd1 = fmod(sun_rise.rise, 1); // ~0.8 122 146 123 147 const string fDatabase = conf.Get<string>("source-database"); … … 188 212 hframe.DrawCopy(); 189 213 214 TCanvas c4; 215 gPad->SetLeftMargin(0.085); 216 gPad->SetRightMargin(0.01); 217 gPad->SetTopMargin(0.03); 218 gPad->SetGrid(); 219 hframe.GetYaxis()->SetTitle("Distance to moon [deg]"); 220 hframe.SetMinimum(0); 221 hframe.SetMaximum(180); 222 hframe.DrawCopy(); 223 190 224 Int_t color[] = { kBlack, kRed, kBlue, kGreen, kCyan, kMagenta }; 191 225 Int_t style[] = { kSolid, kDashed, kDotted }; … … 206 240 207 241 // Create graphs 208 TGraph g1, g2, g3 ;242 TGraph g1, g2, g3, g4, gm; 209 243 g1.SetName(name.data()); 210 244 g2.SetName(name.data()); 211 245 g3.SetName(name.data()); 246 g4.SetName(name.data()); 212 247 g1.SetLineWidth(2); 213 248 g2.SetLineWidth(2); 214 249 g3.SetLineWidth(2); 250 g4.SetLineWidth(2); 251 gm.SetLineWidth(1); 215 252 g1.SetLineStyle(style[cnt/6]); 216 253 g2.SetLineStyle(style[cnt/6]); 217 254 g3.SetLineStyle(style[cnt/6]); 255 g4.SetLineStyle(style[cnt/6]); 218 256 g1.SetLineColor(color[cnt%6]); 219 257 g2.SetLineColor(color[cnt%6]); 220 258 g3.SetLineColor(color[cnt%6]); 259 g4.SetLineColor(color[cnt%6]); 260 gm.SetLineColor(kYellow); 221 261 222 262 // Loop over 24 hours … … 254 294 255 295 // If there is a gap of more than one bin, start a new curve 256 if (g1.GetN()>0 && axis-g1.GetX()[g1.GetN()-1]>450) 257 { 258 c1.cd(); 259 ((TGraph*)g1.DrawClone("C"))->SetBit(kCanDelete); 260 while (g1.GetN()) 261 g1.RemovePoint(0); 262 } 263 264 if (g2.GetN()>0 && axis-g2.GetX()[g2.GetN()-1]>450) 265 { 266 c2.cd(); 267 ((TGraph*)g2.DrawClone("C"))->SetBit(kCanDelete); 268 while (g2.GetN()) 269 g2.RemovePoint(0); 270 } 271 272 if (g3.GetN()>0 && axis-g3.GetX()[g3.GetN()-1]>450) 273 { 274 c3.cd(); 275 ((TGraph*)g3.DrawClone("C"))->SetBit(kCanDelete); 276 while (g3.GetN()) 277 g3.RemovePoint(0); 278 } 296 CheckForGap(c1, g1, axis); 297 CheckForGap(c1, gm, axis); 298 CheckForGap(c2, g2, axis); 299 CheckForGap(c3, g3, axis); 300 CheckForGap(c4, g4, axis); 279 301 280 302 // Add data … … 287 309 if (no_limits || (cur<max_current && 90-hrz.alt<max_zd)) 288 310 g3.SetPoint(g3.GetN(), axis, ratio*cur/7.7); 311 312 if (no_limits || (cur<max_current && 90-hrz.alt<max_zd)) 313 g4.SetPoint(g4.GetN(), axis, angle); 314 315 if (cnt==0) 316 gm.SetPoint(gm.GetN(), axis, hrzm.alt); 289 317 } 290 318 291 319 // Add graphs to canvases and add corresponding entry to legend 292 TGraph *g = 0;293 294 320 c1.cd(); 295 g = (TGraph*)g1.DrawClone("C"); 296 g->SetBit(kCanDelete); 321 if (cnt==0) 322 { 323 TGraph *g = (TGraph*)gm.DrawClone("C"); 324 g->SetBit(kCanDelete); 325 leg.AddEntry(g, "Moon", "l"); 326 } 327 ((TGraph*)g1.DrawClone("C"))->SetBit(kCanDelete); 297 328 298 329 c2.cd(); 299 g = (TGraph*)g2.DrawClone("C"); 300 g->SetBit(kCanDelete); 330 ((TGraph*)g2.DrawClone("C"))->SetBit(kCanDelete); 301 331 302 332 c3.cd(); 303 g = (TGraph*)g3.DrawClone("C"); 333 ((TGraph*)g3.DrawClone("C"))->SetBit(kCanDelete); 334 335 c4.cd(); 336 TGraph *g = (TGraph*)g4.DrawClone("C"); 304 337 g->SetBit(kCanDelete); 305 338 … … 307 340 } 308 341 342 309 343 // Save three plots 310 TCanvas c 4;344 TCanvas c5; 311 345 leg.Draw(); 312 346 … … 314 348 c2.SaveAs("test2.eps"); 315 349 c3.SaveAs("test3.eps"); 316 c4.SaveAs("legend.eps"); 350 c4.SaveAs("test4.eps"); 351 c5.SaveAs("legend.eps"); 317 352 318 353 c1.SaveAs("test1.root"); 319 354 c2.SaveAs("test2.root"); 320 355 c3.SaveAs("test3.root"); 356 c4.SaveAs("test4.root"); 321 357 322 358 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.