diff --git a/ChangeLog b/ChangeLog index 78b8ea3..b09f41b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017-03-15 + + * Version 1.3.0 released + ========================= + + Add GLS and SFL WCS projections (#1851) + + 2017-02-24 * Version 1.2.0 released diff --git a/NEWS b/NEWS index 7bb1123..7ff61f6 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ -New Features and Important Changes in GammaLib 1.2.0 +New Features and Important Changes in GammaLib 1.3.0 -3 February 2017 +15 March 2017 1. Introduction @@ -12,121 +12,39 @@ made since the last release of GammaLib. 2. Public interface modifications --------------------------------- The following classes have been added: -- GModelSpectralExpInvPlaw -- GModelSpectralPlawEnergyFlux -- GModelSpectralMultiplicative -- GModelSpectralComposite -- GModelSpatialComposite -- GModelTemporalLightCurve -- GModelTemporalPhaseCurve -- GVOTable -- GNdarray -- GFft -- GFftWavetable +- GWcsGLS +- GWcsSFL The following classes have been removed: - ... The following classes have been renamed: -- GModelSpectralPlawPhotonFlux, was GModelSpectralPlaw2 +- ... The following methods have been added: -- GApplication::log_string() -- GApplication::log_value() -- GApplication::log_header1() -- GApplication::log_header2() -- GApplication::log_header3() -- GApplication::operator[](const int& index) -- GApplication::pars() -- GApplicationPar::current_value() -- GLog::is_open() -- GLog::is_empty() -- GLog::written_size() -- GSkyMap::is_empty() -- GTime::jd(const std::string& timesys) -- GTime::mjd(const std::string& timesys) -- GTime::secs(const std::string& timesys) -- GTime::days(const std::string& timesys) -- GTime::jd(const double& time, const std::string& timesys) -- GTime::mjd(const double& time, const std::string& timesys) -- GTime::secs(const double& time, const std::string& timesys) -- GTime::days(const double& time, const std::string& timesys) -- GTime::gmst() -- GTime::gast() -- GTime::lmst(const double& geolon) -- GTime::last(const double& geolon) -- GTime::now() -- GFits::publish() -- gammalib::rstrip_chars() -- GObservations::save_covmat() -- GModelSpatial::region() -- GSkyMap(const GFitsHDU&) +- ... The following methods have been removed: -- ::eval_gradients() - The eval_gradients() methods duplicate much of the code of the eval() - methods. To increase the maintainability of the code, the eval_gradients() - methods have been removed, and the computation of partial derivatives is - now done by the eval() methods if the optional gradients argument is set - to true. +- ... The following methods have been renamed: -- GModelSpectralPlawPhotonFlux::flux(), was GModelSpectralPlaw2::integral() -- GLog::buffer_size(), was GLog::max_size() +- ... The arguments for the following methods have been changed: -- GApplication::log_parameters() now has a mandatory GChatter argument -- ::eval() has now an optional gradients parameter (see above) +- ... The return value of the following methods has been changed: -- GSkyMap::write() now returns a pointer to GFitsHDU instead of void +- ... 3. Configuration ----------------- -The Python wrappers were always removed when typing "make clean", even if -they had been shipped with the code. Now, the Python wrappers are only -removed in a "make clean" if they have been built (#1826). +None 4. Application module --------------------- -The GApplication::log_parameters() method now takes a mandatory GChatter -argument to enable displaying of parameters only above a given chattiness -level. This avoids a log-level check in the client code. For the same -purpose, the GApplication methods log_string(), log_value(), log_header1(), -log_header2(), and log_header3() have been introduced. There are three -variants of log_value() for strings, integers and double precision values -(#1828). - -The application name and version and now conserved in a GApplication::clear() -method call and the application is properly initialised like in the call of -a constructor (#1835). - -The GLog::copy_members() method simply copied the file pointer, hence after -a copy of a log instance there were two instances holding the same pointer -to the file, and as soon as one instance closes the log file the file -pointer in the second instance became invalid. This has been fixed by -duplicating the file descriptor and opening the log file in the copied -instance using the duplicated descriptor. This solves the problems (#1823). - -A GLog::is_open() method has been added to assess whether a log file is -actually opened. The GLog::is_empty() method has been added to assess whether -a log file is actually empty (#1837). - -The GLog::size() method now returns the actual size of the log file, including -the number of characters on disk. - -The GLog::max_size() method has been renamed to GLog::buffer_size since this -is more explicit (#1837). - -GApplication::pars() methods have been added to allow to retrieve or to set all -application parameters. The GApplicationPar::current_value() method has been -added to retrieve the current parameter value without querying for the parameter -(#1838). - -Operators have been added to GApplication that allow the access of application -parameters by index (#1838). +None 5. Base module @@ -136,9 +54,7 @@ None 6. FITS I/O Interface --------------------- -Add GFits::publish() methods that publish a FITS HDU to an Virtual Observatory -hub. If the FITS HDU is an image it will be published as a FITS image, which -table HDUs will be published as VO tables (#1231). +None 7. Linear algebra module @@ -148,77 +64,17 @@ None 8. Model module --------------- -The GModelSpectralPlaw2 class has been renamed to GModelSpectralPlawPhotonFlux -and the integral() methods were renamed to flux(). A new class -GModelSpectralPlawEnergyFlux has been added that handles integral energy -fluxes as opposed to GModelSpectralPlawPhotonFlux that handles integral -photon fluxes. Unit tests have been added for the new class (#1790). - -The GModelSpectralExpInvPlaw class has been added that uses a cut-off -parameter instead of a cut-off energy for the exponentially cut-off -power law. The cut-off parameter is the inverse of the cut-off energy -(#1800). - -The GModelSpectralMultiplicative class has been added that implements the -product of spectral model components as a new spectral model (#1861). - -The GModelSpectralComposite and GModelSpatialComposite classes have been -added that implement composite spectral and spatial models, which are sums -of models as a new model component (#1706). - -A region() method has been added to the GModelSpatial base class and all -derived classes that returns a pointer to a sky region that bounds the -spatial model. For the moment, only circular sky regions have been -implemented (#1764). - -The GModelTemporalLightCurve class has been added to implement a light -curve as temporal component of a model. The light curve is defined by -nodes in a FITS file. It can be used for the simulation of transient -sources. A unit test has been added and the mc() and eval() methods -have been validated using a dedicated test script (#1914). - -The GModelSpatialDiffuseMap::mc and GModelSpatialDiffuseCube::mc methods -now throw an GException::invalid_return_value exception that is catched -in the GModelSky::mc method and leads to the skipping of the concerned -photon. This allows handling of empty diffuse maps or map cubes (#1915). - -The GModelTemporalPhaseCurve class has been added to impelement a phase -curve as temporal component of a model. The phase curve can be used to -model pulsar light curves or the temporal variation of gamma-ray binaries -(#1916). +None 9. Numerics module ------------------ -The GNdarray class has been added that implements a n-dimensional double -precision floating point array (#1768). - -The GFft class has been added that performs a Fast Fourier Transformation -of a n-dimensional array. The GFftWavetable class is a support class for -GFft that provides the trigonometric coefficients for a factorisation. For -the moment, GFft does only support 1-dimensional and 2-dimensional arrays -(#1731). +None 10. Observation module ---------------------- -Time setting and getting methods for Julian Days, Modified Julian Days, -native seconds and native days are now available in the GTime class that -allow specifying the time system. Currently, TT, TAI and UTC are supported. -Methods have also been added to the GTime class that return the Greenwich -mean and apparent siderial times, and the local mean and apparent siderial -times that depend on the geographic longitude. Finally, a now() method has -been added to the GTime class that sets the time to the current time (see -#1856). - -The GObservations::save_covmat() method computes and saves the covariance -matrix into a FITS file (#1863). - -A leap second has been added to GTime::leap_seconds() for 1 January 2017 -(#1887). - -The handling of time references was corrected in GGti::extend() so that -times now reflect correctly any changes in the time reference (#1922). +None 11. Optimization module @@ -228,26 +84,13 @@ None 12. Sky module -------------- -The GSkyMap::write() method now returns a pointer to the written GFitsHDU -object. In case that no sky map is written, for example because none has been -defined so far, the method returns NONE. The GSkyMap::publish() method will -detect the NONE value and will do nothing if no sky map exists (#1835). - -The GSkyMap::is_empty() method signals whether a sky map contains no pixels -or no maps (#1828). - -A FITS HDU constructor was added to the GSkyMap class that allows constructing -a sky map from a FITS HDU. +The GWcsGLS and GWcsSFL classes have been added to support the GLS and SFL +World Coordinate System projections (#1851). 13. Support module ------------------ -The gammalib::rstrip_chars() function has been added to right strip characters -from a string. - -The gammalib::str() functions for single and double precision floating point -numbers now have an increased precision so that significant digits are no -longer lost. +None 14. XML module @@ -257,9 +100,7 @@ None 15. VO module ------------- -A GVOTable class has been added that allows handling of VO tables, including -transformation of FITS tables into VO tables and sending VO tables through the -VO hub to other applications (#1231). +None 16. Xspec module @@ -269,10 +110,7 @@ None 17. Test module --------------- -A GTestSuite::test_value() method for double precision values has been added -that automatically requires a relative precision of 1.0e-7. The default value -for "eps" has been removed from the former double precision test_value() -method. This should allow writing of more compact unit tests. +None 18. Multi-wavelength interface @@ -287,18 +125,7 @@ None 20. CTA interface ----------------- -The dimension of response tables is now checked for being consistent with the -axis dimension (#1848). - -The formula for the containment radius computation in GCTAPsf2D::containment_radius -was wrong and has been corrected (#1876). - -The GCTABackground3D::mc() method now verifies that the specified energy is within -the validity range of the background template. Otherwise an exception is thrown -(#1918). - -Observations with zero livetime are now skipped in building the cubes for stacked -analysis for CTA (#1920). +None 21. COMPTEL interface diff --git a/doc/source/users/user_manual/modules/uml_sky.png b/doc/source/users/user_manual/modules/uml_sky.png index e4dc990..f9fb5ed 100644 --- a/doc/source/users/user_manual/modules/uml_sky.png +++ b/doc/source/users/user_manual/modules/uml_sky.png diff --git a/include/GWcsGLS.hpp b/include/GWcsGLS.hpp new file mode 100644 index 0000000..13d304a --- /dev/null +++ b/include/GWcsGLS.hpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * GWcsGLS.hpp - Global Sinusoidal (GLS) projection class * + * ----------------------------------------------------------------------- * + * copyright (C) 2017 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GWcsGLS.hpp + * @brief Global Sinusoidal (GLS) projection class definition + * @author Juergen Knoedlseder + */ + +#ifndef GWCSGLS_HPP +#define GWCSGLS_HPP + +/* __ Includes ___________________________________________________________ */ +#include +#include "GWcsSFL.hpp" + + +/***********************************************************************//** + * @class GWcsGLS + * + * @brief Global Sinusoidal (GLS) projection class definition + * + * This class implements the Global Sinusoidal projection for the World + * Coordinate System. The Global Sinusoidal projection is an alias of the + * Sanson-Flamsteed projection, and the GWcsGLS therefore derives from the + * GWcsSFL class. + ***************************************************************************/ +class GWcsGLS : public GWcsSFL { + +public: + // Constructors and destructors + GWcsGLS(void); + GWcsGLS(const std::string& coords, + const double& crval1, const double& crval2, + const double& crpix1, const double& crpix2, + const double& cdelt1, const double& cdelt2); + GWcsGLS(const GWcsGLS& wcs); + virtual ~GWcsGLS(void); + + // Operators + GWcsGLS& operator=(const GWcsGLS& wcs); + + // Implemented pure virtual base class methods + virtual void clear(void); + virtual GWcsGLS* clone(void) const; + virtual std::string classname(void) const; + virtual std::string code(void) const; + virtual std::string name(void) const; + virtual std::string print(const GChatter& chatter = NORMAL) const; + +protected: + // Private methods + void init_members(void); + void copy_members(const GWcsGLS& wcs); + void free_members(void); +}; + + +/***********************************************************************//** + * @brief Return class name + * + * @return String containing the class name ("GWcsGLS"). + ***************************************************************************/ +inline +std::string GWcsGLS::classname(void) const +{ + return ("GWcsGLS"); +} + + +/***********************************************************************//** + * @brief Return projection code + * + * @return Projection code. + * + * Returns the projection code "GLS". + ***************************************************************************/ +inline +std::string GWcsGLS::code(void) const +{ + return "GLS"; +} + + +/***********************************************************************//** + * @brief Return projection name + * + * @return Projection name. + * + * Returns the projection name. + ***************************************************************************/ +inline +std::string GWcsGLS::name(void) const +{ + return "Global Sinusoidal"; +} + +#endif /* GWCSGLS_HPP */ diff --git a/include/GWcsSFL.hpp b/include/GWcsSFL.hpp new file mode 100644 index 0000000..c01d7fb --- /dev/null +++ b/include/GWcsSFL.hpp @@ -0,0 +1,120 @@ +/*************************************************************************** + * GWcsSFL.hpp - Sanson-Flamsteed (SFL) projection class * + * ----------------------------------------------------------------------- * + * copyright (C) 2017 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GWcsSFL.hpp + * @brief Sanson-Flamsteed (SFL) projection class definition + * @author Juergen Knoedlseder + */ + +#ifndef GWCSSFL_HPP +#define GWCSSFL_HPP + +/* __ Includes ___________________________________________________________ */ +#include +#include "GWcs.hpp" + + +/***********************************************************************//** + * @class GWcsSFL + * + * @brief Sanson-Flamsteed (SFL) projection class definition + * + * This class implements the Sanson-Flamsteed projection for the World + * Coordinate System. + ***************************************************************************/ +class GWcsSFL : public GWcs { + +public: + // Constructors and destructors + GWcsSFL(void); + GWcsSFL(const std::string& coords, + const double& crval1, const double& crval2, + const double& crpix1, const double& crpix2, + const double& cdelt1, const double& cdelt2); + GWcsSFL(const GWcsSFL& wcs); + virtual ~GWcsSFL(void); + + // Operators + GWcsSFL& operator=(const GWcsSFL& wcs); + + // Implemented pure virtual base class methods + virtual void clear(void); + virtual GWcsSFL* clone(void) const; + virtual std::string classname(void) const; + virtual std::string code(void) const; + virtual std::string name(void) const; + virtual std::string print(const GChatter& chatter = NORMAL) const; + +protected: + // Protected methods + void init_members(void); + void copy_members(const GWcsSFL& wcs); + void free_members(void); + void prj_set(void) const; + void prj_x2s(int nx, int ny, int sxy, int spt, + const double* x, const double* y, + double* phi, double* theta, int* stat) const; + void prj_s2x(int nphi, int ntheta, int spt, int sxy, + const double* phi, const double* theta, + double* x, double* y, int* stat) const; +}; + + +/***********************************************************************//** + * @brief Return class name + * + * @return String containing the class name ("GWcsSFL"). + ***************************************************************************/ +inline +std::string GWcsSFL::classname(void) const +{ + return ("GWcsSFL"); +} + + +/***********************************************************************//** + * @brief Return projection code + * + * @return Projection code. + * + * Returns the projection code "SFL". + ***************************************************************************/ +inline +std::string GWcsSFL::code(void) const +{ + return "SFL"; +} + + +/***********************************************************************//** + * @brief Return projection name + * + * @return Projection name. + * + * Returns the projection name. + ***************************************************************************/ +inline +std::string GWcsSFL::name(void) const +{ + return "Sanson-Flamsteed"; +} + +#endif /* GWCSSFL_HPP */ diff --git a/include/GammaLib.hpp b/include/GammaLib.hpp index 7244f29..be0af84 100644 --- a/include/GammaLib.hpp +++ b/include/GammaLib.hpp @@ -156,9 +156,11 @@ #include "GWcsAIT.hpp" #include "GWcsAZP.hpp" #include "GWcsCAR.hpp" +#include "GWcsGLS.hpp" #include "GWcsMER.hpp" #include "GWcsMOL.hpp" #include "GWcsSIN.hpp" +#include "GWcsSFL.hpp" #include "GWcsSTG.hpp" #include "GWcsTAN.hpp" diff --git a/include/Makefile.am b/include/Makefile.am index 8c2fea5..ae96c41 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -118,9 +118,11 @@ pkginclude_HEADERS = GammaLib.hpp \ GWcsAIT.hpp \ GWcsAZP.hpp \ GWcsCAR.hpp \ + GWcsGLS.hpp \ GWcsMER.hpp \ GWcsMOL.hpp \ GWcsSIN.hpp \ + GWcsSFL.hpp \ GWcsSTG.hpp \ GWcsTAN.hpp \ GEnergy.hpp \ diff --git a/pyext/GWcsGLS.i b/pyext/GWcsGLS.i new file mode 100644 index 0000000..10ade71 --- /dev/null +++ b/pyext/GWcsGLS.i @@ -0,0 +1,65 @@ +/*************************************************************************** + * GWcsGLS.i - Global Sinusoidal (GLS) projection class * + * ----------------------------------------------------------------------- * + * copyright (C) 2017 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GWcsGLS.i + * @brief Global Sinusoidal (GLS) projection class Python interface + * @author Juergen Knoedlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GWcsGLS.hpp" +%} + + +/***********************************************************************//** + * @class GWcsGLS + * + * @brief Global Sinusoidal (GLS) projection class definition + ***************************************************************************/ +class GWcsGLS : public GWcsSFL { + +public: + // Constructors and destructors + GWcsGLS(void); + GWcsGLS(const std::string& coords, + const double& crval1, const double& crval2, + const double& crpix1, const double& crpix2, + const double& cdelt1, const double& cdelt2); + GWcsGLS(const GWcsGLS& wcs); + virtual ~GWcsGLS(void); + + // Implemented pure virtual methods + virtual void clear(void); + virtual GWcsGLS* clone(void) const; + virtual std::string classname(void) const; + virtual std::string code(void) const; + virtual std::string name(void) const; +}; + + +/***********************************************************************//** + * @brief GWcsGLS class extension + ***************************************************************************/ +%extend GWcsGLS { + GWcsGLS copy() { + return (*self); + } +}; diff --git a/pyext/GWcsSFL.i b/pyext/GWcsSFL.i new file mode 100644 index 0000000..8baea02 --- /dev/null +++ b/pyext/GWcsSFL.i @@ -0,0 +1,64 @@ +/*************************************************************************** + * GWcsSFL.i - Sanson-Flamsteed (SFL) projection class * + * ----------------------------------------------------------------------- * + * copyright (C) 2017 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GWcsSFL.i + * @brief Sanson-Flamsteed (SFL) projection class Python interface + * @author Juergen Knoedlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GWcsSFL.hpp" +%} + + +/***********************************************************************//** + * @class GWcsSFL + * + * @brief Sanson-Flamsteed (SFL) projection class definition + ***************************************************************************/ +class GWcsSFL : public GWcs { +public: + // Constructors and destructors + GWcsSFL(void); + GWcsSFL(const std::string& coords, + const double& crval1, const double& crval2, + const double& crpix1, const double& crpix2, + const double& cdelt1, const double& cdelt2); + GWcsSFL(const GWcsSFL& wcs); + virtual ~GWcsSFL(void); + + // Implemented pure virtual methods + virtual void clear(void); + virtual GWcsSFL* clone(void) const; + virtual std::string classname(void) const; + virtual std::string code(void) const; + virtual std::string name(void) const; +}; + + +/***********************************************************************//** + * @brief GWcsSFL class extension + ***************************************************************************/ +%extend GWcsSFL { + GWcsSFL copy() { + return (*self); + } +}; diff --git a/pyext/gammalib/sky.i b/pyext/gammalib/sky.i index a1a60c8..4376d52 100644 --- a/pyext/gammalib/sky.i +++ b/pyext/gammalib/sky.i @@ -122,8 +122,10 @@ namespace std { %include "GWcsAIT.i" %include "GWcsAZP.i" %include "GWcsCAR.i" +%include "GWcsGLS.i" %include "GWcsMER.i" %include "GWcsMOL.i" +%include "GWcsSFL.i" %include "GWcsSIN.i" %include "GWcsSTG.i" %include "GWcsTAN.i" diff --git a/src/sky/GWcs.cpp b/src/sky/GWcs.cpp index 8a38d4b..532354b 100644 --- a/src/sky/GWcs.cpp +++ b/src/sky/GWcs.cpp @@ -920,8 +920,9 @@ void GWcs::copy_members(const GWcs& wcs) m_x0 = wcs.m_x0; m_y0 = wcs.m_y0; m_w = wcs.m_w; - for (int i = 0; i < PVN; ++i) + for (int i = 0; i < PVN; ++i) { m_pv[i] = wcs.m_pv[i]; + } // Return return; @@ -1147,7 +1148,12 @@ void GWcs::wcs_set(void) const //TODO: Do we have PVi_ma keyvalues? - //TODO: Do simple alias translations + // Do simple alias translations + if (code() == "GLS") { + m_offset = true; + m_phi0 = 0.0; + m_theta0 = m_crval[m_lat]; + } // Initialize the celestial transformation routines m_r0 = 0.0; // Forces initialisation diff --git a/src/sky/GWcsAIT.cpp b/src/sky/GWcsAIT.cpp index 71e95b4..02025e1 100644 --- a/src/sky/GWcsAIT.cpp +++ b/src/sky/GWcsAIT.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsAIT.cpp - Aitoff (AIT) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2013 by Juergen Knoedlseder * + * copyright (C) 2013-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -302,6 +302,10 @@ void GWcsAIT::free_members(void) ***************************************************************************/ void GWcsAIT::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.assign(4, 0.0); @@ -319,9 +323,6 @@ void GWcsAIT::prj_set(void) const // Compute fiducial offset prj_off(0.0, 0.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsAZP.cpp b/src/sky/GWcsAZP.cpp index af74146..f39f409 100644 --- a/src/sky/GWcsAZP.cpp +++ b/src/sky/GWcsAZP.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsAZP.cpp - Zenithal/azimuthal perspective (AZP) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2013 by Juergen Knoedlseder * + * copyright (C) 2011-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -309,8 +309,12 @@ void GWcsAZP::free_members(void) ***************************************************************************/ void GWcsAZP::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters - m_w.assign(8,0.0); + m_w.assign(8, 0.0); // Set undefined parameters if (undefined(m_pv[1])) m_pv[1] = 0.0; @@ -343,9 +347,6 @@ void GWcsAZP::prj_set(void) const // Compute fiducial offset prj_off(0.0, 90.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsCAR.cpp b/src/sky/GWcsCAR.cpp index 936f77f..83bc849 100644 --- a/src/sky/GWcsCAR.cpp +++ b/src/sky/GWcsCAR.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsCAR.cpp - Plate carree (CAR) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2013 by Jurgen Knodlseder * + * copyright (C) 2010-2017 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -290,6 +290,10 @@ void GWcsCAR::free_members(void) ***************************************************************************/ void GWcsCAR::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.clear(); @@ -307,9 +311,6 @@ void GWcsCAR::prj_set(void) const // Compute fiducial offset prj_off(0.0, 0.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsGLS.cpp b/src/sky/GWcsGLS.cpp new file mode 100644 index 0000000..3d1c4ef --- /dev/null +++ b/src/sky/GWcsGLS.cpp @@ -0,0 +1,270 @@ +/*************************************************************************** + * GWcsGLS.cpp - Global Sinusoidal (GLS) projection class * + * ----------------------------------------------------------------------- * + * copyright (C) 2017 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GWcsGLS.cpp + * @brief Global Sinusoidal (GLS) projection class implementation + * @author Juergen Knoedlseder + */ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include "GException.hpp" +#include "GMath.hpp" +#include "GWcsGLS.hpp" +#include "GWcsRegistry.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + +/* __ Local prototypes ___________________________________________________ */ + +/* __ Constants __________________________________________________________ */ + +/* __ Globals ____________________________________________________________ */ +const GWcsGLS g_wcs_gls_seed; +const GWcsRegistry g_wcs_gls_registry(&g_wcs_gls_seed); + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Void constructor + ***************************************************************************/ +GWcsGLS::GWcsGLS(void) : GWcsSFL() +{ + // Initialise class members + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Projection constructor + * + * @param[in] coords Coordinate system. + * @param[in] crval1 X value of reference pixel. + * @param[in] crval2 Y value of reference pixel. + * @param[in] crpix1 X index of reference pixel (starting from 1). + * @param[in] crpix2 Y index of reference pixel (starting from 1). + * @param[in] cdelt1 Increment in x direction at reference pixel [deg]. + * @param[in] cdelt2 Increment in y direction at reference pixel [deg]. + ***************************************************************************/ +GWcsGLS::GWcsGLS(const std::string& coords, + const double& crval1, const double& crval2, + const double& crpix1, const double& crpix2, + const double& cdelt1, const double& cdelt2) : + GWcsSFL(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2) +{ + // Initialise class members + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] wcs World Coordinate System. + ***************************************************************************/ +GWcsGLS::GWcsGLS(const GWcsGLS& wcs) : GWcsSFL(wcs) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(wcs); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GWcsGLS::~GWcsGLS(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] wcs World Coordinate System. + * @return World Coordinate System. + ***************************************************************************/ +GWcsGLS& GWcsGLS::operator=(const GWcsGLS& wcs) +{ + // Execute only if object is not identical + if (this != &wcs) { + + // Copy base class members + this->GWcsSFL::operator=(wcs); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(wcs); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Clear Global Sinusoidal projection + * + * Resets the Global Sinusoidal projection to an clean initial state. + ***************************************************************************/ +void GWcsGLS::clear(void) +{ + // Free class members (base and derived classes, derived class first) + free_members(); + this->GWcsSFL::free_members(); + this->GWcs::free_members(); + this->GSkyProjection::free_members(); + + // Initialise members + this->GSkyProjection::init_members(); + this->GWcs::init_members(); + this->GWcsSFL::init_members(); + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone Global Sinusoidal projection + * + * @return Pointer to deep copy of Global Sinusoidal projection. + ***************************************************************************/ +GWcsGLS* GWcsGLS::clone(void) const +{ + return new GWcsGLS(*this); +} + + +/***********************************************************************//** + * @brief Print Global Sinusoidal projection information + * + * @param[in] chatter Chattiness. + * @return String containing Global Sinusoidal projection information. + ***************************************************************************/ +std::string GWcsGLS::print(const GChatter& chatter) const +{ + // Initialise result string + std::string result; + + // Continue only if chatter is not silent + if (chatter != SILENT) { + + // Append header + result.append("=== GWcsGLS ==="); + + // Append information + result.append(wcs_print(chatter)); + + } // endif: chatter was not silent + + // Return result + return result; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GWcsGLS::init_members(void) +{ + // Setup World Coordinate System + wcs_set(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] wcs World Coordinate System. + ***************************************************************************/ +void GWcsGLS::copy_members(const GWcsGLS& wcs) +{ + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GWcsGLS::free_members(void) +{ + // Return + return; +} diff --git a/src/sky/GWcsMER.cpp b/src/sky/GWcsMER.cpp index 4900630..dc49ab7 100644 --- a/src/sky/GWcsMER.cpp +++ b/src/sky/GWcsMER.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsMER.cpp - Mercator's (MER) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -290,6 +290,10 @@ void GWcsMER::free_members(void) ***************************************************************************/ void GWcsMER::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.clear(); @@ -307,9 +311,6 @@ void GWcsMER::prj_set(void) const // Compute fiducial offset prj_off(0.0, 0.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsMOL.cpp b/src/sky/GWcsMOL.cpp index 95b6f49..e5ca257 100644 --- a/src/sky/GWcsMOL.cpp +++ b/src/sky/GWcsMOL.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsMOL.cpp - Mollweide's projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2015 by Juergen Knoedlseder * + * copyright (C) 2015-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -301,6 +301,10 @@ void GWcsMOL::free_members(void) ***************************************************************************/ void GWcsMOL::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.assign(5, 0.0); @@ -319,9 +323,6 @@ void GWcsMOL::prj_set(void) const // Compute fiducial offset prj_off(0.0, 0.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsSFL.cpp b/src/sky/GWcsSFL.cpp new file mode 100644 index 0000000..5cddaae --- /dev/null +++ b/src/sky/GWcsSFL.cpp @@ -0,0 +1,512 @@ +/*************************************************************************** + * GWcsSFL.cpp - Sanson-Flamsteed (SFL) projection class * + * ----------------------------------------------------------------------- * + * copyright (C) 2017 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GWcsSFL.cpp + * @brief Sanson-Flamsteed (SFL) projection class implementation + * @author Juergen Knoedlseder + */ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include "GException.hpp" +#include "GMath.hpp" +#include "GWcsSFL.hpp" +#include "GWcsRegistry.hpp" + +/* __ Method name definitions ____________________________________________ */ +#define G_PRJ_X2S "GWcsSFL::prj_x2s(int, int, int, int, double*, double*,"\ + " double*, double*, int*)" + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + +/* __ Local prototypes ___________________________________________________ */ + +/* __ Constants __________________________________________________________ */ + +/* __ Globals ____________________________________________________________ */ +const GWcsSFL g_wcs_sfl_seed; +const GWcsRegistry g_wcs_sfl_registry(&g_wcs_sfl_seed); + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Void constructor + ***************************************************************************/ +GWcsSFL::GWcsSFL(void) : GWcs() +{ + // Initialise class members + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Projection constructor + * + * @param[in] coords Coordinate system. + * @param[in] crval1 X value of reference pixel. + * @param[in] crval2 Y value of reference pixel. + * @param[in] crpix1 X index of reference pixel (starting from 1). + * @param[in] crpix2 Y index of reference pixel (starting from 1). + * @param[in] cdelt1 Increment in x direction at reference pixel [deg]. + * @param[in] cdelt2 Increment in y direction at reference pixel [deg]. + ***************************************************************************/ +GWcsSFL::GWcsSFL(const std::string& coords, + const double& crval1, const double& crval2, + const double& crpix1, const double& crpix2, + const double& cdelt1, const double& cdelt2) : + GWcs(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2) +{ + // Initialise class members + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] wcs World Coordinate System. + ***************************************************************************/ +GWcsSFL::GWcsSFL(const GWcsSFL& wcs) : GWcs(wcs) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(wcs); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GWcsSFL::~GWcsSFL(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] wcs World Coordinate System. + * @return World Coordinate System. + ***************************************************************************/ +GWcsSFL& GWcsSFL::operator=(const GWcsSFL& wcs) +{ + // Execute only if object is not identical + if (this != &wcs) { + + // Copy base class members + this->GWcs::operator=(wcs); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(wcs); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Clear Sanson-Flamsteed projection + * + * Resets the Sanson-Flamsteed projection to an clean initial state. + ***************************************************************************/ +void GWcsSFL::clear(void) +{ + // Free class members (base and derived classes, derived class first) + free_members(); + this->GWcs::free_members(); + this->GSkyProjection::free_members(); + + // Initialise members + this->GSkyProjection::init_members(); + this->GWcs::init_members(); + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone Sanson-Flamsteed projection + * + * @return Pointer to deep copy of Sanson-Flamsteed projection. + ***************************************************************************/ +GWcsSFL* GWcsSFL::clone(void) const +{ + return new GWcsSFL(*this); +} + + +/***********************************************************************//** + * @brief Print Sanson-Flamsteed projection information + * + * @param[in] chatter Chattiness. + * @return String containing Sanson-Flamsteed projection information. + ***************************************************************************/ +std::string GWcsSFL::print(const GChatter& chatter) const +{ + // Initialise result string + std::string result; + + // Continue only if chatter is not silent + if (chatter != SILENT) { + + // Append header + result.append("=== GWcsSFL ==="); + + // Append information + result.append(wcs_print(chatter)); + + } // endif: chatter was not silent + + // Return result + return result; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + * + * This method sets up the World Coordinate System by calling wcs_set(). + ***************************************************************************/ +void GWcsSFL::init_members(void) +{ + // Setup World Coordinate System + wcs_set(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] wcs World Coordinate System. + ***************************************************************************/ +void GWcsSFL::copy_members(const GWcsSFL& wcs) +{ + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GWcsSFL::free_members(void) +{ + // Return + return; +} + + +/***********************************************************************//** + * @brief Setup of projection + * + * This method sets up the projection information. The method has been + * adapted from the wcslib function prj.c::sflset. + * + * Given and/or returned: + * m_r0 Reset to 180/pi if 0. + * m_phi0 Reset to 0.0 if undefined. + * m_theta0 Reset to 0.0 if undefined. + * + * Returned: + * m_x0 Fiducial offset in x. + * m_y0 Fiducial offset in y. + * m_w[0] r0*(pi/180) + * m_w[1] (180/pi)/r0 + ***************************************************************************/ +void GWcsSFL::prj_set(void) const +{ + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + + // Initialise projection parameters + m_w.assign(2, 0.0); + + // Precompute + if (m_r0 == 0.0) { + m_r0 = gammalib::rad2deg; + m_w[0] = 1.0; + m_w[1] = 1.0; + } + else { + m_w[0] = m_r0 * gammalib::deg2rad; + m_w[1] = 1.0 / m_w[0]; + } + + // Compute fiducial offset + prj_off(0.0, 0.0); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Pixel-to-spherical deprojection + * + * @param[in] nx X vector length. + * @param[in] ny Y vector length (0=no replication). + * @param[in] sxy Input vector step. + * @param[in] spt Output vector step. + * @param[in] x Vector of projected x coordinates. + * @param[in] y Vector of projected y coordinates. + * @param[out] phi Longitude of the projected point in native spherical + * coordinates [deg]. + * @param[out] theta Latitude of the projected point in native spherical + * coordinates [deg]. + * @param[out] stat Status return value for each vector element (always 0) + * + * Deproject pixel (x,y) coordinates in the plane of projection to native + * spherical coordinates (phi,theta). + * + * This method has been adapted from the wcslib function prj.c::sflx2s(). + * The interface follows very closely that of wcslib. In contrast to the + * wcslib routine, however, the method assumes that the projection has been + * setup previously (as this will be done by the constructor). + ***************************************************************************/ +void GWcsSFL::prj_x2s(int nx, int ny, int sxy, int spt, + const double* x, const double* y, + double* phi, double* theta, int* stat) const +{ + // Initialize projection if required + if (!m_prjset) { + prj_set(); + } + + // Set value replication length mx,my + int mx; + int my; + if (ny > 0) { + mx = nx; + my = ny; + } + else { + mx = 1; + my = 1; + ny = nx; + } + + // Initialise status code and statistics + int status = 0; + int n_invalid = 0; + + + // Do x dependence + const double* xp = x; + int rowoff = 0; + int rowlen = nx * spt; + for (int ix = 0; ix < nx; ++ix, rowoff += spt, xp += sxy) { + double s = m_w[1] * (*xp + m_x0); + double* phip = phi + rowoff; + for (int iy = 0; iy < my; ++iy, phip += rowlen) { + *phip = s; + } + } + + // Do y dependence + const double* yp = y; + double* phip = phi; + double* thetap = theta; + int* statp = stat; + for (int iy = 0; iy < ny; ++iy, yp += sxy) { + double yj = *yp + m_y0; + double s = std::cos(yj/m_r0); + + // Initialise status + int istat = 0; + + // Invert s + if (s == 0.0) { + istat = 1; + status = 3; + n_invalid++; + #if defined(G_DEBUG_PRJ) + std::cout << "prj_x2s(Phi)..:"; + std::cout << " nx=" << nx; + std::cout << " ny=" << ny; + std::cout << " ix=" << ix; + std::cout << " iy=" << iy; + std::cout << " yp=" << *yp; + std::cout << " yj=" << yj; + std::cout << " phip=" << *phip; + std::cout << " s=" << s; + std::cout << std::endl; + #endif + } + else { + s = 1.0 / s; + } + + // ... + double t = m_w[1] * yj; + + // ... + for (int ix = 0; ix < mx; ++ix, phip += spt, thetap += spt) { + *phip *= s; + *thetap = t; + *(statp++) = istat; + } + + } // endfor: y dependence + + // Handle status code + if (status == 3) { + throw GException::wcs_invalid_x_y(G_PRJ_X2S, n_invalid); + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Generic spherical-to-pixel projection + * + * @param[in] nphi Longitude vector length. + * @param[in] ntheta Latitude vector length (0=no replication). + * @param[in] spt Input vector step. + * @param[in] sxy Output vector step. + * @param[in] phi Longitude vector of the projected point in native spherical + * coordinates [deg]. + * @param[in] theta Latitude vector of the projected point in native spherical + * coordinates [deg]. + * @param[out] x Vector of projected x coordinates. + * @param[out] y Vector of projected y coordinates. + * @param[out] stat Status return value for each vector element (always 0) + * + * Project native spherical coordinates (phi,theta) to pixel (x,y) + * coordinates in the plane of projection. + * + * This method has been adapted from the wcslib function prj.c::sfls2x(). + * The interface follows very closely that of wcslib. In contrast to the + * wcslib routine, however, the method assumes that the projection has been + * setup previously (as this will be done by the constructor). + ***************************************************************************/ +void GWcsSFL::prj_s2x(int nphi, int ntheta, int spt, int sxy, + const double* phi, const double* theta, + double* x, double* y, int* stat) const +{ + // Initialize projection if required + if (!m_prjset) { + prj_set(); + } + + // Set value replication length mphi,mtheta + int mphi; + int mtheta; + if (ntheta > 0) { + mphi = nphi; + mtheta = ntheta; + } + else { + mphi = 1; + mtheta = 1; + ntheta = nphi; + } + + // Do phi dependence + const double* phip = phi; + int rowoff = 0; + int rowlen = nphi * sxy; + for (int iphi = 0; iphi < nphi; ++iphi, rowoff += sxy, phip += spt) { + double xi = m_w[0] * (*phip); + double* xp = x + rowoff; + for (int itheta = 0; itheta < mtheta; ++itheta, xp += rowlen) { + *xp = xi; + } + } + + // Do theta dependence + const double* thetap = theta; + double* xp = x; + double* yp = y; + int* statp = stat; + for (int itheta = 0; itheta < ntheta; ++itheta, thetap += spt) { + double xi = gammalib::cosd(*thetap); + double eta = m_w[0] * (*thetap) - m_y0; + for (int iphi = 0; iphi < mphi; ++iphi, xp += sxy, yp += sxy) { + *xp = xi * (*xp) - m_x0; + *yp = eta; + *(statp++) = 0; + } + } + + // Return + return; +} diff --git a/src/sky/GWcsSIN.cpp b/src/sky/GWcsSIN.cpp index 739ec6b..e7de769 100644 --- a/src/sky/GWcsSIN.cpp +++ b/src/sky/GWcsSIN.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsSIN.cpp - Orthographic/synthesis (SIN) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2016 by Juergen Knoedlseder * + * copyright (C) 2016-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -300,6 +300,10 @@ void GWcsSIN::free_members(void) ***************************************************************************/ void GWcsSIN::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.assign(4,0.0); @@ -323,9 +327,6 @@ void GWcsSIN::prj_set(void) const // Compute fiducial offset prj_off(0.0, 90.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsSTG.cpp b/src/sky/GWcsSTG.cpp index 876c6cc..6a2f2f4 100644 --- a/src/sky/GWcsSTG.cpp +++ b/src/sky/GWcsSTG.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsSTG.cpp - Stereographic (STG) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2013 by Juergen Knoedlseder * + * copyright (C) 2011-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -292,6 +292,10 @@ void GWcsSTG::free_members(void) ***************************************************************************/ void GWcsSTG::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.clear(); @@ -305,9 +309,6 @@ void GWcsSTG::prj_set(void) const // Compute fiducial offset prj_off(0.0, 90.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/GWcsTAN.cpp b/src/sky/GWcsTAN.cpp index 3f19f1b..e702bc3 100644 --- a/src/sky/GWcsTAN.cpp +++ b/src/sky/GWcsTAN.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GWcsTAN.cpp - Gnomonic (TAN) projection class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2013 by Juergen Knoedlseder * + * copyright (C) 2011-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -290,6 +290,10 @@ void GWcsTAN::free_members(void) ***************************************************************************/ void GWcsTAN::prj_set(void) const { + // Signal that projection has been set (needs to be done before calling + // the prj_off() method to avoid an endless loop) + m_prjset = true; + // Initialise projection parameters m_w.clear(); @@ -301,9 +305,6 @@ void GWcsTAN::prj_set(void) const // Compute fiducial offset prj_off(0.0, 90.0); - // Signal that projection has been set - m_prjset = true; - // Return return; } diff --git a/src/sky/Makefile.am b/src/sky/Makefile.am index c5eec97..dfd3b1f 100644 --- a/src/sky/Makefile.am +++ b/src/sky/Makefile.am @@ -1,7 +1,7 @@ ############################################################################# # Makefile.am for sky module # # ------------------------------------------------------------------------- # -# Copyright (C) 2016 Juergen Knoedlseder # +# Copyright (C) 2016-2017 Juergen Knoedlseder # # ------------------------------------------------------------------------- # # # # This program is free software: you can redistribute it and/or modify # @@ -26,7 +26,7 @@ INCLUDES = -I$(top_srcdir)/include \ # Define sources for this directory sources = GSkyDir.cpp \ - GHorizDir.cpp \ + GHorizDir.cpp \ GSkyPixel.cpp \ GSkyMap.cpp \ GSkyRegions.cpp \ @@ -39,9 +39,11 @@ sources = GSkyDir.cpp \ GWcsAIT.cpp \ GWcsAZP.cpp \ GWcsCAR.cpp \ + GWcsGLS.cpp \ GWcsMER.cpp \ GWcsMOL.cpp \ GWcsSIN.cpp \ + GWcsSFL.cpp \ GWcsSTG.cpp \ GWcsTAN.cpp \ GException_sky.cpp diff --git a/test/test_GSky.py b/test/test_GSky.py index 74ff59f..fd14630 100755 --- a/test/test_GSky.py +++ b/test/test_GSky.py @@ -1,7 +1,7 @@ # ========================================================================== # This module performs unit tests for the GammaLib sky module. # -# Copyright (C) 2012-2016 Juergen Knoedlseder +# Copyright (C) 2012-2017 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -77,8 +77,10 @@ class Test(gammalib.GPythonTestSuite): self.append(self.test_skymap_ait, "Test AIT projection map") self.append(self.test_skymap_azp, "Test AZP projection map") self.append(self.test_skymap_car, "Test CAR projection map") + self.append(self.test_skymap_gls, "Test GLS projection map") self.append(self.test_skymap_mer, "Test MER projection map") self.append(self.test_skymap_mol, "Test MOL projection map") + self.append(self.test_skymap_sfl, "Test SFL projection map") self.append(self.test_skymap_sin, "Test SIN projection map") self.append(self.test_skymap_stg, "Test STG projection map") self.append(self.test_skymap_tan, "Test TAN projection map") @@ -322,6 +324,17 @@ class Test(gammalib.GPythonTestSuite): # Return return + # Test GLS projection + def test_skymap_gls(self): + """ + Test GLS projection. + """ + # Execute generic test + self.test_skymap_proj("GLS") + + # Return + return + # Test MER projection def test_skymap_mer(self): """ @@ -355,6 +368,17 @@ class Test(gammalib.GPythonTestSuite): # Return return + # Test SFL projection + def test_skymap_sfl(self): + """ + Test SFL projection. + """ + # Execute generic test + self.test_skymap_proj("SFL") + + # Return + return + # Test STG projection def test_skymap_stg(self): """