Changeset 12764 for trunk/Mars/macros/starvisday.C
- Timestamp:
- 01/25/12 11:47:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/macros/starvisday.C
r8066 r12764 33 33 /////////////////////////////////////////////////////////////////////////// 34 34 35 void 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 35 51 void starvisday() 36 52 { … … 39 55 40 56 // Setup a different time as you like 41 // time.Set(2006, 1 0, 10);57 // time.Set(2006, 12, 20); 42 58 43 59 // Current observatory (see class reference of MObservatory) … … 51 67 // Read the stars from a star catalog. The catalogs can be downloaded 52 68 // from the Mars web page. For more information see class reference. 53 stars.ReadXephem(" /magic/datacenter/setup/magic_favorites.edb");69 stars.ReadXephem("magic_favorites.edb"); 54 70 55 71 // Mark the stars you would like to display (see the names in the catalog) … … 58 74 stars.MarkObject("1ES1426+428"); 59 75 stars.MarkObject("Mrk421"); 60 stars.MarkObject("Mrk501"); 61 stars.MarkObject("1ES1959+650"); 62 stars.MarkObject("1ES2344+514"); 76 // stars.MarkObject("Mrk501"); 77 // stars.MarkObject("1ES1959+650"); 78 // stars.MarkObject("1ES2344+514"); 79 stars.MarkObject("M87"); 63 80 64 81 // -------------------------------------------------------------------------- … … 77 94 c->SetGridy(); 78 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 79 122 // Draw the twilight and dark time 80 123 TBox box; 81 box.SetFillStyle(4100); 82 for (int i= 0; i<4; i++)124 125 for (int i=3; i>=0; i--) 83 126 { 84 127 double set = obs.GetSunRiseSet(time.GetMjd()-1, -6*i)[1]; 85 128 double ris = obs.GetSunRiseSet(time.GetMjd(), -6*i)[0]; 86 129 87 box.SetFillColor(19-i); 88 box.DrawBox(MTime(set).GetAxisTime(), 5, 89 MTime(ris).GetAxisTime(), 90); 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; 90 136 } 91 137 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())); 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); 97 145 g.SetLineWidth(2); 98 146 147 // =================== 148 99 149 // Some helper to iterate these three colors 100 Int_t col[] = { kBlack, kBlue, kRed };150 Int_t col[] = { kBlack, kBlue, kRed+1, kMagenta+1, kGreen+2 }; 101 151 102 152 // Loop over all stars in the catalog … … 116 166 stars.GetVisibilityCurve(g); 117 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 118 178 // Setup description 119 179 TText txt; 120 180 txt.SetTextFont(102); 121 181 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()); 182 txt.SetTextColor(g.GetLineColor()); 133 183 134 184 // draw name at culmination 135 185 txt.DrawText(g.GetX()[max]-1.0*3600, g.GetY()[max]+1, o->GetName()); 186 187 k++; 136 188 } 137 189 … … 139 191 c->Update(); 140 192 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 193 TButton *but = new TButton("zoom", "zoom()", 0.88, 0.95, 0.99, 0.99); 194 but->Draw(); 151 195 }
Note:
See TracChangeset
for help on using the changeset viewer.