source: trunk/Mars/macros/starvisday.C@ 11628

Last change on this file since 11628 was 8066, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 4.5 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 10/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2004-2006
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////////
26//
27// starvisday.C
28//
29// displays the star visibility of several stars for one day
30//
31// See the code for ducumentation and setup
32//
33///////////////////////////////////////////////////////////////////////////
34
35void starvisday()
36{
37 // Date (UTC) for which to get the visibility plot
38 MTime time(-1); // -1 means NOW
39
40 // Setup a different time as you like
41 // time.Set(2006, 10, 10);
42
43 // Current observatory (see class reference of MObservatory)
44 const MObservatory obs(MObservatory::kMagic1);
45
46 // The class contaning the catalog
47 MAstroCatalog stars;
48 stars.SetObservatory(obs);
49 stars.SetTime(time);
50
51 // Read the stars from a star catalog. The catalogs can be downloaded
52 // from the Mars web page. For more information see class reference.
53 stars.ReadXephem("/magic/datacenter/setup/magic_favorites.edb");
54
55 // Mark the stars you would like to display (see the names in the catalog)
56 stars.MarkObject("CrabNebula");
57 stars.MarkObject("1ES1218+304");
58 stars.MarkObject("1ES1426+428");
59 stars.MarkObject("Mrk421");
60 stars.MarkObject("Mrk501");
61 stars.MarkObject("1ES1959+650");
62 stars.MarkObject("1ES2344+514");
63
64 // --------------------------------------------------------------------------
65 //
66 // Start producing the nice plot
67 //
68
69 // open and setup a new canvas
70 TCanvas *c = new TCanvas;
71 c->SetBorderMode(0);
72 c->SetFillColor(kWhite);
73 c->SetFrameBorderMode(0);
74 c->SetFrameFillStyle(0);
75
76 c->SetGridx();
77 c->SetGridy();
78
79 // Draw the twilight and dark time
80 TBox box;
81 box.SetFillStyle(4100);
82 for (int i=0; i<4; i++)
83 {
84 double set = obs.GetSunRiseSet(time.GetMjd()-1, -6*i)[1];
85 double ris = obs.GetSunRiseSet(time.GetMjd(), -6*i)[0];
86
87 box.SetFillColor(19-i);
88 box.DrawBox(MTime(set).GetAxisTime(), 5,
89 MTime(ris).GetAxisTime(), 90);
90 }
91
92 // Setup the TGraph which is drawn
93 TGraph g;
94 g.SetTitle(Form("Visibility at %s, %s",
95 obs.GetObservatoryName().Data(),
96 time.GetStringFmt("%A %e.%B %Y").Data()));
97 g.SetLineWidth(2);
98
99 // Some helper to iterate these three colors
100 Int_t col[] = { kBlack, kBlue, kRed };
101
102 // Loop over all stars in the catalog
103 int k=0;
104 TIter Next(stars.GetList());
105 TObject *o=0;
106 while ((o=Next()))
107 {
108 // Check if the star was previously marked
109 if (!o->TestBit(1<<14))
110 continue;
111
112 // Set graph name to object name
113 g.SetName(o->GetName());
114
115 // produce visibility curve
116 stars.GetVisibilityCurve(g);
117
118 // Setup description
119 TText txt;
120 txt.SetTextFont(102);
121 txt.SetTextSize(0.03);
122 txt.SetTextColor(col[k%3]);
123
124 // Setup color and style of TGraph
125 g.SetLineColor(col[k%3]);
126 g.SetLineStyle(1+k/3);
127
128 // Draw TGraph
129 g.DrawClone(k++?"c":"ac")->SetBit(kCanDelete);
130
131 // Search for culmination
132 Long64_t max = TMath::LocMax(g.GetN(), g.GetY());
133
134 // draw name at culmination
135 txt.DrawText(g.GetX()[max]-1.0*3600, g.GetY()[max]+1, o->GetName());
136 }
137
138 c->Modified();
139 c->Update();
140
141 // Draw a line for the "best observation conditions"
142 TLine line;
143 line.SetLineWidth(2);
144 line.SetLineStyle(9);
145 line.SetLineColor(13);
146
147 TAxis &axe = *g.GetHistogram()->GetXaxis();
148 line.DrawLine(axe.GetBinLowEdge(axe.GetFirst()), 65,
149 axe.GetBinLowEdge(axe.GetLast()), 65);
150
151}
Note: See TracBrowser for help on using the repository browser.