Commit 3130ffb6c0b393d0dcd9971d2e34285ee77f6146
1 parent
b95897e9
fixed bug in pointing interpolation (now gives reasonable answers in test case)
Showing
5 changed files
with
55 additions
and
8 deletions
include/GHorizDir.hpp
| @@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
| 31 | #include <string> | 31 | #include <string> |
| 32 | #include "GBase.hpp" | 32 | #include "GBase.hpp" |
| 33 | #include "GVector.hpp" | 33 | #include "GVector.hpp" |
| 34 | +#include "GMath.hpp" | ||
| 34 | 35 | ||
| 35 | /* __ Compile options ____________________________________________________ */ | 36 | /* __ Compile options ____________________________________________________ */ |
| 36 | #define G_SINCOS_CACHE | 37 | #define G_SINCOS_CACHE |
inst/cta/include/GCTAPointing.hpp
| @@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
| 33 | #include "GTime.hpp" | 33 | #include "GTime.hpp" |
| 34 | #include "GMatrix.hpp" | 34 | #include "GMatrix.hpp" |
| 35 | #include "GNodeArray.hpp" | 35 | #include "GNodeArray.hpp" |
| 36 | +#include "GHorizDir.hpp" | ||
| 36 | 37 | ||
| 37 | /***********************************************************************//** | 38 | /***********************************************************************//** |
| 38 | * @class GCTAPointing | 39 | * @class GCTAPointing |
| @@ -91,8 +92,10 @@ protected: | @@ -91,8 +92,10 @@ protected: | ||
| 91 | 92 | ||
| 92 | bool m_has_table; //!< table is loaded | 93 | bool m_has_table; //!< table is loaded |
| 93 | GNodeArray m_table_nodes; | 94 | GNodeArray m_table_nodes; |
| 94 | - std::vector<double> m_table_az; | ||
| 95 | - std::vector<double> m_table_alt; | 95 | + std::vector<double> m_table_az; //!< table of azimuths (rad) |
| 96 | + std::vector<double> m_table_alt; //!< table of altitudes (rad) | ||
| 97 | + GTime m_table_tmin; //!< min time bound in table | ||
| 98 | + GTime m_table_tmax; //!<max time bound in table | ||
| 96 | 99 | ||
| 97 | // Cached members | 100 | // Cached members |
| 98 | mutable bool m_has_cache; //!< Has transformation cache | 101 | mutable bool m_has_cache; //!< Has transformation cache |
inst/cta/src/GCTAPointing.cpp
| @@ -68,8 +68,11 @@ GCTAPointing::load_pointing_table(std::string filename) | @@ -68,8 +68,11 @@ GCTAPointing::load_pointing_table(std::string filename) | ||
| 68 | GFitsTableCol *stop = (*table)["STOP"]; | 68 | GFitsTableCol *stop = (*table)["STOP"]; |
| 69 | GFitsTableCol *alt = (*table)["ALT_PNT"]; | 69 | GFitsTableCol *alt = (*table)["ALT_PNT"]; |
| 70 | GFitsTableCol *az = (*table)["AZ_PNT"]; | 70 | GFitsTableCol *az = (*table)["AZ_PNT"]; |
| 71 | - // GFitsTableCol *ra = (*table)["RA_PNT"]; | ||
| 72 | - //GFitsTableCol *dec = (*table)["DEC_PNT"]; | 71 | + |
| 72 | + // later on, may also interpolate RA/Dec, in the case of a drift | ||
| 73 | + // scan or other tracking mode: | ||
| 74 | + // GFitsTableCol *ra = (*table)["RA_PNT"]; | ||
| 75 | + // GFitsTableCol *dec = (*table)["DEC_PNT"]; | ||
| 73 | 76 | ||
| 74 | 77 | ||
| 75 | // Loop over the elements and build a lookup table: | 78 | // Loop over the elements and build a lookup table: |
| @@ -79,7 +82,7 @@ GCTAPointing::load_pointing_table(std::string filename) | @@ -79,7 +82,7 @@ GCTAPointing::load_pointing_table(std::string filename) | ||
| 79 | 82 | ||
| 80 | for (size_t ii=0; ii < table->nrows(); ii++) { | 83 | for (size_t ii=0; ii < table->nrows(); ii++) { |
| 81 | 84 | ||
| 82 | - double midtime = 0.5*(stop->real(ii) - start->real(ii)); | 85 | + double midtime = 0.5*(stop->real(ii) + start->real(ii)); |
| 83 | GTime tt(midtime, "sec" ); | 86 | GTime tt(midtime, "sec" ); |
| 84 | m_table_nodes.append( tt.secs() ); | 87 | m_table_nodes.append( tt.secs() ); |
| 85 | m_table_az[ii] = az->real(ii) * gammalib::deg2rad; | 88 | m_table_az[ii] = az->real(ii) * gammalib::deg2rad; |
inst/cta/test/test_CTA.cpp
| @@ -187,7 +187,11 @@ void TestGCTAPointing::set(void) | @@ -187,7 +187,11 @@ void TestGCTAPointing::set(void) | ||
| 187 | name("GCTAPointing"); | 187 | name("GCTAPointing"); |
| 188 | 188 | ||
| 189 | // Append tests to test suite | 189 | // Append tests to test suite |
| 190 | - append(static_cast<pfunction>(&TestGCTAPointing::test_load_table), "Test load pointing from table"); | 190 | + append(static_cast<pfunction>(&TestGCTAPointing::test_load_table), |
| 191 | + "Test load pointing from table"); | ||
| 192 | + | ||
| 193 | + append(static_cast<pfunction>(&TestGCTAPointing::test_interpolate_altaz), | ||
| 194 | + "Test alt/az interpolation given a time"); | ||
| 191 | 195 | ||
| 192 | return; | 196 | return; |
| 193 | } | 197 | } |
| @@ -206,9 +210,8 @@ TestGCTAPointing* TestGCTAPointing::clone(void) const | @@ -206,9 +210,8 @@ TestGCTAPointing* TestGCTAPointing::clone(void) const | ||
| 206 | 210 | ||
| 207 | 211 | ||
| 208 | /***********************************************************************//** | 212 | /***********************************************************************//** |
| 209 | - * @brief Test CTA Npred computation | 213 | + * @brief Test ability to load a CTA pointing table |
| 210 | * | 214 | * |
| 211 | - | ||
| 212 | ***************************************************************************/ | 215 | ***************************************************************************/ |
| 213 | void TestGCTAPointing::test_load_table(void) | 216 | void TestGCTAPointing::test_load_table(void) |
| 214 | { | 217 | { |
| @@ -221,6 +224,42 @@ void TestGCTAPointing::test_load_table(void) | @@ -221,6 +224,42 @@ void TestGCTAPointing::test_load_table(void) | ||
| 221 | 224 | ||
| 222 | 225 | ||
| 223 | /***********************************************************************//** | 226 | /***********************************************************************//** |
| 227 | + * @brief Test interpolation of alt/az pointing dir as a function of | ||
| 228 | + * time | ||
| 229 | + * | ||
| 230 | + ***************************************************************************/ | ||
| 231 | +void TestGCTAPointing::test_interpolate_altaz(void) | ||
| 232 | +{ | ||
| 233 | + | ||
| 234 | + GCTAObservation run; | ||
| 235 | + | ||
| 236 | + GCTAPointing pnt; | ||
| 237 | + pnt.load_pointing_table( cta_point_table ); | ||
| 238 | + | ||
| 239 | + // test an out-of bounds time | ||
| 240 | + | ||
| 241 | + | ||
| 242 | + try { | ||
| 243 | + GTime time(155470378.7, "sec"); | ||
| 244 | + GHorizDir dir = pnt.dir_horiz( time ); | ||
| 245 | + } | ||
| 246 | + catch (GException::out_of_range &exc) { | ||
| 247 | + std::cout << exc.what() << std::endl; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + // Get a time that is somewhere in the run: | ||
| 251 | + | ||
| 252 | + GTime time(155470378.7, "sec"); | ||
| 253 | + GHorizDir dir = pnt.dir_horiz( time ); | ||
| 254 | + | ||
| 255 | + std::cout << "time="<<time<<" dir="<<dir<<std::endl; | ||
| 256 | + | ||
| 257 | + return; | ||
| 258 | +} | ||
| 259 | + | ||
| 260 | + | ||
| 261 | + | ||
| 262 | +/***********************************************************************//** | ||
| 224 | * @brief Test CTA Aeff computation | 263 | * @brief Test CTA Aeff computation |
| 225 | ***************************************************************************/ | 264 | ***************************************************************************/ |
| 226 | void TestGCTAResponse::test_response_aeff(void) | 265 | void TestGCTAResponse::test_response_aeff(void) |
inst/cta/test/test_CTA.hpp
| @@ -137,6 +137,7 @@ public: | @@ -137,6 +137,7 @@ public: | ||
| 137 | virtual void set(void); | 137 | virtual void set(void); |
| 138 | virtual TestGCTAPointing* clone(void) const; | 138 | virtual TestGCTAPointing* clone(void) const; |
| 139 | void test_load_table(void); | 139 | void test_load_table(void); |
| 140 | + void test_interpolate_altaz(void); | ||
| 140 | }; | 141 | }; |
| 141 | 142 | ||
| 142 | 143 |