Commit bf33a8509ee8a7b92ae3d76e46afdf0cb985640f

Authored by knodlseder
1 parent 93aba6b9

implement coordinate testing

Showing 1 changed file with 37 additions and 1 deletions
test/test_GSky.cpp
... ... @@ -17,6 +17,9 @@
17 17 */
18 18  
19 19 /* __ Includes ___________________________________________________________ */
  20 +#ifdef HAVE_CONFIG_H
  21 +#include <config.h>
  22 +#endif
20 23 #include <stdlib.h>
21 24 #include "test_GSky.hpp"
22 25  
... ... @@ -285,6 +288,9 @@ void test_GSkymap_healpix_io(void)
285 288 ***************************************************************************/
286 289 void test_GSkymap_map_construct(void)
287 290 {
  291 + // Set precision
  292 + double eps = 1.0e-10;
  293 +
288 294 // Dump header
289 295 std::cout << "Test non Healpix GSkymap constructors: ";
290 296  
... ... @@ -301,10 +307,39 @@ void test_GSkymap_map_construct(void)
301 307 }
302 308 std::cout << ".";
303 309  
304   - // Test correct Healpix constructors
  310 + // Test non-Healpix constructors
305 311 try {
306 312 GSkymap map1("CAR", "GAL", 0.0, 0.0, 1.0, 1.0, 100, 100);
  313 + }
  314 + catch (std::exception &e) {
  315 + std::cout << std::endl
  316 + << "TEST ERROR: Unable to construct sky map(s)."
  317 + << std::endl;
  318 + std::cout << e.what() << std::endl;
  319 + throw;
  320 + }
  321 + std::cout << ".";
  322 +
  323 + // Test CAR projection
  324 + try {
  325 + GSkymap map1("CAR", "GAL", 138.817, 37.293, 0.521, 0.931, 100, 100);
307 326 std::cout << map1 << std::endl;
  327 + GSkyDir dir;
  328 + for (int l = -179; l < 179; ++l) {
  329 + for (int b = -89; b < 89; ++b) {
  330 + dir.lb_deg(double(l),double(b));
  331 + GSkyPixel pixel = map1.dir2xy(dir);
  332 + GSkyDir dir_back = map1.xy2dir(pixel);
  333 + double dl = dir.l_deg() - dir_back.l_deg();
  334 + double db = dir.b_deg() - dir_back.b_deg();
  335 + if (fabs(dl) > eps || fabs(db) > eps) {
  336 + std::cout << std::endl
  337 + << "TEST ERROR: Sky direction differs: dir="
  338 + << dir << " dir_back=" << dir_back << std::endl;
  339 + throw;
  340 + }
  341 + }
  342 + }
308 343 }
309 344 catch (std::exception &e) {
310 345 std::cout << std::endl
... ... @@ -315,6 +350,7 @@ std::cout &lt;&lt; map1 &lt;&lt; std::endl;
315 350 }
316 351 std::cout << ".";
317 352  
  353 +
318 354 // Signal final test success
319 355 std::cout << " ok." << std::endl;
320 356  
... ...