Добавил:
okley
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Антарктида (3 сем, мага) / HW1 / glace
.C#include "TGaxis.h"
void glace() {
float temp_1[8] = {-1., -5., -10., -20., -30., -40., -50., -60.};
float tgDelta_1[8] = {0.00108, 0.00076, 0.00055, 0.00033, 0.00021, 0.00013, 0.00008, 0.00003};
float ro_1 = 0.818;
float temp_2[6] = {-1., -5., -10., -20., -30., -40.};
float tgDelta_2[6] = {0.00180, 0.00130, 0.00108, 0.00078, 0.00057, 0.00044};
float ro_2 = 0.881;
TCanvas *cnv = new TCanvas("cnv","cnv",1000, 700);
gPad->SetLeftMargin(0.15);
gPad->SetTopMargin(0.15);
gPad->SetBottomMargin(0.15);
gPad->SetFrameLineWidth(2);
gStyle->SetOptStat(kFALSE);
gStyle->SetOptTitle(0);
cnv->cd();
TGraph *g1 = new TGraph(8, temp_1, tgDelta_1);
g1->SetMarkerStyle(20);
g1->SetMarkerSize(1.);
g1->SetMarkerColor(9);
g1->SetLineColor(9);
g1->SetLineWidth(2);
g1->Draw("AP");
g1->GetXaxis()->SetTitle("T, ^{#circ}C");
g1->GetYaxis()->SetTitle("tg(#delta)");
g1->SetMinimum(0.);
g1->SetMaximum(0.002);
g1->GetXaxis()->SetLimits(-198., 10.);
g1->GetXaxis()->SetLabelFont(62);
g1->GetXaxis()->SetTitleFont(62);
g1->GetXaxis()->SetTitleSize(0.045);
g1->GetYaxis()->SetLimits(0., 0.002);
g1->GetYaxis()->SetLabelFont(62);
g1->GetYaxis()->SetTitleFont(62);
g1->GetYaxis()->SetTitleSize(0.045);
TGaxis *axis = new TGaxis(g1->GetXaxis()->GetXmin(), g1->GetYaxis()->GetXmax(), g1->GetXaxis()->GetXmax(), g1->GetYaxis()->GetXmax(), 75., 283., 510, "-L");
axis->SetTitle("T, K");
axis->SetTitleSize(0.045);
axis->Draw();
TGraph *g2 = new TGraph(6, temp_2, tgDelta_2);
g2->SetMarkerStyle(20);
g2->SetMarkerSize(1.);
g2->SetMarkerColor(6);
g2->SetLineColor(6);
g2->SetLineWidth(2);
g2->Draw("same P");
g2->GetXaxis()->SetTitle("T, ^{#circ}C");
g2->GetYaxis()->SetTitle("tg(#delta)");
g2->SetMinimum(0.);
g2->SetMaximum(0.002);
g2->GetXaxis()->SetLimits(-198., 10.);
TF1 *fit1 = new TF1("fit1", "expo", -198., 10.);
fit1->SetLineColor(9);
g1->Fit("fit1", "LN", "", -55., -2.);
fit1->Draw("same");
TF1 *fit2 = new TF1("fit2", "expo", -198., 10.);
fit2->SetLineColor(6);
g2->Fit("fit2", "L", "same", -45., -2.);
fit2->Draw("same");
TLegend *leg = new TLegend(0.16, 0.66, 0.5, 0.84);
leg->AddEntry(g1, Form("Iceland, the glacier ice: #rho = %.3f", ro_1), "lp");
leg->AddEntry(g2, Form("Little America, Antarctica: #rho = %.3f", ro_2), "lp");
leg->SetTextSize(0.04);
leg->SetTextFont(62);
leg->SetBorderSize(0.);
leg->Draw("same");
TLatex *ltx = new TLatex(-190., 0.0012, "#splitline{tg(#delta) = #varepsilon''/#varepsilon'}{f = 300 MHz}");
ltx->SetTextSize(0.045);
ltx->SetTextFont(62);
ltx->Draw("same");
std::cout << std::endl << "*** Calculate using mean temperature *** " << std::endl;
std::cout << std::endl << "*** Iceland, the glacier ice *** " << std::endl
<< Form("-> temperature range 80-124 K: <T> = 102 K, tg(delta) = %.8f", fit1->Eval(102-273)) << std::endl
<< Form("-> temperature range 80-139 K: <T> = 110 K, tg(delta) = %.8f", fit1->Eval(110-273)) << std::endl;
std::cout << std::endl << "*** Little America, Antarctica *** " << std::endl
<< Form("-> temperature range 80-124 K: <T> = 102 K, tg(delta) = %.8f", fit2->Eval(102-273)) << std::endl
<< Form("-> temperature range 80-139 K: <T> = 110 K, tg(delta) = %.8f", fit2->Eval(110-273)) << std::endl;
std::cout << std::endl << "*** Calculate using integrating *** " << std::endl;
std::cout << std::endl << "*** Iceland, the glacier ice *** " << std::endl
<< Form("-> temperature range 80-124 K: <tg(delta)> = %.8f", fit1->Integral(80-273., 124-273)/(124-80)) << std::endl
<< Form("-> temperature range 80-139 K: <tg(delta)> = %.8f", fit1->Integral(80-273., 139-273)/(139-80)) << std::endl;
std::cout << std::endl << "*** Little America, Antarctica *** " << std::endl
<< Form("-> temperature range 80-124 K: <T> = 102 K, tg(delta) = %.8f", fit2->Integral(80-273., 124-273)/(124-80)) << std::endl
<< Form("-> temperature range 80-139 K: <T> = 110 K, tg(delta) = %.8f", fit2->Integral(80-273., 139-273)/(139-80)) << std::endl;
cnv->Print("tgDeltaVsTemp.png");
cnv->Close();
float temp[9] = {222, 225, 226, 229, 232, 237, 242, 247, 255};
float Latt[9] = {2017, 1665, 1555, 1404, 1177, 908, 730, 555, 342};
TCanvas *cnv2 = new TCanvas("cnv2","cnv2",1000, 700);
gPad->SetLeftMargin(0.15);
gPad->SetTopMargin(0.15);
gPad->SetBottomMargin(0.15);
gPad->SetFrameLineWidth(2);
gStyle->SetOptStat(kFALSE);
gStyle->SetOptTitle(0);
cnv2->cd();
TGraph *g3 = new TGraph(9, temp, Latt);
g3->SetMarkerStyle(20);
g3->SetMarkerSize(1.);
g3->SetMarkerColor(1);
g3->SetLineColor(1);
g3->SetLineWidth(2);
g3->Draw("AP");
g3->GetXaxis()->SetTitle("T, K");
g3->GetYaxis()->SetTitle("L_{att}, m");
g3->SetMinimum(210.);
g3->SetMaximum(2250.);
g3->GetXaxis()->SetLimits(215., 265.);
g3->GetXaxis()->SetLabelFont(62);
g3->GetXaxis()->SetTitleFont(62);
g3->GetXaxis()->SetTitleSize(0.045);
g3->GetYaxis()->SetLimits(210., 2250.);
g3->GetYaxis()->SetLabelFont(62);
g3->GetYaxis()->SetTitleFont(62);
g3->GetYaxis()->SetTitleSize(0.045);
TGaxis *axis3 = new TGaxis(g3->GetXaxis()->GetXmin(), g3->GetYaxis()->GetXmax(), g3->GetXaxis()->GetXmax(), g3->GetYaxis()->GetXmax(), -213., -13., 510, "-L");
axis3->SetTitle("T, ^{#circ}C");
axis3->SetTitleSize(0.045);
axis3->Draw();
TF1 *fit3 = new TF1("fit3", "expo", 220., 260.);
fit3->SetLineColor(2);
g3->Fit("fit3", "L", "same", 220., 260.);
std::cout << std::endl << "*** Calculate the attenuation length by integrating fit function *** " << std::endl;
std::cout << Form("-> temperature range 80-124 K: Latt = %.0f m", fit3->Integral(80., 124)/(124-80)) << std::endl
<< Form("-> temperature range 80-139 K: Latt = %.0f m", fit3->Integral(80., 139)/(139-80)) << std::endl;
cnv2->Print("LattVsTemp.png");
cnv2->Close();
}
Соседние файлы в папке HW1
