source: trunk/Mars/hawc/atmabs.C@ 20084

Last change on this file since 20084 was 19768, checked in by tbretz, 5 years ago
Minor corrections to a comment.
File size: 5.2 KB
Line 
1void atmabs()
2{
3 // =============================================================================
4 // measured flux (lambda) = emitted flux (lambda) * trans(H, lambda)
5 // =============================================================================
6 TH2F hist1 ("TransCeres", "Ceres Transmission", 700-250, 250, 700, 50, 0, 50);
7 TH2F hist1a("TransCeresRayleigh", "Ceres Transmission (Rayleigh)", 700-250, 250, 700, 50, 0, 50);
8 TH2F hist1b("TransCeresOzone", "Ceres Transmission (Ozone)", 700-250, 250, 700, 50, 0, 50);
9 TH2F hist1c("TransCeresAerosol", "Ceres Transmission (Aerosol)", 700-250, 250, 700, 50, 0, 50);
10
11 const char *ozone = "resmc/atmosphere-ozone.txt";
12 const char *aerosols = "resmc/atmosphere-aerosols.txt";
13
14 MAtmosphere atm(ozone, aerosols);
15
16 cout << atm.HasValidAerosol() << " " << atm.HasValidOzone() << endl;
17
18 for (int h=0; h<50; h++)
19 {
20 for (int l=250; l<700; l++)
21 {
22 MPhotonData ph;
23 ph.SetWavelength(l);
24 ph.SetProductionHeight(h*1e3*1e2);
25
26 hist1a.Fill(l, h, atm.CalcTransmission(h*1e5, l, 0));
27 hist1b.Fill(l, h, atm.CalcOzoneAbsorption(h*1e5, l, 0));
28 hist1c.Fill(l, h, atm.CalcAerosolAbsorption(h*1e5, l, 0));
29 hist1.Fill(l, h, atm.GetTransmission(ph));
30 }
31 }
32
33 // =============================================================================
34 // The CCD Photometric Calibration Cookbook
35 // 8 Atmospheric Extinction and Air Mass
36 // http://star-www.rl.ac.uk/star/docs/sc6.htx/sc6se8.html
37 //
38 // measured magnitude (lambda) = emitted magnitude (lambda) + extco(lambda) * X(z)
39 //
40 // ==> measured flux = emitted flux * exp(extco * X(h))
41 //
42 // =============================================================================
43
44 TH2F hist2("AtmAbs", "Corsika Atmosphere atmabs.txt", (700-180)/5+1, 178.5, 702.5, 51, -0.5, 50.5);
45
46 ifstream fin("/home/tbretz/SW/corsika-76900/run/atmabs.dat");
47
48 TString buf;
49 buf.ReadLine(fin);
50 cout << buf << endl;
51
52 while (1)
53 {
54 double wl;
55 fin >> wl;
56 if (!fin)
57 break;
58
59 for (int h=0; h<51; h++)
60 {
61 double cc;
62 fin >> cc;
63 hist2.Fill(wl, h, cc);
64 }
65 }
66
67 // =============================================================================
68 hist1.SetMinimum(0);
69 hist1.SetMaximum(1);
70 hist1.SetContour(500);
71
72 hist1a.SetMinimum(0);
73 hist1a.SetMaximum(1);
74 hist1a.SetContour(500);
75
76 hist1b.SetMinimum(0);
77 hist1b.SetMaximum(1);
78 hist1b.SetContour(500);
79
80 hist1c.SetMinimum(0);
81 hist1c.SetMaximum(1);
82 hist1c.SetContour(500);
83
84 // =============================================================================
85
86 gStyle->SetOptStat(11);
87
88 TCanvas *c = new TCanvas;
89 c->Divide(2, 2);
90
91 c->cd(1);
92 hist1a.DrawCopy("colz");
93
94 c->cd(2);
95 hist1b.DrawCopy("colz");
96
97 c->cd(3);
98 hist1c.DrawCopy("colz");
99
100 c->cd(4);
101 hist1.DrawCopy("colz");
102
103 // =============================================================================
104
105 c = new TCanvas;
106 c->Divide(2, 2);
107
108 c->cd(1);
109 hist1.DrawCopy("colz");
110
111 c->cd(2);
112 hist2.SetMinimum(0);
113 //hist2.SetMaximum(1);
114 hist2.SetContour(500);
115 hist2.DrawCopy("colz");
116
117 // =============================================================================
118 //
119 // see CORSIKA ATABSO()
120 //
121 // CORSIKA calculates a coefficient COATEX which is the value interpolated
122 // in wavelength and height from the table.
123 //
124 // From this value, the interpolated value at observation level is subtraced.
125 //
126 // The probability to survive (=transmission) is then exp(-COATEX/WEMIS)
127 //
128 // WEMIS defined as the particles z-direction cosine (-> correction for
129 // zenith angle (flat atmosphere))
130 //
131 // =============================================================================
132
133 TH2F hist4("TransCorsika", "Corsika Transmission", (700-180)/5+1, 178.5, 702.5, 51, -0.5, 50.5);
134 for (int x=1; x<=hist2.GetNbinsX(); x++)
135 {
136 double sum = 0;
137 for (int y=1; y<=hist2.GetNbinsY(); y++)
138 {
139 const double cosz = 1;
140 hist4.SetBinContent(x, y, exp(-hist2.GetBinContent(x, y)/cosz));
141 }
142 }
143
144 c->cd(4);
145 hist4.SetMinimum(0);
146 hist4.SetMaximum(1);
147 hist4.SetContour(500);
148 hist4.DrawCopy("colz");
149
150 c->cd(3);
151 TH1D *p1 = hist1.ProjectionX("TransCeres50km", hist1.GetNbinsY(), hist1.GetNbinsY());
152 TH1D *p4 = hist4.ProjectionX("TransCorsika50km", hist4.GetNbinsY(), hist4.GetNbinsY());
153 TH1D *p1b = hist1.ProjectionX("TransCeres5km", 5, 5);
154 TH1D *p4b = hist4.ProjectionX("TransCorsika5km", 5, 5);
155
156 p1->SetNameTitle("Trans", "Transmission");
157
158 p4->SetLineColor(kBlue);
159 p4b->SetLineColor(kBlue);
160 p1->SetMinimum(0);
161 p1->SetMaximum(1);
162 p1->Draw();
163 p4->Draw("same");
164 p1b->Draw("same");
165 p4b->Draw("same");
166
167 TLatex text;
168 text.DrawLatex(275, 0.850, "Ceres");
169 text.DrawLatex(340, 0.250, "50km");
170 text.DrawLatex(320, 0.650, "5km");
171 text.SetTextColor(kBlue);
172 text.DrawLatex(275, 0.925, "Corsika");
173}
Note: See TracBrowser for help on using the repository browser.