Commit 3ce50cc3866df0919310741eaa8ed8fb83042e31
1 parent
9d9f61df
Add GWcsGLS and GWcsSFL classes to support GLS and SFL WCS (#1851)
Showing
23 changed files
with
1260 additions
and
233 deletions
ChangeLog
NEWS
| 1 | -New Features and Important Changes in GammaLib 1.2.0 | |
| 1 | +New Features and Important Changes in GammaLib 1.3.0 | |
| 2 | 2 | |
| 3 | -3 February 2017 | |
| 3 | +15 March 2017 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | 1. Introduction |
| ... | ... | @@ -12,121 +12,39 @@ made since the last release of GammaLib. |
| 12 | 12 | 2. Public interface modifications |
| 13 | 13 | --------------------------------- |
| 14 | 14 | The following classes have been added: |
| 15 | -- GModelSpectralExpInvPlaw | |
| 16 | -- GModelSpectralPlawEnergyFlux | |
| 17 | -- GModelSpectralMultiplicative | |
| 18 | -- GModelSpectralComposite | |
| 19 | -- GModelSpatialComposite | |
| 20 | -- GModelTemporalLightCurve | |
| 21 | -- GModelTemporalPhaseCurve | |
| 22 | -- GVOTable | |
| 23 | -- GNdarray | |
| 24 | -- GFft | |
| 25 | -- GFftWavetable | |
| 15 | +- GWcsGLS | |
| 16 | +- GWcsSFL | |
| 26 | 17 | |
| 27 | 18 | The following classes have been removed: |
| 28 | 19 | - ... |
| 29 | 20 | |
| 30 | 21 | The following classes have been renamed: |
| 31 | -- GModelSpectralPlawPhotonFlux, was GModelSpectralPlaw2 | |
| 22 | +- ... | |
| 32 | 23 | |
| 33 | 24 | The following methods have been added: |
| 34 | -- GApplication::log_string() | |
| 35 | -- GApplication::log_value() | |
| 36 | -- GApplication::log_header1() | |
| 37 | -- GApplication::log_header2() | |
| 38 | -- GApplication::log_header3() | |
| 39 | -- GApplication::operator[](const int& index) | |
| 40 | -- GApplication::pars() | |
| 41 | -- GApplicationPar::current_value() | |
| 42 | -- GLog::is_open() | |
| 43 | -- GLog::is_empty() | |
| 44 | -- GLog::written_size() | |
| 45 | -- GSkyMap::is_empty() | |
| 46 | -- GTime::jd(const std::string& timesys) | |
| 47 | -- GTime::mjd(const std::string& timesys) | |
| 48 | -- GTime::secs(const std::string& timesys) | |
| 49 | -- GTime::days(const std::string& timesys) | |
| 50 | -- GTime::jd(const double& time, const std::string& timesys) | |
| 51 | -- GTime::mjd(const double& time, const std::string& timesys) | |
| 52 | -- GTime::secs(const double& time, const std::string& timesys) | |
| 53 | -- GTime::days(const double& time, const std::string& timesys) | |
| 54 | -- GTime::gmst() | |
| 55 | -- GTime::gast() | |
| 56 | -- GTime::lmst(const double& geolon) | |
| 57 | -- GTime::last(const double& geolon) | |
| 58 | -- GTime::now() | |
| 59 | -- GFits::publish() | |
| 60 | -- gammalib::rstrip_chars() | |
| 61 | -- GObservations::save_covmat() | |
| 62 | -- GModelSpatial::region() | |
| 63 | -- GSkyMap(const GFitsHDU&) | |
| 25 | +- ... | |
| 64 | 26 | |
| 65 | 27 | The following methods have been removed: |
| 66 | -- <all classes>::eval_gradients() | |
| 67 | - The eval_gradients() methods duplicate much of the code of the eval() | |
| 68 | - methods. To increase the maintainability of the code, the eval_gradients() | |
| 69 | - methods have been removed, and the computation of partial derivatives is | |
| 70 | - now done by the eval() methods if the optional gradients argument is set | |
| 71 | - to true. | |
| 28 | +- ... | |
| 72 | 29 | |
| 73 | 30 | The following methods have been renamed: |
| 74 | -- GModelSpectralPlawPhotonFlux::flux(), was GModelSpectralPlaw2::integral() | |
| 75 | -- GLog::buffer_size(), was GLog::max_size() | |
| 31 | +- ... | |
| 76 | 32 | |
| 77 | 33 | The arguments for the following methods have been changed: |
| 78 | -- GApplication::log_parameters() now has a mandatory GChatter argument | |
| 79 | -- <all classes>::eval() has now an optional gradients parameter (see above) | |
| 34 | +- ... | |
| 80 | 35 | |
| 81 | 36 | The return value of the following methods has been changed: |
| 82 | -- GSkyMap::write() now returns a pointer to GFitsHDU instead of void | |
| 37 | +- ... | |
| 83 | 38 | |
| 84 | 39 | |
| 85 | 40 | 3. Configuration |
| 86 | 41 | ----------------- |
| 87 | -The Python wrappers were always removed when typing "make clean", even if | |
| 88 | -they had been shipped with the code. Now, the Python wrappers are only | |
| 89 | -removed in a "make clean" if they have been built (#1826). | |
| 42 | +None | |
| 90 | 43 | |
| 91 | 44 | |
| 92 | 45 | 4. Application module |
| 93 | 46 | --------------------- |
| 94 | -The GApplication::log_parameters() method now takes a mandatory GChatter | |
| 95 | -argument to enable displaying of parameters only above a given chattiness | |
| 96 | -level. This avoids a log-level check in the client code. For the same | |
| 97 | -purpose, the GApplication methods log_string(), log_value(), log_header1(), | |
| 98 | -log_header2(), and log_header3() have been introduced. There are three | |
| 99 | -variants of log_value() for strings, integers and double precision values | |
| 100 | -(#1828). | |
| 101 | - | |
| 102 | -The application name and version and now conserved in a GApplication::clear() | |
| 103 | -method call and the application is properly initialised like in the call of | |
| 104 | -a constructor (#1835). | |
| 105 | - | |
| 106 | -The GLog::copy_members() method simply copied the file pointer, hence after | |
| 107 | -a copy of a log instance there were two instances holding the same pointer | |
| 108 | -to the file, and as soon as one instance closes the log file the file | |
| 109 | -pointer in the second instance became invalid. This has been fixed by | |
| 110 | -duplicating the file descriptor and opening the log file in the copied | |
| 111 | -instance using the duplicated descriptor. This solves the problems (#1823). | |
| 112 | - | |
| 113 | -A GLog::is_open() method has been added to assess whether a log file is | |
| 114 | -actually opened. The GLog::is_empty() method has been added to assess whether | |
| 115 | -a log file is actually empty (#1837). | |
| 116 | - | |
| 117 | -The GLog::size() method now returns the actual size of the log file, including | |
| 118 | -the number of characters on disk. | |
| 119 | - | |
| 120 | -The GLog::max_size() method has been renamed to GLog::buffer_size since this | |
| 121 | -is more explicit (#1837). | |
| 122 | - | |
| 123 | -GApplication::pars() methods have been added to allow to retrieve or to set all | |
| 124 | -application parameters. The GApplicationPar::current_value() method has been | |
| 125 | -added to retrieve the current parameter value without querying for the parameter | |
| 126 | -(#1838). | |
| 127 | - | |
| 128 | -Operators have been added to GApplication that allow the access of application | |
| 129 | -parameters by index (#1838). | |
| 47 | +None | |
| 130 | 48 | |
| 131 | 49 | |
| 132 | 50 | 5. Base module |
| ... | ... | @@ -136,9 +54,7 @@ None |
| 136 | 54 | |
| 137 | 55 | 6. FITS I/O Interface |
| 138 | 56 | --------------------- |
| 139 | -Add GFits::publish() methods that publish a FITS HDU to an Virtual Observatory | |
| 140 | -hub. If the FITS HDU is an image it will be published as a FITS image, which | |
| 141 | -table HDUs will be published as VO tables (#1231). | |
| 57 | +None | |
| 142 | 58 | |
| 143 | 59 | |
| 144 | 60 | 7. Linear algebra module |
| ... | ... | @@ -148,77 +64,17 @@ None |
| 148 | 64 | |
| 149 | 65 | 8. Model module |
| 150 | 66 | --------------- |
| 151 | -The GModelSpectralPlaw2 class has been renamed to GModelSpectralPlawPhotonFlux | |
| 152 | -and the integral() methods were renamed to flux(). A new class | |
| 153 | -GModelSpectralPlawEnergyFlux has been added that handles integral energy | |
| 154 | -fluxes as opposed to GModelSpectralPlawPhotonFlux that handles integral | |
| 155 | -photon fluxes. Unit tests have been added for the new class (#1790). | |
| 156 | - | |
| 157 | -The GModelSpectralExpInvPlaw class has been added that uses a cut-off | |
| 158 | -parameter instead of a cut-off energy for the exponentially cut-off | |
| 159 | -power law. The cut-off parameter is the inverse of the cut-off energy | |
| 160 | -(#1800). | |
| 161 | - | |
| 162 | -The GModelSpectralMultiplicative class has been added that implements the | |
| 163 | -product of spectral model components as a new spectral model (#1861). | |
| 164 | - | |
| 165 | -The GModelSpectralComposite and GModelSpatialComposite classes have been | |
| 166 | -added that implement composite spectral and spatial models, which are sums | |
| 167 | -of models as a new model component (#1706). | |
| 168 | - | |
| 169 | -A region() method has been added to the GModelSpatial base class and all | |
| 170 | -derived classes that returns a pointer to a sky region that bounds the | |
| 171 | -spatial model. For the moment, only circular sky regions have been | |
| 172 | -implemented (#1764). | |
| 173 | - | |
| 174 | -The GModelTemporalLightCurve class has been added to implement a light | |
| 175 | -curve as temporal component of a model. The light curve is defined by | |
| 176 | -nodes in a FITS file. It can be used for the simulation of transient | |
| 177 | -sources. A unit test has been added and the mc() and eval() methods | |
| 178 | -have been validated using a dedicated test script (#1914). | |
| 179 | - | |
| 180 | -The GModelSpatialDiffuseMap::mc and GModelSpatialDiffuseCube::mc methods | |
| 181 | -now throw an GException::invalid_return_value exception that is catched | |
| 182 | -in the GModelSky::mc method and leads to the skipping of the concerned | |
| 183 | -photon. This allows handling of empty diffuse maps or map cubes (#1915). | |
| 184 | - | |
| 185 | -The GModelTemporalPhaseCurve class has been added to impelement a phase | |
| 186 | -curve as temporal component of a model. The phase curve can be used to | |
| 187 | -model pulsar light curves or the temporal variation of gamma-ray binaries | |
| 188 | -(#1916). | |
| 67 | +None | |
| 189 | 68 | |
| 190 | 69 | |
| 191 | 70 | 9. Numerics module |
| 192 | 71 | ------------------ |
| 193 | -The GNdarray class has been added that implements a n-dimensional double | |
| 194 | -precision floating point array (#1768). | |
| 195 | - | |
| 196 | -The GFft class has been added that performs a Fast Fourier Transformation | |
| 197 | -of a n-dimensional array. The GFftWavetable class is a support class for | |
| 198 | -GFft that provides the trigonometric coefficients for a factorisation. For | |
| 199 | -the moment, GFft does only support 1-dimensional and 2-dimensional arrays | |
| 200 | -(#1731). | |
| 72 | +None | |
| 201 | 73 | |
| 202 | 74 | |
| 203 | 75 | 10. Observation module |
| 204 | 76 | ---------------------- |
| 205 | -Time setting and getting methods for Julian Days, Modified Julian Days, | |
| 206 | -native seconds and native days are now available in the GTime class that | |
| 207 | -allow specifying the time system. Currently, TT, TAI and UTC are supported. | |
| 208 | -Methods have also been added to the GTime class that return the Greenwich | |
| 209 | -mean and apparent siderial times, and the local mean and apparent siderial | |
| 210 | -times that depend on the geographic longitude. Finally, a now() method has | |
| 211 | -been added to the GTime class that sets the time to the current time (see | |
| 212 | -#1856). | |
| 213 | - | |
| 214 | -The GObservations::save_covmat() method computes and saves the covariance | |
| 215 | -matrix into a FITS file (#1863). | |
| 216 | - | |
| 217 | -A leap second has been added to GTime::leap_seconds() for 1 January 2017 | |
| 218 | -(#1887). | |
| 219 | - | |
| 220 | -The handling of time references was corrected in GGti::extend() so that | |
| 221 | -times now reflect correctly any changes in the time reference (#1922). | |
| 77 | +None | |
| 222 | 78 | |
| 223 | 79 | |
| 224 | 80 | 11. Optimization module |
| ... | ... | @@ -228,26 +84,13 @@ None |
| 228 | 84 | |
| 229 | 85 | 12. Sky module |
| 230 | 86 | -------------- |
| 231 | -The GSkyMap::write() method now returns a pointer to the written GFitsHDU | |
| 232 | -object. In case that no sky map is written, for example because none has been | |
| 233 | -defined so far, the method returns NONE. The GSkyMap::publish() method will | |
| 234 | -detect the NONE value and will do nothing if no sky map exists (#1835). | |
| 235 | - | |
| 236 | -The GSkyMap::is_empty() method signals whether a sky map contains no pixels | |
| 237 | -or no maps (#1828). | |
| 238 | - | |
| 239 | -A FITS HDU constructor was added to the GSkyMap class that allows constructing | |
| 240 | -a sky map from a FITS HDU. | |
| 87 | +The GWcsGLS and GWcsSFL classes have been added to support the GLS and SFL | |
| 88 | +World Coordinate System projections (#1851). | |
| 241 | 89 | |
| 242 | 90 | |
| 243 | 91 | 13. Support module |
| 244 | 92 | ------------------ |
| 245 | -The gammalib::rstrip_chars() function has been added to right strip characters | |
| 246 | -from a string. | |
| 247 | - | |
| 248 | -The gammalib::str() functions for single and double precision floating point | |
| 249 | -numbers now have an increased precision so that significant digits are no | |
| 250 | -longer lost. | |
| 93 | +None | |
| 251 | 94 | |
| 252 | 95 | |
| 253 | 96 | 14. XML module |
| ... | ... | @@ -257,9 +100,7 @@ None |
| 257 | 100 | |
| 258 | 101 | 15. VO module |
| 259 | 102 | ------------- |
| 260 | -A GVOTable class has been added that allows handling of VO tables, including | |
| 261 | -transformation of FITS tables into VO tables and sending VO tables through the | |
| 262 | -VO hub to other applications (#1231). | |
| 103 | +None | |
| 263 | 104 | |
| 264 | 105 | |
| 265 | 106 | 16. Xspec module |
| ... | ... | @@ -269,10 +110,7 @@ None |
| 269 | 110 | |
| 270 | 111 | 17. Test module |
| 271 | 112 | --------------- |
| 272 | -A GTestSuite::test_value() method for double precision values has been added | |
| 273 | -that automatically requires a relative precision of 1.0e-7. The default value | |
| 274 | -for "eps" has been removed from the former double precision test_value() | |
| 275 | -method. This should allow writing of more compact unit tests. | |
| 113 | +None | |
| 276 | 114 | |
| 277 | 115 | |
| 278 | 116 | 18. Multi-wavelength interface |
| ... | ... | @@ -287,18 +125,7 @@ None |
| 287 | 125 | |
| 288 | 126 | 20. CTA interface |
| 289 | 127 | ----------------- |
| 290 | -The dimension of response tables is now checked for being consistent with the | |
| 291 | -axis dimension (#1848). | |
| 292 | - | |
| 293 | -The formula for the containment radius computation in GCTAPsf2D::containment_radius | |
| 294 | -was wrong and has been corrected (#1876). | |
| 295 | - | |
| 296 | -The GCTABackground3D::mc() method now verifies that the specified energy is within | |
| 297 | -the validity range of the background template. Otherwise an exception is thrown | |
| 298 | -(#1918). | |
| 299 | - | |
| 300 | -Observations with zero livetime are now skipped in building the cubes for stacked | |
| 301 | -analysis for CTA (#1920). | |
| 128 | +None | |
| 302 | 129 | |
| 303 | 130 | |
| 304 | 131 | 21. COMPTEL interface | ... | ... |
doc/source/users/user_manual/modules/uml_sky.png
include/GWcsGLS.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GWcsGLS.hpp - Global Sinusoidal (GLS) projection class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2017 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GWcsGLS.hpp | |
| 23 | + * @brief Global Sinusoidal (GLS) projection class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GWCSGLS_HPP | |
| 28 | +#define GWCSGLS_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <string> | |
| 32 | +#include "GWcsSFL.hpp" | |
| 33 | + | |
| 34 | + | |
| 35 | +/***********************************************************************//** | |
| 36 | + * @class GWcsGLS | |
| 37 | + * | |
| 38 | + * @brief Global Sinusoidal (GLS) projection class definition | |
| 39 | + * | |
| 40 | + * This class implements the Global Sinusoidal projection for the World | |
| 41 | + * Coordinate System. The Global Sinusoidal projection is an alias of the | |
| 42 | + * Sanson-Flamsteed projection, and the GWcsGLS therefore derives from the | |
| 43 | + * GWcsSFL class. | |
| 44 | + ***************************************************************************/ | |
| 45 | +class GWcsGLS : public GWcsSFL { | |
| 46 | + | |
| 47 | +public: | |
| 48 | + // Constructors and destructors | |
| 49 | + GWcsGLS(void); | |
| 50 | + GWcsGLS(const std::string& coords, | |
| 51 | + const double& crval1, const double& crval2, | |
| 52 | + const double& crpix1, const double& crpix2, | |
| 53 | + const double& cdelt1, const double& cdelt2); | |
| 54 | + GWcsGLS(const GWcsGLS& wcs); | |
| 55 | + virtual ~GWcsGLS(void); | |
| 56 | + | |
| 57 | + // Operators | |
| 58 | + GWcsGLS& operator=(const GWcsGLS& wcs); | |
| 59 | + | |
| 60 | + // Implemented pure virtual base class methods | |
| 61 | + virtual void clear(void); | |
| 62 | + virtual GWcsGLS* clone(void) const; | |
| 63 | + virtual std::string classname(void) const; | |
| 64 | + virtual std::string code(void) const; | |
| 65 | + virtual std::string name(void) const; | |
| 66 | + virtual std::string print(const GChatter& chatter = NORMAL) const; | |
| 67 | + | |
| 68 | +protected: | |
| 69 | + // Private methods | |
| 70 | + void init_members(void); | |
| 71 | + void copy_members(const GWcsGLS& wcs); | |
| 72 | + void free_members(void); | |
| 73 | +}; | |
| 74 | + | |
| 75 | + | |
| 76 | +/***********************************************************************//** | |
| 77 | + * @brief Return class name | |
| 78 | + * | |
| 79 | + * @return String containing the class name ("GWcsGLS"). | |
| 80 | + ***************************************************************************/ | |
| 81 | +inline | |
| 82 | +std::string GWcsGLS::classname(void) const | |
| 83 | +{ | |
| 84 | + return ("GWcsGLS"); | |
| 85 | +} | |
| 86 | + | |
| 87 | + | |
| 88 | +/***********************************************************************//** | |
| 89 | + * @brief Return projection code | |
| 90 | + * | |
| 91 | + * @return Projection code. | |
| 92 | + * | |
| 93 | + * Returns the projection code "GLS". | |
| 94 | + ***************************************************************************/ | |
| 95 | +inline | |
| 96 | +std::string GWcsGLS::code(void) const | |
| 97 | +{ | |
| 98 | + return "GLS"; | |
| 99 | +} | |
| 100 | + | |
| 101 | + | |
| 102 | +/***********************************************************************//** | |
| 103 | + * @brief Return projection name | |
| 104 | + * | |
| 105 | + * @return Projection name. | |
| 106 | + * | |
| 107 | + * Returns the projection name. | |
| 108 | + ***************************************************************************/ | |
| 109 | +inline | |
| 110 | +std::string GWcsGLS::name(void) const | |
| 111 | +{ | |
| 112 | + return "Global Sinusoidal"; | |
| 113 | +} | |
| 114 | + | |
| 115 | +#endif /* GWCSGLS_HPP */ | ... | ... |
include/GWcsSFL.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GWcsSFL.hpp - Sanson-Flamsteed (SFL) projection class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2017 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GWcsSFL.hpp | |
| 23 | + * @brief Sanson-Flamsteed (SFL) projection class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GWCSSFL_HPP | |
| 28 | +#define GWCSSFL_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <string> | |
| 32 | +#include "GWcs.hpp" | |
| 33 | + | |
| 34 | + | |
| 35 | +/***********************************************************************//** | |
| 36 | + * @class GWcsSFL | |
| 37 | + * | |
| 38 | + * @brief Sanson-Flamsteed (SFL) projection class definition | |
| 39 | + * | |
| 40 | + * This class implements the Sanson-Flamsteed projection for the World | |
| 41 | + * Coordinate System. | |
| 42 | + ***************************************************************************/ | |
| 43 | +class GWcsSFL : public GWcs { | |
| 44 | + | |
| 45 | +public: | |
| 46 | + // Constructors and destructors | |
| 47 | + GWcsSFL(void); | |
| 48 | + GWcsSFL(const std::string& coords, | |
| 49 | + const double& crval1, const double& crval2, | |
| 50 | + const double& crpix1, const double& crpix2, | |
| 51 | + const double& cdelt1, const double& cdelt2); | |
| 52 | + GWcsSFL(const GWcsSFL& wcs); | |
| 53 | + virtual ~GWcsSFL(void); | |
| 54 | + | |
| 55 | + // Operators | |
| 56 | + GWcsSFL& operator=(const GWcsSFL& wcs); | |
| 57 | + | |
| 58 | + // Implemented pure virtual base class methods | |
| 59 | + virtual void clear(void); | |
| 60 | + virtual GWcsSFL* clone(void) const; | |
| 61 | + virtual std::string classname(void) const; | |
| 62 | + virtual std::string code(void) const; | |
| 63 | + virtual std::string name(void) const; | |
| 64 | + virtual std::string print(const GChatter& chatter = NORMAL) const; | |
| 65 | + | |
| 66 | +protected: | |
| 67 | + // Protected methods | |
| 68 | + void init_members(void); | |
| 69 | + void copy_members(const GWcsSFL& wcs); | |
| 70 | + void free_members(void); | |
| 71 | + void prj_set(void) const; | |
| 72 | + void prj_x2s(int nx, int ny, int sxy, int spt, | |
| 73 | + const double* x, const double* y, | |
| 74 | + double* phi, double* theta, int* stat) const; | |
| 75 | + void prj_s2x(int nphi, int ntheta, int spt, int sxy, | |
| 76 | + const double* phi, const double* theta, | |
| 77 | + double* x, double* y, int* stat) const; | |
| 78 | +}; | |
| 79 | + | |
| 80 | + | |
| 81 | +/***********************************************************************//** | |
| 82 | + * @brief Return class name | |
| 83 | + * | |
| 84 | + * @return String containing the class name ("GWcsSFL"). | |
| 85 | + ***************************************************************************/ | |
| 86 | +inline | |
| 87 | +std::string GWcsSFL::classname(void) const | |
| 88 | +{ | |
| 89 | + return ("GWcsSFL"); | |
| 90 | +} | |
| 91 | + | |
| 92 | + | |
| 93 | +/***********************************************************************//** | |
| 94 | + * @brief Return projection code | |
| 95 | + * | |
| 96 | + * @return Projection code. | |
| 97 | + * | |
| 98 | + * Returns the projection code "SFL". | |
| 99 | + ***************************************************************************/ | |
| 100 | +inline | |
| 101 | +std::string GWcsSFL::code(void) const | |
| 102 | +{ | |
| 103 | + return "SFL"; | |
| 104 | +} | |
| 105 | + | |
| 106 | + | |
| 107 | +/***********************************************************************//** | |
| 108 | + * @brief Return projection name | |
| 109 | + * | |
| 110 | + * @return Projection name. | |
| 111 | + * | |
| 112 | + * Returns the projection name. | |
| 113 | + ***************************************************************************/ | |
| 114 | +inline | |
| 115 | +std::string GWcsSFL::name(void) const | |
| 116 | +{ | |
| 117 | + return "Sanson-Flamsteed"; | |
| 118 | +} | |
| 119 | + | |
| 120 | +#endif /* GWCSSFL_HPP */ | ... | ... |
include/GammaLib.hpp
| ... | ... | @@ -156,9 +156,11 @@ |
| 156 | 156 | #include "GWcsAIT.hpp" |
| 157 | 157 | #include "GWcsAZP.hpp" |
| 158 | 158 | #include "GWcsCAR.hpp" |
| 159 | +#include "GWcsGLS.hpp" | |
| 159 | 160 | #include "GWcsMER.hpp" |
| 160 | 161 | #include "GWcsMOL.hpp" |
| 161 | 162 | #include "GWcsSIN.hpp" |
| 163 | +#include "GWcsSFL.hpp" | |
| 162 | 164 | #include "GWcsSTG.hpp" |
| 163 | 165 | #include "GWcsTAN.hpp" |
| 164 | 166 | ... | ... |
include/Makefile.am
| ... | ... | @@ -118,9 +118,11 @@ pkginclude_HEADERS = GammaLib.hpp \ |
| 118 | 118 | GWcsAIT.hpp \ |
| 119 | 119 | GWcsAZP.hpp \ |
| 120 | 120 | GWcsCAR.hpp \ |
| 121 | + GWcsGLS.hpp \ | |
| 121 | 122 | GWcsMER.hpp \ |
| 122 | 123 | GWcsMOL.hpp \ |
| 123 | 124 | GWcsSIN.hpp \ |
| 125 | + GWcsSFL.hpp \ | |
| 124 | 126 | GWcsSTG.hpp \ |
| 125 | 127 | GWcsTAN.hpp \ |
| 126 | 128 | GEnergy.hpp \ | ... | ... |
pyext/GWcsGLS.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GWcsGLS.i - Global Sinusoidal (GLS) projection class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2017 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GWcsGLS.i | |
| 23 | + * @brief Global Sinusoidal (GLS) projection class Python interface | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | +%{ | |
| 27 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 28 | +#include "GWcsGLS.hpp" | |
| 29 | +%} | |
| 30 | + | |
| 31 | + | |
| 32 | +/***********************************************************************//** | |
| 33 | + * @class GWcsGLS | |
| 34 | + * | |
| 35 | + * @brief Global Sinusoidal (GLS) projection class definition | |
| 36 | + ***************************************************************************/ | |
| 37 | +class GWcsGLS : public GWcsSFL { | |
| 38 | + | |
| 39 | +public: | |
| 40 | + // Constructors and destructors | |
| 41 | + GWcsGLS(void); | |
| 42 | + GWcsGLS(const std::string& coords, | |
| 43 | + const double& crval1, const double& crval2, | |
| 44 | + const double& crpix1, const double& crpix2, | |
| 45 | + const double& cdelt1, const double& cdelt2); | |
| 46 | + GWcsGLS(const GWcsGLS& wcs); | |
| 47 | + virtual ~GWcsGLS(void); | |
| 48 | + | |
| 49 | + // Implemented pure virtual methods | |
| 50 | + virtual void clear(void); | |
| 51 | + virtual GWcsGLS* clone(void) const; | |
| 52 | + virtual std::string classname(void) const; | |
| 53 | + virtual std::string code(void) const; | |
| 54 | + virtual std::string name(void) const; | |
| 55 | +}; | |
| 56 | + | |
| 57 | + | |
| 58 | +/***********************************************************************//** | |
| 59 | + * @brief GWcsGLS class extension | |
| 60 | + ***************************************************************************/ | |
| 61 | +%extend GWcsGLS { | |
| 62 | + GWcsGLS copy() { | |
| 63 | + return (*self); | |
| 64 | + } | |
| 65 | +}; | ... | ... |
pyext/GWcsSFL.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GWcsSFL.i - Sanson-Flamsteed (SFL) projection class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2017 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GWcsSFL.i | |
| 23 | + * @brief Sanson-Flamsteed (SFL) projection class Python interface | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | +%{ | |
| 27 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 28 | +#include "GWcsSFL.hpp" | |
| 29 | +%} | |
| 30 | + | |
| 31 | + | |
| 32 | +/***********************************************************************//** | |
| 33 | + * @class GWcsSFL | |
| 34 | + * | |
| 35 | + * @brief Sanson-Flamsteed (SFL) projection class definition | |
| 36 | + ***************************************************************************/ | |
| 37 | +class GWcsSFL : public GWcs { | |
| 38 | +public: | |
| 39 | + // Constructors and destructors | |
| 40 | + GWcsSFL(void); | |
| 41 | + GWcsSFL(const std::string& coords, | |
| 42 | + const double& crval1, const double& crval2, | |
| 43 | + const double& crpix1, const double& crpix2, | |
| 44 | + const double& cdelt1, const double& cdelt2); | |
| 45 | + GWcsSFL(const GWcsSFL& wcs); | |
| 46 | + virtual ~GWcsSFL(void); | |
| 47 | + | |
| 48 | + // Implemented pure virtual methods | |
| 49 | + virtual void clear(void); | |
| 50 | + virtual GWcsSFL* clone(void) const; | |
| 51 | + virtual std::string classname(void) const; | |
| 52 | + virtual std::string code(void) const; | |
| 53 | + virtual std::string name(void) const; | |
| 54 | +}; | |
| 55 | + | |
| 56 | + | |
| 57 | +/***********************************************************************//** | |
| 58 | + * @brief GWcsSFL class extension | |
| 59 | + ***************************************************************************/ | |
| 60 | +%extend GWcsSFL { | |
| 61 | + GWcsSFL copy() { | |
| 62 | + return (*self); | |
| 63 | + } | |
| 64 | +}; | ... | ... |
pyext/gammalib/sky.i
| ... | ... | @@ -122,8 +122,10 @@ namespace std { |
| 122 | 122 | %include "GWcsAIT.i" |
| 123 | 123 | %include "GWcsAZP.i" |
| 124 | 124 | %include "GWcsCAR.i" |
| 125 | +%include "GWcsGLS.i" | |
| 125 | 126 | %include "GWcsMER.i" |
| 126 | 127 | %include "GWcsMOL.i" |
| 128 | +%include "GWcsSFL.i" | |
| 127 | 129 | %include "GWcsSIN.i" |
| 128 | 130 | %include "GWcsSTG.i" |
| 129 | 131 | %include "GWcsTAN.i" | ... | ... |
src/sky/GWcs.cpp
| ... | ... | @@ -920,8 +920,9 @@ void GWcs::copy_members(const GWcs& wcs) |
| 920 | 920 | m_x0 = wcs.m_x0; |
| 921 | 921 | m_y0 = wcs.m_y0; |
| 922 | 922 | m_w = wcs.m_w; |
| 923 | - for (int i = 0; i < PVN; ++i) | |
| 923 | + for (int i = 0; i < PVN; ++i) { | |
| 924 | 924 | m_pv[i] = wcs.m_pv[i]; |
| 925 | + } | |
| 925 | 926 | |
| 926 | 927 | // Return |
| 927 | 928 | return; |
| ... | ... | @@ -1147,7 +1148,12 @@ void GWcs::wcs_set(void) const |
| 1147 | 1148 | |
| 1148 | 1149 | //TODO: Do we have PVi_ma keyvalues? |
| 1149 | 1150 | |
| 1150 | - //TODO: Do simple alias translations | |
| 1151 | + // Do simple alias translations | |
| 1152 | + if (code() == "GLS") { | |
| 1153 | + m_offset = true; | |
| 1154 | + m_phi0 = 0.0; | |
| 1155 | + m_theta0 = m_crval[m_lat]; | |
| 1156 | + } | |
| 1151 | 1157 | |
| 1152 | 1158 | // Initialize the celestial transformation routines |
| 1153 | 1159 | m_r0 = 0.0; // Forces initialisation | ... | ... |
src/sky/GWcsAIT.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsAIT.cpp - Aitoff (AIT) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -302,6 +302,10 @@ void GWcsAIT::free_members(void) |
| 302 | 302 | ***************************************************************************/ |
| 303 | 303 | void GWcsAIT::prj_set(void) const |
| 304 | 304 | { |
| 305 | + // Signal that projection has been set (needs to be done before calling | |
| 306 | + // the prj_off() method to avoid an endless loop) | |
| 307 | + m_prjset = true; | |
| 308 | + | |
| 305 | 309 | // Initialise projection parameters |
| 306 | 310 | m_w.assign(4, 0.0); |
| 307 | 311 | |
| ... | ... | @@ -319,9 +323,6 @@ void GWcsAIT::prj_set(void) const |
| 319 | 323 | // Compute fiducial offset |
| 320 | 324 | prj_off(0.0, 0.0); |
| 321 | 325 | |
| 322 | - // Signal that projection has been set | |
| 323 | - m_prjset = true; | |
| 324 | - | |
| 325 | 326 | // Return |
| 326 | 327 | return; |
| 327 | 328 | } | ... | ... |
src/sky/GWcsAZP.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsAZP.cpp - Zenithal/azimuthal perspective (AZP) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -309,8 +309,12 @@ void GWcsAZP::free_members(void) |
| 309 | 309 | ***************************************************************************/ |
| 310 | 310 | void GWcsAZP::prj_set(void) const |
| 311 | 311 | { |
| 312 | + // Signal that projection has been set (needs to be done before calling | |
| 313 | + // the prj_off() method to avoid an endless loop) | |
| 314 | + m_prjset = true; | |
| 315 | + | |
| 312 | 316 | // Initialise projection parameters |
| 313 | - m_w.assign(8,0.0); | |
| 317 | + m_w.assign(8, 0.0); | |
| 314 | 318 | |
| 315 | 319 | // Set undefined parameters |
| 316 | 320 | if (undefined(m_pv[1])) m_pv[1] = 0.0; |
| ... | ... | @@ -343,9 +347,6 @@ void GWcsAZP::prj_set(void) const |
| 343 | 347 | // Compute fiducial offset |
| 344 | 348 | prj_off(0.0, 90.0); |
| 345 | 349 | |
| 346 | - // Signal that projection has been set | |
| 347 | - m_prjset = true; | |
| 348 | - | |
| 349 | 350 | // Return |
| 350 | 351 | return; |
| 351 | 352 | } | ... | ... |
src/sky/GWcsCAR.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsCAR.cpp - Plate carree (CAR) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2013 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2017 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -290,6 +290,10 @@ void GWcsCAR::free_members(void) |
| 290 | 290 | ***************************************************************************/ |
| 291 | 291 | void GWcsCAR::prj_set(void) const |
| 292 | 292 | { |
| 293 | + // Signal that projection has been set (needs to be done before calling | |
| 294 | + // the prj_off() method to avoid an endless loop) | |
| 295 | + m_prjset = true; | |
| 296 | + | |
| 293 | 297 | // Initialise projection parameters |
| 294 | 298 | m_w.clear(); |
| 295 | 299 | |
| ... | ... | @@ -307,9 +311,6 @@ void GWcsCAR::prj_set(void) const |
| 307 | 311 | // Compute fiducial offset |
| 308 | 312 | prj_off(0.0, 0.0); |
| 309 | 313 | |
| 310 | - // Signal that projection has been set | |
| 311 | - m_prjset = true; | |
| 312 | - | |
| 313 | 314 | // Return |
| 314 | 315 | return; |
| 315 | 316 | } | ... | ... |
src/sky/GWcsGLS.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GWcsGLS.cpp - Global Sinusoidal (GLS) projection class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2017 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GWcsGLS.cpp | |
| 23 | + * @brief Global Sinusoidal (GLS) projection class implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include "GException.hpp" | |
| 32 | +#include "GMath.hpp" | |
| 33 | +#include "GWcsGLS.hpp" | |
| 34 | +#include "GWcsRegistry.hpp" | |
| 35 | + | |
| 36 | +/* __ Method name definitions ____________________________________________ */ | |
| 37 | + | |
| 38 | +/* __ Macros _____________________________________________________________ */ | |
| 39 | + | |
| 40 | +/* __ Coding definitions _________________________________________________ */ | |
| 41 | + | |
| 42 | +/* __ Debug definitions __________________________________________________ */ | |
| 43 | + | |
| 44 | +/* __ Local prototypes ___________________________________________________ */ | |
| 45 | + | |
| 46 | +/* __ Constants __________________________________________________________ */ | |
| 47 | + | |
| 48 | +/* __ Globals ____________________________________________________________ */ | |
| 49 | +const GWcsGLS g_wcs_gls_seed; | |
| 50 | +const GWcsRegistry g_wcs_gls_registry(&g_wcs_gls_seed); | |
| 51 | + | |
| 52 | + | |
| 53 | +/*========================================================================== | |
| 54 | + = = | |
| 55 | + = Constructors/destructors = | |
| 56 | + = = | |
| 57 | + ==========================================================================*/ | |
| 58 | + | |
| 59 | +/***********************************************************************//** | |
| 60 | + * @brief Void constructor | |
| 61 | + ***************************************************************************/ | |
| 62 | +GWcsGLS::GWcsGLS(void) : GWcsSFL() | |
| 63 | +{ | |
| 64 | + // Initialise class members | |
| 65 | + init_members(); | |
| 66 | + | |
| 67 | + // Return | |
| 68 | + return; | |
| 69 | +} | |
| 70 | + | |
| 71 | + | |
| 72 | +/***********************************************************************//** | |
| 73 | + * @brief Projection constructor | |
| 74 | + * | |
| 75 | + * @param[in] coords Coordinate system. | |
| 76 | + * @param[in] crval1 X value of reference pixel. | |
| 77 | + * @param[in] crval2 Y value of reference pixel. | |
| 78 | + * @param[in] crpix1 X index of reference pixel (starting from 1). | |
| 79 | + * @param[in] crpix2 Y index of reference pixel (starting from 1). | |
| 80 | + * @param[in] cdelt1 Increment in x direction at reference pixel [deg]. | |
| 81 | + * @param[in] cdelt2 Increment in y direction at reference pixel [deg]. | |
| 82 | + ***************************************************************************/ | |
| 83 | +GWcsGLS::GWcsGLS(const std::string& coords, | |
| 84 | + const double& crval1, const double& crval2, | |
| 85 | + const double& crpix1, const double& crpix2, | |
| 86 | + const double& cdelt1, const double& cdelt2) : | |
| 87 | + GWcsSFL(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2) | |
| 88 | +{ | |
| 89 | + // Initialise class members | |
| 90 | + init_members(); | |
| 91 | + | |
| 92 | + // Return | |
| 93 | + return; | |
| 94 | +} | |
| 95 | + | |
| 96 | + | |
| 97 | +/***********************************************************************//** | |
| 98 | + * @brief Copy constructor | |
| 99 | + * | |
| 100 | + * @param[in] wcs World Coordinate System. | |
| 101 | + ***************************************************************************/ | |
| 102 | +GWcsGLS::GWcsGLS(const GWcsGLS& wcs) : GWcsSFL(wcs) | |
| 103 | +{ | |
| 104 | + // Initialise class members for clean destruction | |
| 105 | + init_members(); | |
| 106 | + | |
| 107 | + // Copy members | |
| 108 | + copy_members(wcs); | |
| 109 | + | |
| 110 | + // Return | |
| 111 | + return; | |
| 112 | +} | |
| 113 | + | |
| 114 | + | |
| 115 | +/***********************************************************************//** | |
| 116 | + * @brief Destructor | |
| 117 | + ***************************************************************************/ | |
| 118 | +GWcsGLS::~GWcsGLS(void) | |
| 119 | +{ | |
| 120 | + // Free members | |
| 121 | + free_members(); | |
| 122 | + | |
| 123 | + // Return | |
| 124 | + return; | |
| 125 | +} | |
| 126 | + | |
| 127 | + | |
| 128 | +/*========================================================================== | |
| 129 | + = = | |
| 130 | + = Operators = | |
| 131 | + = = | |
| 132 | + ==========================================================================*/ | |
| 133 | + | |
| 134 | +/***********************************************************************//** | |
| 135 | + * @brief Assignment operator | |
| 136 | + * | |
| 137 | + * @param[in] wcs World Coordinate System. | |
| 138 | + * @return World Coordinate System. | |
| 139 | + ***************************************************************************/ | |
| 140 | +GWcsGLS& GWcsGLS::operator=(const GWcsGLS& wcs) | |
| 141 | +{ | |
| 142 | + // Execute only if object is not identical | |
| 143 | + if (this != &wcs) { | |
| 144 | + | |
| 145 | + // Copy base class members | |
| 146 | + this->GWcsSFL::operator=(wcs); | |
| 147 | + | |
| 148 | + // Free members | |
| 149 | + free_members(); | |
| 150 | + | |
| 151 | + // Initialise private members for clean destruction | |
| 152 | + init_members(); | |
| 153 | + | |
| 154 | + // Copy members | |
| 155 | + copy_members(wcs); | |
| 156 | + | |
| 157 | + } // endif: object was not identical | |
| 158 | + | |
| 159 | + // Return this object | |
| 160 | + return *this; | |
| 161 | +} | |
| 162 | + | |
| 163 | + | |
| 164 | +/*========================================================================== | |
| 165 | + = = | |
| 166 | + = Public methods = | |
| 167 | + = = | |
| 168 | + ==========================================================================*/ | |
| 169 | + | |
| 170 | +/***********************************************************************//** | |
| 171 | + * @brief Clear Global Sinusoidal projection | |
| 172 | + * | |
| 173 | + * Resets the Global Sinusoidal projection to an clean initial state. | |
| 174 | + ***************************************************************************/ | |
| 175 | +void GWcsGLS::clear(void) | |
| 176 | +{ | |
| 177 | + // Free class members (base and derived classes, derived class first) | |
| 178 | + free_members(); | |
| 179 | + this->GWcsSFL::free_members(); | |
| 180 | + this->GWcs::free_members(); | |
| 181 | + this->GSkyProjection::free_members(); | |
| 182 | + | |
| 183 | + // Initialise members | |
| 184 | + this->GSkyProjection::init_members(); | |
| 185 | + this->GWcs::init_members(); | |
| 186 | + this->GWcsSFL::init_members(); | |
| 187 | + init_members(); | |
| 188 | + | |
| 189 | + // Return | |
| 190 | + return; | |
| 191 | +} | |
| 192 | + | |
| 193 | + | |
| 194 | +/***********************************************************************//** | |
| 195 | + * @brief Clone Global Sinusoidal projection | |
| 196 | + * | |
| 197 | + * @return Pointer to deep copy of Global Sinusoidal projection. | |
| 198 | + ***************************************************************************/ | |
| 199 | +GWcsGLS* GWcsGLS::clone(void) const | |
| 200 | +{ | |
| 201 | + return new GWcsGLS(*this); | |
| 202 | +} | |
| 203 | + | |
| 204 | + | |
| 205 | +/***********************************************************************//** | |
| 206 | + * @brief Print Global Sinusoidal projection information | |
| 207 | + * | |
| 208 | + * @param[in] chatter Chattiness. | |
| 209 | + * @return String containing Global Sinusoidal projection information. | |
| 210 | + ***************************************************************************/ | |
| 211 | +std::string GWcsGLS::print(const GChatter& chatter) const | |
| 212 | +{ | |
| 213 | + // Initialise result string | |
| 214 | + std::string result; | |
| 215 | + | |
| 216 | + // Continue only if chatter is not silent | |
| 217 | + if (chatter != SILENT) { | |
| 218 | + | |
| 219 | + // Append header | |
| 220 | + result.append("=== GWcsGLS ==="); | |
| 221 | + | |
| 222 | + // Append information | |
| 223 | + result.append(wcs_print(chatter)); | |
| 224 | + | |
| 225 | + } // endif: chatter was not silent | |
| 226 | + | |
| 227 | + // Return result | |
| 228 | + return result; | |
| 229 | +} | |
| 230 | + | |
| 231 | + | |
| 232 | +/*========================================================================== | |
| 233 | + = = | |
| 234 | + = Private methods = | |
| 235 | + = = | |
| 236 | + ==========================================================================*/ | |
| 237 | + | |
| 238 | +/***********************************************************************//** | |
| 239 | + * @brief Initialise class members | |
| 240 | + ***************************************************************************/ | |
| 241 | +void GWcsGLS::init_members(void) | |
| 242 | +{ | |
| 243 | + // Setup World Coordinate System | |
| 244 | + wcs_set(); | |
| 245 | + | |
| 246 | + // Return | |
| 247 | + return; | |
| 248 | +} | |
| 249 | + | |
| 250 | + | |
| 251 | +/***********************************************************************//** | |
| 252 | + * @brief Copy class members | |
| 253 | + * | |
| 254 | + * @param[in] wcs World Coordinate System. | |
| 255 | + ***************************************************************************/ | |
| 256 | +void GWcsGLS::copy_members(const GWcsGLS& wcs) | |
| 257 | +{ | |
| 258 | + // Return | |
| 259 | + return; | |
| 260 | +} | |
| 261 | + | |
| 262 | + | |
| 263 | +/***********************************************************************//** | |
| 264 | + * @brief Delete class members | |
| 265 | + ***************************************************************************/ | |
| 266 | +void GWcsGLS::free_members(void) | |
| 267 | +{ | |
| 268 | + // Return | |
| 269 | + return; | |
| 270 | +} | ... | ... |
src/sky/GWcsMER.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsMER.cpp - Mercator's (MER) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -290,6 +290,10 @@ void GWcsMER::free_members(void) |
| 290 | 290 | ***************************************************************************/ |
| 291 | 291 | void GWcsMER::prj_set(void) const |
| 292 | 292 | { |
| 293 | + // Signal that projection has been set (needs to be done before calling | |
| 294 | + // the prj_off() method to avoid an endless loop) | |
| 295 | + m_prjset = true; | |
| 296 | + | |
| 293 | 297 | // Initialise projection parameters |
| 294 | 298 | m_w.clear(); |
| 295 | 299 | |
| ... | ... | @@ -307,9 +311,6 @@ void GWcsMER::prj_set(void) const |
| 307 | 311 | // Compute fiducial offset |
| 308 | 312 | prj_off(0.0, 0.0); |
| 309 | 313 | |
| 310 | - // Signal that projection has been set | |
| 311 | - m_prjset = true; | |
| 312 | - | |
| 313 | 314 | // Return |
| 314 | 315 | return; |
| 315 | 316 | } | ... | ... |
src/sky/GWcsMOL.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsMOL.cpp - Mollweide's projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2015-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -301,6 +301,10 @@ void GWcsMOL::free_members(void) |
| 301 | 301 | ***************************************************************************/ |
| 302 | 302 | void GWcsMOL::prj_set(void) const |
| 303 | 303 | { |
| 304 | + // Signal that projection has been set (needs to be done before calling | |
| 305 | + // the prj_off() method to avoid an endless loop) | |
| 306 | + m_prjset = true; | |
| 307 | + | |
| 304 | 308 | // Initialise projection parameters |
| 305 | 309 | m_w.assign(5, 0.0); |
| 306 | 310 | |
| ... | ... | @@ -319,9 +323,6 @@ void GWcsMOL::prj_set(void) const |
| 319 | 323 | // Compute fiducial offset |
| 320 | 324 | prj_off(0.0, 0.0); |
| 321 | 325 | |
| 322 | - // Signal that projection has been set | |
| 323 | - m_prjset = true; | |
| 324 | - | |
| 325 | 326 | // Return |
| 326 | 327 | return; |
| 327 | 328 | } | ... | ... |
src/sky/GWcsSFL.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GWcsSFL.cpp - Sanson-Flamsteed (SFL) projection class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2017 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GWcsSFL.cpp | |
| 23 | + * @brief Sanson-Flamsteed (SFL) projection class implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include "GException.hpp" | |
| 32 | +#include "GMath.hpp" | |
| 33 | +#include "GWcsSFL.hpp" | |
| 34 | +#include "GWcsRegistry.hpp" | |
| 35 | + | |
| 36 | +/* __ Method name definitions ____________________________________________ */ | |
| 37 | +#define G_PRJ_X2S "GWcsSFL::prj_x2s(int, int, int, int, double*, double*,"\ | |
| 38 | + " double*, double*, int*)" | |
| 39 | + | |
| 40 | +/* __ Macros _____________________________________________________________ */ | |
| 41 | + | |
| 42 | +/* __ Coding definitions _________________________________________________ */ | |
| 43 | + | |
| 44 | +/* __ Debug definitions __________________________________________________ */ | |
| 45 | + | |
| 46 | +/* __ Local prototypes ___________________________________________________ */ | |
| 47 | + | |
| 48 | +/* __ Constants __________________________________________________________ */ | |
| 49 | + | |
| 50 | +/* __ Globals ____________________________________________________________ */ | |
| 51 | +const GWcsSFL g_wcs_sfl_seed; | |
| 52 | +const GWcsRegistry g_wcs_sfl_registry(&g_wcs_sfl_seed); | |
| 53 | + | |
| 54 | + | |
| 55 | +/*========================================================================== | |
| 56 | + = = | |
| 57 | + = Constructors/destructors = | |
| 58 | + = = | |
| 59 | + ==========================================================================*/ | |
| 60 | + | |
| 61 | +/***********************************************************************//** | |
| 62 | + * @brief Void constructor | |
| 63 | + ***************************************************************************/ | |
| 64 | +GWcsSFL::GWcsSFL(void) : GWcs() | |
| 65 | +{ | |
| 66 | + // Initialise class members | |
| 67 | + init_members(); | |
| 68 | + | |
| 69 | + // Return | |
| 70 | + return; | |
| 71 | +} | |
| 72 | + | |
| 73 | + | |
| 74 | +/***********************************************************************//** | |
| 75 | + * @brief Projection constructor | |
| 76 | + * | |
| 77 | + * @param[in] coords Coordinate system. | |
| 78 | + * @param[in] crval1 X value of reference pixel. | |
| 79 | + * @param[in] crval2 Y value of reference pixel. | |
| 80 | + * @param[in] crpix1 X index of reference pixel (starting from 1). | |
| 81 | + * @param[in] crpix2 Y index of reference pixel (starting from 1). | |
| 82 | + * @param[in] cdelt1 Increment in x direction at reference pixel [deg]. | |
| 83 | + * @param[in] cdelt2 Increment in y direction at reference pixel [deg]. | |
| 84 | + ***************************************************************************/ | |
| 85 | +GWcsSFL::GWcsSFL(const std::string& coords, | |
| 86 | + const double& crval1, const double& crval2, | |
| 87 | + const double& crpix1, const double& crpix2, | |
| 88 | + const double& cdelt1, const double& cdelt2) : | |
| 89 | + GWcs(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2) | |
| 90 | +{ | |
| 91 | + // Initialise class members | |
| 92 | + init_members(); | |
| 93 | + | |
| 94 | + // Return | |
| 95 | + return; | |
| 96 | +} | |
| 97 | + | |
| 98 | + | |
| 99 | +/***********************************************************************//** | |
| 100 | + * @brief Copy constructor | |
| 101 | + * | |
| 102 | + * @param[in] wcs World Coordinate System. | |
| 103 | + ***************************************************************************/ | |
| 104 | +GWcsSFL::GWcsSFL(const GWcsSFL& wcs) : GWcs(wcs) | |
| 105 | +{ | |
| 106 | + // Initialise class members for clean destruction | |
| 107 | + init_members(); | |
| 108 | + | |
| 109 | + // Copy members | |
| 110 | + copy_members(wcs); | |
| 111 | + | |
| 112 | + // Return | |
| 113 | + return; | |
| 114 | +} | |
| 115 | + | |
| 116 | + | |
| 117 | +/***********************************************************************//** | |
| 118 | + * @brief Destructor | |
| 119 | + ***************************************************************************/ | |
| 120 | +GWcsSFL::~GWcsSFL(void) | |
| 121 | +{ | |
| 122 | + // Free members | |
| 123 | + free_members(); | |
| 124 | + | |
| 125 | + // Return | |
| 126 | + return; | |
| 127 | +} | |
| 128 | + | |
| 129 | + | |
| 130 | +/*========================================================================== | |
| 131 | + = = | |
| 132 | + = Operators = | |
| 133 | + = = | |
| 134 | + ==========================================================================*/ | |
| 135 | + | |
| 136 | +/***********************************************************************//** | |
| 137 | + * @brief Assignment operator | |
| 138 | + * | |
| 139 | + * @param[in] wcs World Coordinate System. | |
| 140 | + * @return World Coordinate System. | |
| 141 | + ***************************************************************************/ | |
| 142 | +GWcsSFL& GWcsSFL::operator=(const GWcsSFL& wcs) | |
| 143 | +{ | |
| 144 | + // Execute only if object is not identical | |
| 145 | + if (this != &wcs) { | |
| 146 | + | |
| 147 | + // Copy base class members | |
| 148 | + this->GWcs::operator=(wcs); | |
| 149 | + | |
| 150 | + // Free members | |
| 151 | + free_members(); | |
| 152 | + | |
| 153 | + // Initialise private members for clean destruction | |
| 154 | + init_members(); | |
| 155 | + | |
| 156 | + // Copy members | |
| 157 | + copy_members(wcs); | |
| 158 | + | |
| 159 | + } // endif: object was not identical | |
| 160 | + | |
| 161 | + // Return this object | |
| 162 | + return *this; | |
| 163 | +} | |
| 164 | + | |
| 165 | + | |
| 166 | +/*========================================================================== | |
| 167 | + = = | |
| 168 | + = Public methods = | |
| 169 | + = = | |
| 170 | + ==========================================================================*/ | |
| 171 | + | |
| 172 | +/***********************************************************************//** | |
| 173 | + * @brief Clear Sanson-Flamsteed projection | |
| 174 | + * | |
| 175 | + * Resets the Sanson-Flamsteed projection to an clean initial state. | |
| 176 | + ***************************************************************************/ | |
| 177 | +void GWcsSFL::clear(void) | |
| 178 | +{ | |
| 179 | + // Free class members (base and derived classes, derived class first) | |
| 180 | + free_members(); | |
| 181 | + this->GWcs::free_members(); | |
| 182 | + this->GSkyProjection::free_members(); | |
| 183 | + | |
| 184 | + // Initialise members | |
| 185 | + this->GSkyProjection::init_members(); | |
| 186 | + this->GWcs::init_members(); | |
| 187 | + init_members(); | |
| 188 | + | |
| 189 | + // Return | |
| 190 | + return; | |
| 191 | +} | |
| 192 | + | |
| 193 | + | |
| 194 | +/***********************************************************************//** | |
| 195 | + * @brief Clone Sanson-Flamsteed projection | |
| 196 | + * | |
| 197 | + * @return Pointer to deep copy of Sanson-Flamsteed projection. | |
| 198 | + ***************************************************************************/ | |
| 199 | +GWcsSFL* GWcsSFL::clone(void) const | |
| 200 | +{ | |
| 201 | + return new GWcsSFL(*this); | |
| 202 | +} | |
| 203 | + | |
| 204 | + | |
| 205 | +/***********************************************************************//** | |
| 206 | + * @brief Print Sanson-Flamsteed projection information | |
| 207 | + * | |
| 208 | + * @param[in] chatter Chattiness. | |
| 209 | + * @return String containing Sanson-Flamsteed projection information. | |
| 210 | + ***************************************************************************/ | |
| 211 | +std::string GWcsSFL::print(const GChatter& chatter) const | |
| 212 | +{ | |
| 213 | + // Initialise result string | |
| 214 | + std::string result; | |
| 215 | + | |
| 216 | + // Continue only if chatter is not silent | |
| 217 | + if (chatter != SILENT) { | |
| 218 | + | |
| 219 | + // Append header | |
| 220 | + result.append("=== GWcsSFL ==="); | |
| 221 | + | |
| 222 | + // Append information | |
| 223 | + result.append(wcs_print(chatter)); | |
| 224 | + | |
| 225 | + } // endif: chatter was not silent | |
| 226 | + | |
| 227 | + // Return result | |
| 228 | + return result; | |
| 229 | +} | |
| 230 | + | |
| 231 | + | |
| 232 | +/*========================================================================== | |
| 233 | + = = | |
| 234 | + = Private methods = | |
| 235 | + = = | |
| 236 | + ==========================================================================*/ | |
| 237 | + | |
| 238 | +/***********************************************************************//** | |
| 239 | + * @brief Initialise class members | |
| 240 | + * | |
| 241 | + * This method sets up the World Coordinate System by calling wcs_set(). | |
| 242 | + ***************************************************************************/ | |
| 243 | +void GWcsSFL::init_members(void) | |
| 244 | +{ | |
| 245 | + // Setup World Coordinate System | |
| 246 | + wcs_set(); | |
| 247 | + | |
| 248 | + // Return | |
| 249 | + return; | |
| 250 | +} | |
| 251 | + | |
| 252 | + | |
| 253 | +/***********************************************************************//** | |
| 254 | + * @brief Copy class members | |
| 255 | + * | |
| 256 | + * @param[in] wcs World Coordinate System. | |
| 257 | + ***************************************************************************/ | |
| 258 | +void GWcsSFL::copy_members(const GWcsSFL& wcs) | |
| 259 | +{ | |
| 260 | + // Return | |
| 261 | + return; | |
| 262 | +} | |
| 263 | + | |
| 264 | + | |
| 265 | +/***********************************************************************//** | |
| 266 | + * @brief Delete class members | |
| 267 | + ***************************************************************************/ | |
| 268 | +void GWcsSFL::free_members(void) | |
| 269 | +{ | |
| 270 | + // Return | |
| 271 | + return; | |
| 272 | +} | |
| 273 | + | |
| 274 | + | |
| 275 | +/***********************************************************************//** | |
| 276 | + * @brief Setup of projection | |
| 277 | + * | |
| 278 | + * This method sets up the projection information. The method has been | |
| 279 | + * adapted from the wcslib function prj.c::sflset. | |
| 280 | + * | |
| 281 | + * Given and/or returned: | |
| 282 | + * m_r0 Reset to 180/pi if 0. | |
| 283 | + * m_phi0 Reset to 0.0 if undefined. | |
| 284 | + * m_theta0 Reset to 0.0 if undefined. | |
| 285 | + * | |
| 286 | + * Returned: | |
| 287 | + * m_x0 Fiducial offset in x. | |
| 288 | + * m_y0 Fiducial offset in y. | |
| 289 | + * m_w[0] r0*(pi/180) | |
| 290 | + * m_w[1] (180/pi)/r0 | |
| 291 | + ***************************************************************************/ | |
| 292 | +void GWcsSFL::prj_set(void) const | |
| 293 | +{ | |
| 294 | + // Signal that projection has been set (needs to be done before calling | |
| 295 | + // the prj_off() method to avoid an endless loop) | |
| 296 | + m_prjset = true; | |
| 297 | + | |
| 298 | + // Initialise projection parameters | |
| 299 | + m_w.assign(2, 0.0); | |
| 300 | + | |
| 301 | + // Precompute | |
| 302 | + if (m_r0 == 0.0) { | |
| 303 | + m_r0 = gammalib::rad2deg; | |
| 304 | + m_w[0] = 1.0; | |
| 305 | + m_w[1] = 1.0; | |
| 306 | + } | |
| 307 | + else { | |
| 308 | + m_w[0] = m_r0 * gammalib::deg2rad; | |
| 309 | + m_w[1] = 1.0 / m_w[0]; | |
| 310 | + } | |
| 311 | + | |
| 312 | + // Compute fiducial offset | |
| 313 | + prj_off(0.0, 0.0); | |
| 314 | + | |
| 315 | + // Return | |
| 316 | + return; | |
| 317 | +} | |
| 318 | + | |
| 319 | + | |
| 320 | +/***********************************************************************//** | |
| 321 | + * @brief Pixel-to-spherical deprojection | |
| 322 | + * | |
| 323 | + * @param[in] nx X vector length. | |
| 324 | + * @param[in] ny Y vector length (0=no replication). | |
| 325 | + * @param[in] sxy Input vector step. | |
| 326 | + * @param[in] spt Output vector step. | |
| 327 | + * @param[in] x Vector of projected x coordinates. | |
| 328 | + * @param[in] y Vector of projected y coordinates. | |
| 329 | + * @param[out] phi Longitude of the projected point in native spherical | |
| 330 | + * coordinates [deg]. | |
| 331 | + * @param[out] theta Latitude of the projected point in native spherical | |
| 332 | + * coordinates [deg]. | |
| 333 | + * @param[out] stat Status return value for each vector element (always 0) | |
| 334 | + * | |
| 335 | + * Deproject pixel (x,y) coordinates in the plane of projection to native | |
| 336 | + * spherical coordinates (phi,theta). | |
| 337 | + * | |
| 338 | + * This method has been adapted from the wcslib function prj.c::sflx2s(). | |
| 339 | + * The interface follows very closely that of wcslib. In contrast to the | |
| 340 | + * wcslib routine, however, the method assumes that the projection has been | |
| 341 | + * setup previously (as this will be done by the constructor). | |
| 342 | + ***************************************************************************/ | |
| 343 | +void GWcsSFL::prj_x2s(int nx, int ny, int sxy, int spt, | |
| 344 | + const double* x, const double* y, | |
| 345 | + double* phi, double* theta, int* stat) const | |
| 346 | +{ | |
| 347 | + // Initialize projection if required | |
| 348 | + if (!m_prjset) { | |
| 349 | + prj_set(); | |
| 350 | + } | |
| 351 | + | |
| 352 | + // Set value replication length mx,my | |
| 353 | + int mx; | |
| 354 | + int my; | |
| 355 | + if (ny > 0) { | |
| 356 | + mx = nx; | |
| 357 | + my = ny; | |
| 358 | + } | |
| 359 | + else { | |
| 360 | + mx = 1; | |
| 361 | + my = 1; | |
| 362 | + ny = nx; | |
| 363 | + } | |
| 364 | + | |
| 365 | + // Initialise status code and statistics | |
| 366 | + int status = 0; | |
| 367 | + int n_invalid = 0; | |
| 368 | + | |
| 369 | + | |
| 370 | + // Do x dependence | |
| 371 | + const double* xp = x; | |
| 372 | + int rowoff = 0; | |
| 373 | + int rowlen = nx * spt; | |
| 374 | + for (int ix = 0; ix < nx; ++ix, rowoff += spt, xp += sxy) { | |
| 375 | + double s = m_w[1] * (*xp + m_x0); | |
| 376 | + double* phip = phi + rowoff; | |
| 377 | + for (int iy = 0; iy < my; ++iy, phip += rowlen) { | |
| 378 | + *phip = s; | |
| 379 | + } | |
| 380 | + } | |
| 381 | + | |
| 382 | + // Do y dependence | |
| 383 | + const double* yp = y; | |
| 384 | + double* phip = phi; | |
| 385 | + double* thetap = theta; | |
| 386 | + int* statp = stat; | |
| 387 | + for (int iy = 0; iy < ny; ++iy, yp += sxy) { | |
| 388 | + double yj = *yp + m_y0; | |
| 389 | + double s = std::cos(yj/m_r0); | |
| 390 | + | |
| 391 | + // Initialise status | |
| 392 | + int istat = 0; | |
| 393 | + | |
| 394 | + // Invert s | |
| 395 | + if (s == 0.0) { | |
| 396 | + istat = 1; | |
| 397 | + status = 3; | |
| 398 | + n_invalid++; | |
| 399 | + #if defined(G_DEBUG_PRJ) | |
| 400 | + std::cout << "prj_x2s(Phi)..:"; | |
| 401 | + std::cout << " nx=" << nx; | |
| 402 | + std::cout << " ny=" << ny; | |
| 403 | + std::cout << " ix=" << ix; | |
| 404 | + std::cout << " iy=" << iy; | |
| 405 | + std::cout << " yp=" << *yp; | |
| 406 | + std::cout << " yj=" << yj; | |
| 407 | + std::cout << " phip=" << *phip; | |
| 408 | + std::cout << " s=" << s; | |
| 409 | + std::cout << std::endl; | |
| 410 | + #endif | |
| 411 | + } | |
| 412 | + else { | |
| 413 | + s = 1.0 / s; | |
| 414 | + } | |
| 415 | + | |
| 416 | + // ... | |
| 417 | + double t = m_w[1] * yj; | |
| 418 | + | |
| 419 | + // ... | |
| 420 | + for (int ix = 0; ix < mx; ++ix, phip += spt, thetap += spt) { | |
| 421 | + *phip *= s; | |
| 422 | + *thetap = t; | |
| 423 | + *(statp++) = istat; | |
| 424 | + } | |
| 425 | + | |
| 426 | + } // endfor: y dependence | |
| 427 | + | |
| 428 | + // Handle status code | |
| 429 | + if (status == 3) { | |
| 430 | + throw GException::wcs_invalid_x_y(G_PRJ_X2S, n_invalid); | |
| 431 | + } | |
| 432 | + | |
| 433 | + // Return | |
| 434 | + return; | |
| 435 | +} | |
| 436 | + | |
| 437 | + | |
| 438 | +/***********************************************************************//** | |
| 439 | + * @brief Generic spherical-to-pixel projection | |
| 440 | + * | |
| 441 | + * @param[in] nphi Longitude vector length. | |
| 442 | + * @param[in] ntheta Latitude vector length (0=no replication). | |
| 443 | + * @param[in] spt Input vector step. | |
| 444 | + * @param[in] sxy Output vector step. | |
| 445 | + * @param[in] phi Longitude vector of the projected point in native spherical | |
| 446 | + * coordinates [deg]. | |
| 447 | + * @param[in] theta Latitude vector of the projected point in native spherical | |
| 448 | + * coordinates [deg]. | |
| 449 | + * @param[out] x Vector of projected x coordinates. | |
| 450 | + * @param[out] y Vector of projected y coordinates. | |
| 451 | + * @param[out] stat Status return value for each vector element (always 0) | |
| 452 | + * | |
| 453 | + * Project native spherical coordinates (phi,theta) to pixel (x,y) | |
| 454 | + * coordinates in the plane of projection. | |
| 455 | + * | |
| 456 | + * This method has been adapted from the wcslib function prj.c::sfls2x(). | |
| 457 | + * The interface follows very closely that of wcslib. In contrast to the | |
| 458 | + * wcslib routine, however, the method assumes that the projection has been | |
| 459 | + * setup previously (as this will be done by the constructor). | |
| 460 | + ***************************************************************************/ | |
| 461 | +void GWcsSFL::prj_s2x(int nphi, int ntheta, int spt, int sxy, | |
| 462 | + const double* phi, const double* theta, | |
| 463 | + double* x, double* y, int* stat) const | |
| 464 | +{ | |
| 465 | + // Initialize projection if required | |
| 466 | + if (!m_prjset) { | |
| 467 | + prj_set(); | |
| 468 | + } | |
| 469 | + | |
| 470 | + // Set value replication length mphi,mtheta | |
| 471 | + int mphi; | |
| 472 | + int mtheta; | |
| 473 | + if (ntheta > 0) { | |
| 474 | + mphi = nphi; | |
| 475 | + mtheta = ntheta; | |
| 476 | + } | |
| 477 | + else { | |
| 478 | + mphi = 1; | |
| 479 | + mtheta = 1; | |
| 480 | + ntheta = nphi; | |
| 481 | + } | |
| 482 | + | |
| 483 | + // Do phi dependence | |
| 484 | + const double* phip = phi; | |
| 485 | + int rowoff = 0; | |
| 486 | + int rowlen = nphi * sxy; | |
| 487 | + for (int iphi = 0; iphi < nphi; ++iphi, rowoff += sxy, phip += spt) { | |
| 488 | + double xi = m_w[0] * (*phip); | |
| 489 | + double* xp = x + rowoff; | |
| 490 | + for (int itheta = 0; itheta < mtheta; ++itheta, xp += rowlen) { | |
| 491 | + *xp = xi; | |
| 492 | + } | |
| 493 | + } | |
| 494 | + | |
| 495 | + // Do theta dependence | |
| 496 | + const double* thetap = theta; | |
| 497 | + double* xp = x; | |
| 498 | + double* yp = y; | |
| 499 | + int* statp = stat; | |
| 500 | + for (int itheta = 0; itheta < ntheta; ++itheta, thetap += spt) { | |
| 501 | + double xi = gammalib::cosd(*thetap); | |
| 502 | + double eta = m_w[0] * (*thetap) - m_y0; | |
| 503 | + for (int iphi = 0; iphi < mphi; ++iphi, xp += sxy, yp += sxy) { | |
| 504 | + *xp = xi * (*xp) - m_x0; | |
| 505 | + *yp = eta; | |
| 506 | + *(statp++) = 0; | |
| 507 | + } | |
| 508 | + } | |
| 509 | + | |
| 510 | + // Return | |
| 511 | + return; | |
| 512 | +} | ... | ... |
src/sky/GWcsSIN.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsSIN.cpp - Orthographic/synthesis (SIN) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2016-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -300,6 +300,10 @@ void GWcsSIN::free_members(void) |
| 300 | 300 | ***************************************************************************/ |
| 301 | 301 | void GWcsSIN::prj_set(void) const |
| 302 | 302 | { |
| 303 | + // Signal that projection has been set (needs to be done before calling | |
| 304 | + // the prj_off() method to avoid an endless loop) | |
| 305 | + m_prjset = true; | |
| 306 | + | |
| 303 | 307 | // Initialise projection parameters |
| 304 | 308 | m_w.assign(4,0.0); |
| 305 | 309 | |
| ... | ... | @@ -323,9 +327,6 @@ void GWcsSIN::prj_set(void) const |
| 323 | 327 | // Compute fiducial offset |
| 324 | 328 | prj_off(0.0, 90.0); |
| 325 | 329 | |
| 326 | - // Signal that projection has been set | |
| 327 | - m_prjset = true; | |
| 328 | - | |
| 329 | 330 | // Return |
| 330 | 331 | return; |
| 331 | 332 | } | ... | ... |
src/sky/GWcsSTG.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsSTG.cpp - Stereographic (STG) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -292,6 +292,10 @@ void GWcsSTG::free_members(void) |
| 292 | 292 | ***************************************************************************/ |
| 293 | 293 | void GWcsSTG::prj_set(void) const |
| 294 | 294 | { |
| 295 | + // Signal that projection has been set (needs to be done before calling | |
| 296 | + // the prj_off() method to avoid an endless loop) | |
| 297 | + m_prjset = true; | |
| 298 | + | |
| 295 | 299 | // Initialise projection parameters |
| 296 | 300 | m_w.clear(); |
| 297 | 301 | |
| ... | ... | @@ -305,9 +309,6 @@ void GWcsSTG::prj_set(void) const |
| 305 | 309 | // Compute fiducial offset |
| 306 | 310 | prj_off(0.0, 90.0); |
| 307 | 311 | |
| 308 | - // Signal that projection has been set | |
| 309 | - m_prjset = true; | |
| 310 | - | |
| 311 | 312 | // Return |
| 312 | 313 | return; |
| 313 | 314 | } | ... | ... |
src/sky/GWcsTAN.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcsTAN.cpp - Gnomonic (TAN) projection class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2017 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -290,6 +290,10 @@ void GWcsTAN::free_members(void) |
| 290 | 290 | ***************************************************************************/ |
| 291 | 291 | void GWcsTAN::prj_set(void) const |
| 292 | 292 | { |
| 293 | + // Signal that projection has been set (needs to be done before calling | |
| 294 | + // the prj_off() method to avoid an endless loop) | |
| 295 | + m_prjset = true; | |
| 296 | + | |
| 293 | 297 | // Initialise projection parameters |
| 294 | 298 | m_w.clear(); |
| 295 | 299 | |
| ... | ... | @@ -301,9 +305,6 @@ void GWcsTAN::prj_set(void) const |
| 301 | 305 | // Compute fiducial offset |
| 302 | 306 | prj_off(0.0, 90.0); |
| 303 | 307 | |
| 304 | - // Signal that projection has been set | |
| 305 | - m_prjset = true; | |
| 306 | - | |
| 307 | 308 | // Return |
| 308 | 309 | return; |
| 309 | 310 | } | ... | ... |
src/sky/Makefile.am
| 1 | 1 | ############################################################################# |
| 2 | 2 | # Makefile.am for sky module # |
| 3 | 3 | # ------------------------------------------------------------------------- # |
| 4 | -# Copyright (C) 2016 Juergen Knoedlseder # | |
| 4 | +# Copyright (C) 2016-2017 Juergen Knoedlseder # | |
| 5 | 5 | # ------------------------------------------------------------------------- # |
| 6 | 6 | # # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify # |
| ... | ... | @@ -26,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/include \ |
| 26 | 26 | |
| 27 | 27 | # Define sources for this directory |
| 28 | 28 | sources = GSkyDir.cpp \ |
| 29 | - GHorizDir.cpp \ | |
| 29 | + GHorizDir.cpp \ | |
| 30 | 30 | GSkyPixel.cpp \ |
| 31 | 31 | GSkyMap.cpp \ |
| 32 | 32 | GSkyRegions.cpp \ |
| ... | ... | @@ -39,9 +39,11 @@ sources = GSkyDir.cpp \ |
| 39 | 39 | GWcsAIT.cpp \ |
| 40 | 40 | GWcsAZP.cpp \ |
| 41 | 41 | GWcsCAR.cpp \ |
| 42 | + GWcsGLS.cpp \ | |
| 42 | 43 | GWcsMER.cpp \ |
| 43 | 44 | GWcsMOL.cpp \ |
| 44 | 45 | GWcsSIN.cpp \ |
| 46 | + GWcsSFL.cpp \ | |
| 45 | 47 | GWcsSTG.cpp \ |
| 46 | 48 | GWcsTAN.cpp \ |
| 47 | 49 | GException_sky.cpp | ... | ... |
test/test_GSky.py
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # This module performs unit tests for the GammaLib sky module. |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2012-2016 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2012-2017 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -77,8 +77,10 @@ class Test(gammalib.GPythonTestSuite): |
| 77 | 77 | self.append(self.test_skymap_ait, "Test AIT projection map") |
| 78 | 78 | self.append(self.test_skymap_azp, "Test AZP projection map") |
| 79 | 79 | self.append(self.test_skymap_car, "Test CAR projection map") |
| 80 | + self.append(self.test_skymap_gls, "Test GLS projection map") | |
| 80 | 81 | self.append(self.test_skymap_mer, "Test MER projection map") |
| 81 | 82 | self.append(self.test_skymap_mol, "Test MOL projection map") |
| 83 | + self.append(self.test_skymap_sfl, "Test SFL projection map") | |
| 82 | 84 | self.append(self.test_skymap_sin, "Test SIN projection map") |
| 83 | 85 | self.append(self.test_skymap_stg, "Test STG projection map") |
| 84 | 86 | self.append(self.test_skymap_tan, "Test TAN projection map") |
| ... | ... | @@ -322,6 +324,17 @@ class Test(gammalib.GPythonTestSuite): |
| 322 | 324 | # Return |
| 323 | 325 | return |
| 324 | 326 | |
| 327 | + # Test GLS projection | |
| 328 | + def test_skymap_gls(self): | |
| 329 | + """ | |
| 330 | + Test GLS projection. | |
| 331 | + """ | |
| 332 | + # Execute generic test | |
| 333 | + self.test_skymap_proj("GLS") | |
| 334 | + | |
| 335 | + # Return | |
| 336 | + return | |
| 337 | + | |
| 325 | 338 | # Test MER projection |
| 326 | 339 | def test_skymap_mer(self): |
| 327 | 340 | """ |
| ... | ... | @@ -355,6 +368,17 @@ class Test(gammalib.GPythonTestSuite): |
| 355 | 368 | # Return |
| 356 | 369 | return |
| 357 | 370 | |
| 371 | + # Test SFL projection | |
| 372 | + def test_skymap_sfl(self): | |
| 373 | + """ | |
| 374 | + Test SFL projection. | |
| 375 | + """ | |
| 376 | + # Execute generic test | |
| 377 | + self.test_skymap_proj("SFL") | |
| 378 | + | |
| 379 | + # Return | |
| 380 | + return | |
| 381 | + | |
| 358 | 382 | # Test STG projection |
| 359 | 383 | def test_skymap_stg(self): |
| 360 | 384 | """ | ... | ... |