Commit 4e802a0ad5f5f1c2b6f768da5336d655f48feaf1
1 parent
96016512
add small test case for GHorizDir
Showing
4 changed files
with
58 additions
and
17 deletions
include/GHorizDir.hpp
| ... | ... | @@ -71,10 +71,10 @@ public: |
| 71 | 71 | void altaz_deg(const double& alt, const double& az); |
| 72 | 72 | void celvector(const GVector& vector); |
| 73 | 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 | 78 | double alt_deg(void) const; |
| 79 | 79 | double az_deg(void) const; |
| 80 | 80 | GVector celvector(void) const; |
| ... | ... | @@ -125,7 +125,20 @@ inline |
| 125 | 125 | double GHorizDir::zenith_deg() const |
| 126 | 126 | { |
| 127 | 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 | 144 | #endif /* GHORIZDIR_HPP */ | ... | ... |
src/sky/GHorizDir.cpp
| ... | ... | @@ -195,8 +195,8 @@ void GHorizDir::altaz_deg(const double& alt, const double& az) |
| 195 | 195 | { |
| 196 | 196 | |
| 197 | 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 | 201 | // Return |
| 202 | 202 | return; | ... | ... |
test/test_GSky.cpp
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include "test_GSky.hpp" |
| 35 | 35 | #include "GTools.hpp" |
| 36 | 36 | |
| 37 | + | |
| 37 | 38 | /* __ Namespaces _________________________________________________________ */ |
| 38 | 39 | |
| 39 | 40 | /* __ Globals ____________________________________________________________ */ |
| ... | ... | @@ -47,10 +48,10 @@ |
| 47 | 48 | * @brief Set parameters and tests |
| 48 | 49 | ***************************************************************************/ |
| 49 | 50 | void TestGSky::set(void){ |
| 50 | - | |
| 51 | + | |
| 51 | 52 | // Test name |
| 52 | 53 | name("GSky"); |
| 53 | - | |
| 54 | + | |
| 54 | 55 | // Append tests |
| 55 | 56 | append(static_cast<pfunction>(&TestGSky::test_GWcs),"Test GWcs"); |
| 56 | 57 | append(static_cast<pfunction>(&TestGSky::test_GSkyPixel),"Test GSkyPixel"); |
| ... | ... | @@ -61,6 +62,7 @@ void TestGSky::set(void){ |
| 61 | 62 | append(static_cast<pfunction>(&TestGSky::test_GSkyRegions_io),"Test GSkyRegions"); |
| 62 | 63 | append(static_cast<pfunction>(&TestGSky::test_GSkyRegionCircle_construct),"Test GSkyRegionCircle constructors"); |
| 63 | 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 | 67 | // Return |
| 66 | 68 | return; |
| ... | ... | @@ -92,10 +94,10 @@ double TestGSky::wcs_forth_back_pixel(GWcs* wcs, int nx, int ny, double& crpix1, |
| 92 | 94 | { |
| 93 | 95 | // Initialise maximal distance |
| 94 | 96 | double dist_max = 0.0; |
| 95 | - | |
| 97 | + | |
| 96 | 98 | // Loop over x pixels |
| 97 | 99 | for (int ix = -nx; ix <= nx; ++ix) { |
| 98 | - | |
| 100 | + | |
| 99 | 101 | // Set x value |
| 100 | 102 | double x = double(ix) + crpix1; |
| 101 | 103 | |
| ... | ... | @@ -955,7 +957,7 @@ void TestGSky::test_GSkyRegionCircle_logic(void) |
| 955 | 957 | /*************************************************************************** |
| 956 | 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 | 962 | // Set filenames |
| 961 | 963 | const std::string filename = "data/test_circle_region.reg"; |
| ... | ... | @@ -1009,8 +1011,34 @@ void TestGSky::test_GSkyRegions_io(void) |
| 1009 | 1011 | |
| 1010 | 1012 | // Exit test |
| 1011 | 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 | 1044 | * @brief Main test function |
| ... | ... | @@ -1018,13 +1046,13 @@ void TestGSky::test_GSkyRegions_io(void) |
| 1018 | 1046 | int main(void) |
| 1019 | 1047 | { |
| 1020 | 1048 | GTestSuites testsuites("GSky"); |
| 1021 | - | |
| 1049 | + | |
| 1022 | 1050 | bool was_successful=true; |
| 1023 | - | |
| 1051 | + | |
| 1024 | 1052 | //Create a test suite |
| 1025 | 1053 | TestGSky test; |
| 1026 | - | |
| 1027 | - //Append to the container | |
| 1054 | + | |
| 1055 | + //Append to the container | |
| 1028 | 1056 | testsuites.append(test); |
| 1029 | 1057 | |
| 1030 | 1058 | //Run | ... | ... |
test/test_GSky.hpp
| ... | ... | @@ -25,7 +25,6 @@ |
| 25 | 25 | /* __ Includes ___________________________________________________________ */ |
| 26 | 26 | #include "GammaLib.hpp" |
| 27 | 27 | |
| 28 | - | |
| 29 | 28 | /***********************************************************************//** |
| 30 | 29 | * @class TestGSky |
| 31 | 30 | * |
| ... | ... | @@ -50,6 +49,7 @@ public: |
| 50 | 49 | void test_GSkyRegions_io(void); |
| 51 | 50 | void test_GSkyRegionCircle_construct(void); |
| 52 | 51 | void test_GSkyRegionCircle_logic(void); |
| 52 | + void test_GHorizDir(void); | |
| 53 | 53 | |
| 54 | 54 | // Private methods |
| 55 | 55 | private: | ... | ... |