Commit be91dbc98c4af2680da3cd1c20d95f0b0875fc16
1 parent
cdd84c91
commit after extensive tests of the skymap creation
Showing
3 changed files
with
23 additions
and
16 deletions
inst/cta/src/GCTAModelBackground.cpp
| ... | ... | @@ -1011,7 +1011,7 @@ void GCTAModelBackground::set_spatial(const GCTAObservation& obs, const std::str |
| 1011 | 1011 | // Retrieve pointing in sky direction |
| 1012 | 1012 | GSkyDir pntdir = pnt->dir(); |
| 1013 | 1013 | |
| 1014 | - // Retrieve rotation matrix for sky coordinate to camera coordinate | |
| 1014 | + // create rotation matrix | |
| 1015 | 1015 | GMatrix ry; |
| 1016 | 1016 | GMatrix rz; |
| 1017 | 1017 | ry.eulery(pntdir.dec_deg() - 90.0); |
| ... | ... | @@ -1032,9 +1032,6 @@ void GCTAModelBackground::set_spatial(const GCTAObservation& obs, const std::str |
| 1032 | 1032 | int ny = background.axis(1); |
| 1033 | 1033 | int n_energies = background.axis(2); |
| 1034 | 1034 | |
| 1035 | - // Set interpolation to logscale for energies | |
| 1036 | - background.axis_log10(2); | |
| 1037 | - | |
| 1038 | 1035 | // retrieve spatial bounds |
| 1039 | 1036 | double xlow = background.axis_lo(0,0); |
| 1040 | 1037 | double xhigh = background.axis_hi(0,background.axis(0)-1); |
| ... | ... | @@ -1047,16 +1044,22 @@ void GCTAModelBackground::set_spatial(const GCTAObservation& obs, const std::str |
| 1047 | 1044 | |
| 1048 | 1045 | // Loop over energies |
| 1049 | 1046 | for(int i=0;i<n_energies;i++) { |
| 1047 | + | |
| 1050 | 1048 | // First create ebounds to get the logarithmic mean between two energies |
| 1051 | - // TODO: simplify | |
| 1052 | 1049 | ebounds.append(GEnergy(background.axis_lo(2,i),"TeV"), GEnergy(background.axis_hi(2,i),"TeV")); |
| 1050 | + | |
| 1051 | + // Append mean log energy to energies container | |
| 1053 | 1052 | energies.append(ebounds.elogmean(i)); |
| 1054 | 1053 | |
| 1055 | 1054 | } // endfor: loop over energies |
| 1056 | 1055 | |
| 1056 | + | |
| 1057 | + // Set interpolation to logscale for energies | |
| 1058 | + background.axis_log10(2); | |
| 1059 | + | |
| 1057 | 1060 | // creating the sky map |
| 1058 | - double bin_size_x = ( xhigh - xlow ) / nx; | |
| 1059 | - double bin_size_y = ( yhigh - ylow ) / ny; | |
| 1061 | + double bin_size_x = ( xhigh - xlow ) / nx * gammalib::rad2deg; | |
| 1062 | + double bin_size_y = ( yhigh - ylow ) / ny * gammalib::rad2deg; | |
| 1060 | 1063 | |
| 1061 | 1064 | GSkymap cube = GSkymap("TAN","CEL",pntdir.ra_deg(),pntdir.dec_deg(),-1*bin_size_x,bin_size_y,nx,ny,ebounds.size()); |
| 1062 | 1065 | |
| ... | ... | @@ -1066,40 +1069,42 @@ void GCTAModelBackground::set_spatial(const GCTAObservation& obs, const std::str |
| 1066 | 1069 | // Get sky direction from pixel number |
| 1067 | 1070 | GSkyDir pix_dir = cube.inx2dir(i); |
| 1068 | 1071 | |
| 1069 | - // Retrieve coordinate vector, implying radec system for rotation matrix | |
| 1070 | 1072 | // Get celestial vector from sky coordinate |
| 1071 | - GVector celvector = pntdir.celvector(); | |
| 1073 | + GVector celvector = pix_dir.celvector(); | |
| 1072 | 1074 | |
| 1073 | 1075 | // Transform to instrument system |
| 1074 | 1076 | GVector inst = rot * celvector; |
| 1075 | 1077 | |
| 1078 | + // Initialise instrument coordinates | |
| 1076 | 1079 | double x_inst = 0.0; |
| 1077 | 1080 | double y_inst = 0.0; |
| 1078 | 1081 | |
| 1082 | + // Get offset from cel vector, i.e. distance from camera center | |
| 1079 | 1083 | double theta = std::acos(inst[2]); |
| 1080 | 1084 | |
| 1085 | + // Check if theta and phi are defined | |
| 1081 | 1086 | if ( theta > 0.0 ) { |
| 1082 | 1087 | |
| 1083 | 1088 | double phi = std::asin( inst[1] / std::sin(theta) ); |
| 1084 | - | |
| 1085 | 1089 | x_inst = theta * std::cos(phi); |
| 1086 | 1090 | y_inst = theta * std::sin(phi); |
| 1087 | 1091 | } |
| 1088 | 1092 | |
| 1089 | - | |
| 1090 | - //GVector native(-cos_phi*m_sin_theta, sin_phi*m_sin_theta, m_cos_theta); | |
| 1091 | - | |
| 1092 | - // loop on the energy map | |
| 1093 | + // loop on the energy map | |
| 1093 | 1094 | for(int j = 0 ; j < energies.size(); j++) { |
| 1094 | 1095 | |
| 1095 | 1096 | // Determine background value in instrument system for given |
| 1096 | 1097 | std::vector<double> value = background(x_inst, y_inst, energies[j].log10TeV()); |
| 1098 | + | |
| 1099 | + // Set skymap value | |
| 1097 | 1100 | cube(i,j) = value[0]; |
| 1098 | 1101 | |
| 1099 | 1102 | } // endfor: loop over energies |
| 1100 | 1103 | |
| 1101 | 1104 | } // endfor: loop over sky bins |
| 1102 | 1105 | |
| 1106 | + cube.save("test_cube.fits",true); | |
| 1107 | + | |
| 1103 | 1108 | // Create the GModelSpatialDiffuseCube |
| 1104 | 1109 | m_spatial = new GModelSpatialDiffuseCube(cube,energies); |
| 1105 | 1110 | ... | ... |
inst/cta/src/GCTAResponseTable.cpp
| ... | ... | @@ -328,7 +328,7 @@ std::vector<double> GCTAResponseTable::operator()(const double& arg1, |
| 328 | 328 | m_wgt7 * m_pars[i][m_inx7] + |
| 329 | 329 | m_wgt8 * m_pars[i][m_inx8] ; |
| 330 | 330 | } |
| 331 | - | |
| 331 | + | |
| 332 | 332 | // Return result vector |
| 333 | 333 | return result; |
| 334 | 334 | } |
| ... | ... | @@ -459,6 +459,7 @@ double GCTAResponseTable::operator()(const int& index, const double& arg1, |
| 459 | 459 | m_wgt8 * m_pars[index][m_inx8]; |
| 460 | 460 | |
| 461 | 461 | |
| 462 | + | |
| 462 | 463 | // Return result |
| 463 | 464 | return result; |
| 464 | 465 | } |
| ... | ... | @@ -1343,6 +1344,7 @@ void GCTAResponseTable::update(const double& arg1, const double& arg2, const dou |
| 1343 | 1344 | nodes2->set_value(arg2); |
| 1344 | 1345 | nodes3->set_value(arg3); |
| 1345 | 1346 | |
| 1347 | + //std::cout<<"X="<<arg1<<" "<<nodes1->inx_left()<<" "<<nodes1->inx_right() <<std::endl; | |
| 1346 | 1348 | // Compute offsets |
| 1347 | 1349 | int size1 = axis(0); |
| 1348 | 1350 | int size2 = axis(1); |
| ... | ... | @@ -1371,7 +1373,7 @@ void GCTAResponseTable::update(const double& arg1, const double& arg2, const dou |
| 1371 | 1373 | m_wgt6 = nodes1->wgt_right() * nodes2->wgt_left() * nodes3->wgt_right(); |
| 1372 | 1374 | m_wgt7 = nodes1->wgt_right() * nodes2->wgt_right()* nodes3->wgt_left() ; |
| 1373 | 1375 | m_wgt8 = nodes1->wgt_right() * nodes2->wgt_right()* nodes3->wgt_right(); |
| 1374 | - | |
| 1376 | + | |
| 1375 | 1377 | // Return |
| 1376 | 1378 | return; |
| 1377 | 1379 | } | ... | ... |
inst/cta/test/data/bg_test.fits
No preview for this file type