| 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 | // starvisyear.C
|
|---|
| 28 | //
|
|---|
| 29 | // displays the star visibility along one year
|
|---|
| 30 | //
|
|---|
| 31 | // See the code for ducumentation and setup
|
|---|
| 32 | //
|
|---|
| 33 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 34 |
|
|---|
| 35 | void starvisyear()
|
|---|
| 36 | {
|
|---|
| 37 | // Setup the observatory location (see MObservatory for details)
|
|---|
| 38 | MObservatory obs(MObservatory::kMagic1);;
|
|---|
| 39 |
|
|---|
| 40 | // Setup the start time of the year (365 days) to be displayed
|
|---|
| 41 | MTime time(-1); // -1 mean NOW
|
|---|
| 42 |
|
|---|
| 43 | // Setup a different time if you like
|
|---|
| 44 | time.Set(2006, 1, 1, 0);
|
|---|
| 45 |
|
|---|
| 46 | // Setup right ascension and declination of the source to display
|
|---|
| 47 | const Double_t ra = MAstro::Hms2Rad(5, 34, 31.9);
|
|---|
| 48 | const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
|
|---|
| 49 |
|
|---|
| 50 | // Setup the name of the source
|
|---|
| 51 | TString source("CrabNebula");
|
|---|
| 52 |
|
|---|
| 53 | // Setup palette you would like to see (99 is fixed)
|
|---|
| 54 | // for more details see MH::SetPalette
|
|---|
| 55 | MH::SetPalette("glow2", 99);
|
|---|
| 56 |
|
|---|
| 57 | // --------------------------------------------------------------------------
|
|---|
| 58 | //
|
|---|
| 59 | // Start producing the data for the plot
|
|---|
| 60 | //
|
|---|
| 61 |
|
|---|
| 62 | // Setup the source in the appropriate format
|
|---|
| 63 | MVector3 v;
|
|---|
| 64 | v.SetRaDec(ra, dec);
|
|---|
| 65 |
|
|---|
| 66 | // For simplicity get mjd of time
|
|---|
| 67 | Double_t mjd = time.GetMjd();
|
|---|
| 68 |
|
|---|
| 69 | // Setup axis ranges
|
|---|
| 70 | Double_t first = time.GetAxisTime();
|
|---|
| 71 | Double_t last = MTime(mjd+365).GetAxisTime();
|
|---|
| 72 |
|
|---|
| 73 | Int_t h0 = 13-obs.GetLongitudeDeg()/15;
|
|---|
| 74 |
|
|---|
| 75 | // Define histograms
|
|---|
| 76 | TH2D hist( "1", "", 365, first, last, 24*12, first+h0*60*60, first+(h0+24)*60*60);//h0/24.+1, (h0+24)/24.+1);
|
|---|
| 77 | TH2D hmoon("2", "", 365, first, last, 24*12, first+h0*60*60, first+(h0+24)*60*60);//h0/24.+1, (h0+24)/24.+1);
|
|---|
| 78 |
|
|---|
| 79 | // Fill histograms
|
|---|
| 80 | TGraph sunset[4], sunrise[4];
|
|---|
| 81 | for (int x=0; x<365; x++)
|
|---|
| 82 | {
|
|---|
| 83 | // Get moon phase and axis time for mjd+x
|
|---|
| 84 | Double_t moon = MAstro::GetMoonPhase(mjd+x);
|
|---|
| 85 | Double_t tmx = MTime(mjd+x).GetAxisTime();
|
|---|
| 86 |
|
|---|
| 87 | // get sunrise and sunset for the current day
|
|---|
| 88 | Double_t sunst[4], sunri[4];
|
|---|
| 89 | for (int i=0; i<4; i++)
|
|---|
| 90 | {
|
|---|
| 91 | // get sunset and sunrise of next day
|
|---|
| 92 | sunri[i] = obs.GetSunRiseSet(mjd+x+1,-18+6*i)[0];
|
|---|
| 93 | sunst[i] = obs.GetSunRiseSet(mjd+x, -18+6*i)[1];
|
|---|
| 94 |
|
|---|
| 95 | // fill both into the TGraphs
|
|---|
| 96 | sunset[i].SetPoint( sunset[i].GetN(), tmx, MTime(sunst[i]).GetAxisTime()-x*24*60*60);
|
|---|
| 97 | sunrise[i].SetPoint(sunrise[i].GetN(), tmx, MTime(sunri[i]).GetAxisTime()-x*24*60*60);
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | // If nautical twilight doesn't take place skip the rest
|
|---|
| 101 | if (sunri[1]<0 || sunst[1]<0)
|
|---|
| 102 | continue;
|
|---|
| 103 |
|
|---|
| 104 | // Now calculate in steps of five minutes
|
|---|
| 105 | for (int hor=0; hor<24*12; hor++)
|
|---|
| 106 | {
|
|---|
| 107 | Double_t hr = hor/12. + h0;
|
|---|
| 108 | Double_t offset = x + hr/24.;
|
|---|
| 109 |
|
|---|
| 110 | // mjd of the current time
|
|---|
| 111 | MTime tm(mjd+offset);
|
|---|
| 112 |
|
|---|
| 113 | // Check if current time is within darkness
|
|---|
| 114 | if (tm.GetMjd()>sunri[1] || tm.GetMjd()<sunst[1])
|
|---|
| 115 | continue;
|
|---|
| 116 |
|
|---|
| 117 | // Initialize conversion from sky coordinates to local coordinates
|
|---|
| 118 | MAstroSky2Local conv(tm.GetGmst(), obs);
|
|---|
| 119 |
|
|---|
| 120 | // get moon position on the sky
|
|---|
| 121 | Double_t moonra, moondec;
|
|---|
| 122 | MAstro::GetMoonRaDec(tm.GetMjd(), moonra, moondec);
|
|---|
| 123 |
|
|---|
| 124 | // calculate moon position as seen by the telescope
|
|---|
| 125 | v.SetRaDec(moonra, moondec);
|
|---|
| 126 | v *= conv;
|
|---|
| 127 |
|
|---|
| 128 | // check if moon is above or below horizont
|
|---|
| 129 | if (v.Theta()*TMath::RadToDeg()<90)
|
|---|
| 130 | moon = 0;
|
|---|
| 131 |
|
|---|
| 132 | // fill moon visibility into hostpogram
|
|---|
| 133 | hmoon.SetBinContent(x+1, hor+1, moon);
|
|---|
| 134 |
|
|---|
| 135 | // calculate source position as seen by the telescope
|
|---|
| 136 | v.SetRaDec(ra, dec);
|
|---|
| 137 | v *= conv;
|
|---|
| 138 |
|
|---|
| 139 | // fill altitude of source into histogram
|
|---|
| 140 | hist.SetBinContent(x+1, hor+1, v.Theta()*TMath::RadToDeg());
|
|---|
| 141 | }
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | // --------------------------------------------------------------------------
|
|---|
| 145 | //
|
|---|
| 146 | // Start producing the nice plot
|
|---|
| 147 | //
|
|---|
| 148 |
|
|---|
| 149 | // Setup canvas
|
|---|
| 150 | TCanvas *c = new TCanvas;
|
|---|
| 151 | c->SetBorderMode(0);
|
|---|
| 152 | c->SetGridx();
|
|---|
| 153 | c->SetGridy();
|
|---|
| 154 |
|
|---|
| 155 | // Setup histogram
|
|---|
| 156 | TString name = obs.GetObservatoryName();
|
|---|
| 157 | hist.SetTitle(Form("Zenith distance of %s at %s", source.Data(), name.Data()));
|
|---|
| 158 |
|
|---|
| 159 | hist.SetXTitle("Day");
|
|---|
| 160 | hist.SetYTitle("UTC");
|
|---|
| 161 |
|
|---|
| 162 | hist.GetXaxis()->CenterTitle();
|
|---|
| 163 | hist.GetYaxis()->CenterTitle();
|
|---|
| 164 |
|
|---|
| 165 | hist.GetXaxis()->SetTimeFormat("%d/%m/%y %F1995-01-01 00:00:00 GMT");
|
|---|
| 166 | hist.GetXaxis()->SetTimeDisplay(1);
|
|---|
| 167 | hist.GetXaxis()->SetLabelSize(0.033);
|
|---|
| 168 |
|
|---|
| 169 | hist.GetYaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
|---|
| 170 | hist.GetYaxis()->SetTimeDisplay(1);
|
|---|
| 171 | hist.GetYaxis()->SetLabelSize(0.033);
|
|---|
| 172 | hist.GetYaxis()->SetTitleOffset(1.3);
|
|---|
| 173 |
|
|---|
| 174 | hist.SetContour(99);
|
|---|
| 175 | hist.SetMinimum(0);
|
|---|
| 176 | hist.SetMaximum(90);
|
|---|
| 177 |
|
|---|
| 178 | hist.SetStats(kFALSE);
|
|---|
| 179 |
|
|---|
| 180 | // draw histograms
|
|---|
| 181 | hist.DrawCopy("colz");
|
|---|
| 182 | hmoon.DrawCopy("scat=7 same");
|
|---|
| 183 |
|
|---|
| 184 | // Draw rise and set time of sun
|
|---|
| 185 | Int_t style[] = { kSolid, 5, 4, kDotted };
|
|---|
| 186 | for (int i=0; i<4; i++)
|
|---|
| 187 | {
|
|---|
| 188 | sunset[i].SetLineColor(kBlue);
|
|---|
| 189 | sunrise[i].SetLineColor(kBlue);
|
|---|
| 190 | sunset[i].SetLineWidth(2);
|
|---|
| 191 | sunrise[i].SetLineWidth(2);
|
|---|
| 192 | sunset[i].SetLineStyle(style[i]);
|
|---|
| 193 | sunrise[i].SetLineStyle(style[i]);
|
|---|
| 194 | sunset[i].DrawClone("L");
|
|---|
| 195 | sunrise[i].DrawClone("L");
|
|---|
| 196 | }
|
|---|
| 197 | }
|
|---|