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

Last change on this file since 17894 was 12764, checked in by tbretz, 13 years ago
Added display of the moon and some more information about visibility
File size: 5.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 zoom()
36{
37 TH1 *h = (TH1*)gPad->FindObject("frame");
38 if (!h)
39 return;
40
41 Int_t mjd = TMath::FloorNint(h->GetXaxis()->GetXmin());
42
43 h->GetXaxis()->SetRangeUser(mjd+0.33*3600*24, mjd+0.85*3600*24);
44 h->GetYaxis()->SetRangeUser(35, 90);
45
46 gPad->Modified();
47 gPad->Update();
48}
49
50
51void starvisday()
52{
53 // Date (UTC) for which to get the visibility plot
54 MTime time(-1); // -1 means NOW
55
56 // Setup a different time as you like
57 // time.Set(2006, 12, 20);
58
59 // Current observatory (see class reference of MObservatory)
60 const MObservatory obs(MObservatory::kMagic1);
61
62 // The class contaning the catalog
63 MAstroCatalog stars;
64 stars.SetObservatory(obs);
65 stars.SetTime(time);
66
67 // Read the stars from a star catalog. The catalogs can be downloaded
68 // from the Mars web page. For more information see class reference.
69 stars.ReadXephem("magic_favorites.edb");
70
71 // Mark the stars you would like to display (see the names in the catalog)
72 stars.MarkObject("CrabNebula");
73 stars.MarkObject("1ES1218+304");
74 stars.MarkObject("1ES1426+428");
75 stars.MarkObject("Mrk421");
76 // stars.MarkObject("Mrk501");
77 // stars.MarkObject("1ES1959+650");
78 // stars.MarkObject("1ES2344+514");
79 stars.MarkObject("M87");
80
81 // --------------------------------------------------------------------------
82 //
83 // Start producing the nice plot
84 //
85
86 // open and setup a new canvas
87 TCanvas *c = new TCanvas;
88 c->SetBorderMode(0);
89 c->SetFillColor(kWhite);
90 c->SetFrameBorderMode(0);
91 c->SetFrameFillStyle(0);
92
93 c->SetGridx();
94 c->SetGridy();
95
96 // Setup the TGraph which is drawn
97 TGraph g;
98 g.SetTitle(Form("Visibility at %s, %s (MOON=%.1f%%)",
99 obs.GetObservatoryName().Data(),
100 time.GetStringFmt("%A %e.%B %Y").Data(),
101 MAstro::GetMoonPhase(time.GetMjd())*100)
102 );
103 g.SetLineWidth(2);
104
105 // ===================
106 // Set graph name to object name
107 g.SetName("Moon");
108
109 // produce visibility curve
110 stars.GetVisibilityCurve(g, "Moon");
111
112 // Draw Frame
113 TH1F *hist = g.GetHistogram();
114 hist->SetName("frame");
115 hist->DrawCopy();
116
117 // Get x-range
118 TAxis *axex = g.GetXaxis();
119 Float_t mn = axex->GetBinLowEdge(axex->GetFirst());
120 Float_t mx = axex->GetBinUpEdge(axex->GetLast());
121
122 // Draw the twilight and dark time
123 TBox box;
124
125 for (int i=3; i>=0; i--)
126 {
127 double set = obs.GetSunRiseSet(time.GetMjd()-1, -6*i)[1];
128 double ris = obs.GetSunRiseSet(time.GetMjd(), -6*i)[0];
129
130 box.SetFillStyle(3001);
131 box.SetFillColor(kGray+3-i);
132 box.DrawBox(mn, 5, MTime(set).GetAxisTime(), 90);
133 box.DrawBox(MTime(ris).GetAxisTime(), 5, mx, 90);
134 box.DrawBox(MTime(set).GetAxisTime(), 15+(i+1)*10,
135 MTime(ris).GetAxisTime(), 5)+i*10;
136 }
137
138 // Draw TGraph for Moon
139 g.SetFillStyle(3003);
140 g.SetFillColor(kRed+1);
141 g.SetLineColor(kRed+1);
142 g.SetLineWidth(1);
143 g.SetLineStyle(kDotted);
144 g.DrawClone("bc")->SetBit(kCanDelete);
145 g.SetLineWidth(2);
146
147 // ===================
148
149 // Some helper to iterate these three colors
150 Int_t col[] = { kBlack, kBlue, kRed+1, kMagenta+1, kGreen+2 };
151
152 // Loop over all stars in the catalog
153 int k=0;
154 TIter Next(stars.GetList());
155 TObject *o=0;
156 while ((o=Next()))
157 {
158 // Check if the star was previously marked
159 if (!o->TestBit(1<<14))
160 continue;
161
162 // Set graph name to object name
163 g.SetName(o->GetName());
164
165 // produce visibility curve
166 stars.GetVisibilityCurve(g);
167
168 // Setup color and style of TGraph
169 g.SetLineColor(col[k%5]);
170 g.SetLineStyle(1+k/3);
171
172 // Draw TGraph
173 g.DrawClone("c")->SetBit(kCanDelete);
174
175 // Search for culmination
176 Long64_t max = TMath::LocMax(g.GetN(), g.GetY());
177
178 // Setup description
179 TText txt;
180 txt.SetTextFont(102);
181 txt.SetTextSize(0.03);
182 txt.SetTextColor(g.GetLineColor());
183
184 // draw name at culmination
185 txt.DrawText(g.GetX()[max]-1.0*3600, g.GetY()[max]+1, o->GetName());
186
187 k++;
188 }
189
190 c->Modified();
191 c->Update();
192
193 TButton *but = new TButton("zoom", "zoom()", 0.88, 0.95, 0.99, 0.99);
194 but->Draw();
195}
Note: See TracBrowser for help on using the repository browser.