Commit 77216649bf82472cb9bc7f7e6da00502319b8603

Authored by Jürgen Knödlseder
1 parent 1ea91214

GWcs::wcs_set() method now sets radesys and equinox members (#2866)

ChangeLog
1   -2019-04-03
  1 +2019-04-08
2 2  
3 3 * Version 1.6.0 released
4 4 ========================
5 5  
  6 + GWcs::wcs_set() method now sets radesys and equinox members (#2866)
6 7 Add GCTAPointing::is_valid() method and remove table methods
7 8 Set CTA IRF integration iterations to 6 to cope with H.E.S.S. PSF (#2860)
8 9 Add kludge to handle incomplete Fermi-LAT source maps (#2850)
... ...
1 1 New Features and Important Changes in GammaLib 1.6.0
2 2  
3   -3 April 2019
  3 +8 April 2019
4 4  
5 5  
6 6 1. Introduction
... ... @@ -251,6 +251,10 @@ None
251 251  
252 252 12. Sky module
253 253 --------------
  254 +The GWcs::wcs_set() method now sets m_radesys and m_equinox members through the
  255 +new protected GWcs::wcs_set_radesys() method. By default, sky maps now have
  256 +a RADECSYS=ICRS keyword (#2866).
  257 +
254 258 An OpenMP locking mechanism was added to GWcs::dir2pix that improves the speed of
255 259 the code parallelization by avoiding mutual lockups of the threads (#2770).
256 260  
... ...
doc/source/admin/release_history/1.6.rst
... ... @@ -19,6 +19,8 @@ In particular, this release provides:
19 19 Bug fixes
20 20 ---------
21 21  
  22 +* [`2866 <https://cta-redmine.irap.omp.eu/issues/2866>`_] -
  23 + ``GWcs::wcs_set()`` method now sets radesys and equinox members
22 24 * [`2860 <https://cta-redmine.irap.omp.eu/issues/2860>`_] -
23 25 Set CTA IRF integration iterations to 6 to cope with H.E.S.S. PSF
24 26 * [`2838 <https://cta-redmine.irap.omp.eu/issues/2838>`_] -
... ...
include/GWcs.hpp
... ... @@ -62,7 +62,7 @@ public:
62 62 virtual ~GWcs(void);
63 63  
64 64 // Operators
65   - virtual GWcs& operator= (const GWcs& wcs);
  65 + virtual GWcs& operator=(const GWcs& wcs);
66 66  
67 67 // Pure virtual base class methods
68 68 virtual void clear(void) = 0;
... ... @@ -104,11 +104,12 @@ protected:
104 104 const double& crpix1, const double& crpix2,
105 105 const double& cdelt1, const double& cdelt2);
106 106 virtual bool compare(const GSkyProjection& proj) const;
107   - bool undefined(const double& value) const { return (value==UNDEFINED); }
  107 + bool undefined(const double& value) const;
108 108  
109 109 // Methods adapted from wcslib::wcs.c
110 110 void wcs_ini(int naxis);
111 111 void wcs_set(void) const;
  112 + void wcs_set_radesys(void) const;
112 113 void wcs_set_ctype(void) const;
113 114 void wcs_p2s(int ncoord, int nelem, const double* pixcrd, double* imgcrd,
114 115 double* phi, double* theta, double* world, int* stat) const;
... ... @@ -177,8 +178,8 @@ protected:
177 178 mutable double m_latpole; //!< LATPOLEa keyvalue
178 179 double m_restfrq; //!< RESTFRQa keyvalue
179 180 double m_restwav; //!< RESTWAVa keyvalue
180   - std::string m_radesys; //!< RADESYS keyvalue
181   - double m_equinox; //!< EQUINOX keyvalue
  181 + mutable std::string m_radesys; //!< RADESYS keyvalue
  182 + mutable double m_equinox; //!< EQUINOX keyvalue
182 183 std::vector<double> m_cd; //!< CDi_ja linear transformation matrix
183 184 std::vector<double> m_crota; //!< CROTAia keyvalues for each coord axis
184 185 int m_lng; //!< Longitude axis
... ... @@ -252,6 +253,19 @@ int GWcs::size(void) const
252 253  
253 254  
254 255 /***********************************************************************//**
  256 + * @brief Check if value is undefined
  257 + *
  258 + * @param[in] value Value to check
  259 + * @return True if @p value is undefined, false otherwise
  260 + ***************************************************************************/
  261 +inline
  262 +bool GWcs::undefined(const double& value) const
  263 +{
  264 + return (value==UNDEFINED);
  265 +}
  266 +
  267 +
  268 +/***********************************************************************//**
255 269 * @brief Initializes an OpenMP lock with a specific name
256 270 *
257 271 * @param[in] lock_id Identifier of the lock that should be initialized
... ...
src/sky/GWcs.cpp
... ... @@ -299,6 +299,16 @@ void GWcs::read(const GFitsHDU&amp; hdu)
299 299 // Set standard parameters
300 300 set_members(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2);
301 301  
  302 + // Optionally read "RADESYS" and "EQUINOX" keywords (needs to come
  303 + // before wcs_set() since the method will eventually complement
  304 + // missing keywords)
  305 + if (hdu.has_card("RADESYS")) {
  306 + m_radesys = hdu.string("RADESYS");
  307 + }
  308 + if (hdu.has_card("EQUINOX")) {
  309 + m_equinox = hdu.real("EQUINOX");
  310 + }
  311 +
302 312 // Setup WCS derived parameters
303 313 wcs_set();
304 314  
... ... @@ -1282,6 +1292,9 @@ void GWcs::wcs_set(void) const
1282 1292 // Initialize the linear transformation
1283 1293 lin_set();
1284 1294  
  1295 + // Set defaults for radesys and equinox
  1296 + wcs_set_radesys();
  1297 +
1285 1298 // Signal that WCS is set
1286 1299 m_wcsset = true;
1287 1300  
... ... @@ -1291,6 +1304,68 @@ void GWcs::wcs_set(void) const
1291 1304  
1292 1305  
1293 1306 /***********************************************************************//**
  1307 + * @brief Set radesys and equinox members
  1308 + *
  1309 + * Set default values for radesys and equinox for equatorial, ecliptic or
  1310 + * helioecliptic coordinates. For other coordinates the radesys and equinox
  1311 + * members are set to empty/undefined values.
  1312 + *
  1313 + * This method has been inspired by code from wcs.c::wcsset.
  1314 + ***************************************************************************/
  1315 +void GWcs::wcs_set_radesys(void) const
  1316 +{
  1317 + // Set defaults for radesys and equinox for equatorial, ecliptic or
  1318 + // helioecliptic coordinates
  1319 + if ((m_coordsys == 0) || (m_coordsys == 2) || (m_coordsys == 3)) {
  1320 +
  1321 + // If radesys is undefined then set it dependend on the equinox.
  1322 + // If equinox is undefined then use "ICRS", otherwise use "FK4" if
  1323 + // equinox is smaller than 1984 and "FK5" for later equinoxes
  1324 + if (m_radesys.empty()) {
  1325 + if (undefined(m_equinox)) {
  1326 + m_radesys = "ICRS";
  1327 + }
  1328 + else if (m_equinox < 1984.0) {
  1329 + m_radesys = "FK4";
  1330 + }
  1331 + else {
  1332 + m_radesys = "FK5";
  1333 + }
  1334 + }
  1335 +
  1336 + // ... otherwise, if radesys is "ICRS" or "GAPPT" then set the equinox
  1337 + // to undefined since the equinox is not applicable for these coordinate
  1338 + // systems
  1339 + else if ((m_radesys == "ICRS") || (m_radesys == "GAPPT")) {
  1340 + m_equinox = UNDEFINED;
  1341 + }
  1342 +
  1343 + // ... otherwise, if equinox is undefined and radesys is "FK5" then
  1344 + // set equinox to 2000.0 and if RADESYS is "FK4" or "FK4-NO-E" then
  1345 + // set equinox to 1950.0
  1346 + else if (undefined(m_equinox)) {
  1347 + if (m_radesys == "FK5") {
  1348 + m_equinox = 2000.0;
  1349 + }
  1350 + else if ((m_radesys == "FK4") || (m_radesys == "FK4-NO-E")) {
  1351 + m_equinox = 1950.0;
  1352 + }
  1353 + }
  1354 +
  1355 + } // endif: coordinate system requires RADESYS
  1356 +
  1357 + // ... otherwise reset radesys and set equinox to undefined
  1358 + else {
  1359 + m_radesys.clear();
  1360 + m_equinox = UNDEFINED;
  1361 + }
  1362 +
  1363 + // Return
  1364 + return;
  1365 +}
  1366 +
  1367 +
  1368 +/***********************************************************************//**
1294 1369 * @brief Set CTYPEa keywords
1295 1370 *
1296 1371 * @exception GException::wcs_invalid
... ...