Commit 4e802a0ad5f5f1c2b6f768da5336d655f48feaf1

Authored by Karl Kosack
1 parent 96016512

add small test case for GHorizDir

include/GHorizDir.hpp
@@ -71,10 +71,10 @@ public: @@ -71,10 +71,10 @@ public:
71 void altaz_deg(const double& alt, const double& az); 71 void altaz_deg(const double& alt, const double& az);
72 void celvector(const GVector& vector); 72 void celvector(const GVector& vector);
73 void rotate_deg(const double& phi, const double& theta); 73 void rotate_deg(const double& phi, const double& theta);
74 - const double& alt(void) const;  
75 - const double& az(void) const;  
76 - double zenith() const;  
77 - double zenith_deg() const; 74 + const double& alt(void) const { return m_alt; }
  75 + const double& az(void) const { return m_az; }
  76 + double zenith(void) const;
  77 + double zenith_deg(void) const;
78 double alt_deg(void) const; 78 double alt_deg(void) const;
79 double az_deg(void) const; 79 double az_deg(void) const;
80 GVector celvector(void) const; 80 GVector celvector(void) const;
@@ -125,7 +125,20 @@ inline @@ -125,7 +125,20 @@ inline
125 double GHorizDir::zenith_deg() const 125 double GHorizDir::zenith_deg() const
126 { 126 {
127 return zenith() * gammalib::rad2deg; 127 return zenith() * gammalib::rad2deg;
128 -}; 128 +}
  129 +
  130 +
  131 +inline
  132 +double GHorizDir::alt_deg() const
  133 +{
  134 + return m_alt * gammalib::rad2deg;
  135 +}
  136 +
  137 +inline
  138 +double GHorizDir::az_deg() const
  139 +{
  140 + return m_az * gammalib::rad2deg;
  141 +}
129 142
130 143
131 #endif /* GHORIZDIR_HPP */ 144 #endif /* GHORIZDIR_HPP */
src/sky/GHorizDir.cpp
@@ -195,8 +195,8 @@ void GHorizDir::altaz_deg(const double& alt, const double& az) @@ -195,8 +195,8 @@ void GHorizDir::altaz_deg(const double& alt, const double& az)
195 { 195 {
196 196
197 // Set direction 197 // Set direction
198 - m_az = alt * gammalib::deg2rad;  
199 - m_alt = az * gammalib::deg2rad; 198 + m_az = az * gammalib::deg2rad;
  199 + m_alt = alt * gammalib::deg2rad;
200 200
201 // Return 201 // Return
202 return; 202 return;
test/test_GSky.cpp
@@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
34 #include "test_GSky.hpp" 34 #include "test_GSky.hpp"
35 #include "GTools.hpp" 35 #include "GTools.hpp"
36 36
  37 +
37 /* __ Namespaces _________________________________________________________ */ 38 /* __ Namespaces _________________________________________________________ */
38 39
39 /* __ Globals ____________________________________________________________ */ 40 /* __ Globals ____________________________________________________________ */
@@ -47,10 +48,10 @@ @@ -47,10 +48,10 @@
47 * @brief Set parameters and tests 48 * @brief Set parameters and tests
48 ***************************************************************************/ 49 ***************************************************************************/
49 void TestGSky::set(void){ 50 void TestGSky::set(void){
50 - 51 +
51 // Test name 52 // Test name
52 name("GSky"); 53 name("GSky");
53 - 54 +
54 // Append tests 55 // Append tests
55 append(static_cast<pfunction>(&TestGSky::test_GWcs),"Test GWcs"); 56 append(static_cast<pfunction>(&TestGSky::test_GWcs),"Test GWcs");
56 append(static_cast<pfunction>(&TestGSky::test_GSkyPixel),"Test GSkyPixel"); 57 append(static_cast<pfunction>(&TestGSky::test_GSkyPixel),"Test GSkyPixel");
@@ -61,6 +62,7 @@ void TestGSky::set(void){ @@ -61,6 +62,7 @@ void TestGSky::set(void){
61 append(static_cast<pfunction>(&TestGSky::test_GSkyRegions_io),"Test GSkyRegions"); 62 append(static_cast<pfunction>(&TestGSky::test_GSkyRegions_io),"Test GSkyRegions");
62 append(static_cast<pfunction>(&TestGSky::test_GSkyRegionCircle_construct),"Test GSkyRegionCircle constructors"); 63 append(static_cast<pfunction>(&TestGSky::test_GSkyRegionCircle_construct),"Test GSkyRegionCircle constructors");
63 append(static_cast<pfunction>(&TestGSky::test_GSkyRegionCircle_logic),"Test GSkyRegionCircle logic"); 64 append(static_cast<pfunction>(&TestGSky::test_GSkyRegionCircle_logic),"Test GSkyRegionCircle logic");
  65 + append(static_cast<pfunction>(&TestGSky::test_GHorizDir),"Test GHorizDir");
64 66
65 // Return 67 // Return
66 return; 68 return;
@@ -92,10 +94,10 @@ double TestGSky::wcs_forth_back_pixel(GWcs* wcs, int nx, int ny, double&amp; crpix1, @@ -92,10 +94,10 @@ double TestGSky::wcs_forth_back_pixel(GWcs* wcs, int nx, int ny, double&amp; crpix1,
92 { 94 {
93 // Initialise maximal distance 95 // Initialise maximal distance
94 double dist_max = 0.0; 96 double dist_max = 0.0;
95 - 97 +
96 // Loop over x pixels 98 // Loop over x pixels
97 for (int ix = -nx; ix <= nx; ++ix) { 99 for (int ix = -nx; ix <= nx; ++ix) {
98 - 100 +
99 // Set x value 101 // Set x value
100 double x = double(ix) + crpix1; 102 double x = double(ix) + crpix1;
101 103
@@ -955,7 +957,7 @@ void TestGSky::test_GSkyRegionCircle_logic(void) @@ -955,7 +957,7 @@ void TestGSky::test_GSkyRegionCircle_logic(void)
955 /*************************************************************************** 957 /***************************************************************************
956 * @brief Test GSkyRegions input and output 958 * @brief Test GSkyRegions input and output
957 ***************************************************************************/ 959 ***************************************************************************/
958 -void TestGSky::test_GSkyRegions_io(void) 960 + void TestGSky::test_GSkyRegions_io(void)
959 { 961 {
960 // Set filenames 962 // Set filenames
961 const std::string filename = "data/test_circle_region.reg"; 963 const std::string filename = "data/test_circle_region.reg";
@@ -1009,8 +1011,34 @@ void TestGSky::test_GSkyRegions_io(void) @@ -1009,8 +1011,34 @@ void TestGSky::test_GSkyRegions_io(void)
1009 1011
1010 // Exit test 1012 // Exit test
1011 return; 1013 return;
  1014 +
1012 } 1015 }
1013 1016
  1017 +void TestGSky::test_GHorizDir(void){
  1018 +
  1019 + GHorizDir nulldir;
  1020 +
  1021 + GHorizDir altaz;
  1022 + double testalt = 45.0;
  1023 + double testaz = 180.0;
  1024 + altaz.altaz_deg( testalt, testaz );
  1025 +
  1026 +
  1027 + double newalt = altaz.alt_deg();
  1028 + double newaz = altaz.az_deg();
  1029 +
  1030 + // std::cout << altaz << std::endl;
  1031 + // std::cout << newalt << "," << testalt << std::endl;
  1032 + // std::cout << newaz << "," << testaz << std::endl;
  1033 +
  1034 + test_value( newalt, testalt,1e-10,"ALT" );
  1035 + test_value( newaz, testaz,1e-10,"AZ" );
  1036 + test_value( altaz.zenith_deg(), 90-testalt,"ZENITH" );
  1037 +
  1038 +
  1039 + return;
  1040 +}
  1041 +
1014 1042
1015 /*************************************************************************** 1043 /***************************************************************************
1016 * @brief Main test function 1044 * @brief Main test function
@@ -1018,13 +1046,13 @@ void TestGSky::test_GSkyRegions_io(void) @@ -1018,13 +1046,13 @@ void TestGSky::test_GSkyRegions_io(void)
1018 int main(void) 1046 int main(void)
1019 { 1047 {
1020 GTestSuites testsuites("GSky"); 1048 GTestSuites testsuites("GSky");
1021 - 1049 +
1022 bool was_successful=true; 1050 bool was_successful=true;
1023 - 1051 +
1024 //Create a test suite 1052 //Create a test suite
1025 TestGSky test; 1053 TestGSky test;
1026 -  
1027 - //Append to the container 1054 +
  1055 + //Append to the container
1028 testsuites.append(test); 1056 testsuites.append(test);
1029 1057
1030 //Run 1058 //Run
test/test_GSky.hpp
@@ -25,7 +25,6 @@ @@ -25,7 +25,6 @@
25 /* __ Includes ___________________________________________________________ */ 25 /* __ Includes ___________________________________________________________ */
26 #include "GammaLib.hpp" 26 #include "GammaLib.hpp"
27 27
28 -  
29 /***********************************************************************//** 28 /***********************************************************************//**
30 * @class TestGSky 29 * @class TestGSky
31 * 30 *
@@ -50,6 +49,7 @@ public: @@ -50,6 +49,7 @@ public:
50 void test_GSkyRegions_io(void); 49 void test_GSkyRegions_io(void);
51 void test_GSkyRegionCircle_construct(void); 50 void test_GSkyRegionCircle_construct(void);
52 void test_GSkyRegionCircle_logic(void); 51 void test_GSkyRegionCircle_logic(void);
  52 + void test_GHorizDir(void);
53 53
54 // Private methods 54 // Private methods
55 private: 55 private: