Commit 4cc03484f5012544ce914eef20a2f3dc00b47718

Authored by knodlseder
1 parent cf749332

improvements

src/sky/GWcs.cpp
... ... @@ -57,6 +57,54 @@ GWcs::GWcs(void)
57 57  
58 58  
59 59 /***********************************************************************//**
  60 + * @brief Standard 2D sky map constructor
  61 + *
  62 + * @param[in] coords Coordinate system.
  63 + * @param[in] crval1 X value of reference pixel.
  64 + * @param[in] crval1 Y value of reference pixel.
  65 + * @param[in] crpix1 X index of reference pixel.
  66 + * @param[in] crpix2 Y index of reference pixel.
  67 + * @param[in] cdelt1 Increment in x direction at reference pixel (deg).
  68 + * @param[in] cdelt2 Increment in y direction at reference pixel (deg).
  69 + *
  70 + * Construct standard 2D sky map from standard definition parameters. This
  71 + * method
  72 + ***************************************************************************/
  73 +GWcs::GWcs(const std::string& coords,
  74 + const double& crval1, const double& crval2,
  75 + const double& crpix1, const double& crpix2,
  76 + const double& cdelt1, const double& cdelt2)
  77 +
  78 +{
  79 + // Initialise class members
  80 + init_members();
  81 +
  82 + //TODO: Check parameters
  83 +
  84 + // Set coordinate system
  85 + coordsys(coords);
  86 +
  87 + // Set parameters
  88 + m_crval[0] = crval1;
  89 + m_crval[1] = crval2;
  90 + m_crpix[0] = crpix1;
  91 + m_crpix[1] = crpix2;
  92 + m_cdelt[0] = cdelt1;
  93 + m_cdelt[1] = cdelt2;
  94 +
  95 + // Set standard CD without rotation is a unit matrix
  96 + m_cd(0,0) = m_cd(1,1) = 1.0;
  97 + m_cd(0,1) = m_cd(1,0) = 0.0;
  98 +
  99 + // Compute inverse CD matrix
  100 + m_invcd = invert(m_cd); //NOTE: invert method not yet implemented
  101 +
  102 + // Return
  103 + return;
  104 +}
  105 +
  106 +
  107 +/***********************************************************************//**
60 108 * @brief Copy constructor
61 109 *
62 110 * @param wcs GWcs instance which should be used for construction
... ... @@ -135,9 +183,9 @@ void GWcs::read(const GFitsHDU* hdu)
135 183 // Free memory and initialise members
136 184 free_members();
137 185 init_members();
138   -
  186 +
139 187 //TODO: Implement WCS definition reading
140   -
  188 +
141 189 // Return
142 190 return;
143 191 }
... ... @@ -189,7 +237,8 @@ std::string GWcs::coordsys(void) const
189 237 *
190 238 * @param[in] coordsys Coordinate system (EQU/CEL/E/C or GAL/G)
191 239 *
192   - * @exception GException::wcs_bad_coords Invalid coordsys parameter.
  240 + * @exception GException::wcs_bad_coords
  241 + * Invalid coordsys parameter.
193 242 ***************************************************************************/
194 243 void GWcs::coordsys(const std::string& coordsys)
195 244 {
... ... @@ -222,8 +271,7 @@ void GWcs::coordsys(const std::string& coordsys)
222 271 void GWcs::init_members(void)
223 272 {
224 273 // Initialise members
225   -// m_ctype[0].clear();
226   -// m_ctype[1].clear();
  274 + m_coordsys = 0;
227 275 m_cdelt[0] = 0.0;
228 276 m_cdelt[1] = 0.0;
229 277 m_crpix[0] = 0.0;
... ... @@ -232,9 +280,9 @@ void GWcs::init_members(void)
232 280 m_crval[1] = 0.0;
233 281 m_longpole = 180.0;
234 282 m_latpole = 0.0;
235   - m_pv2[0] = 0.0;
236   - m_pv2[1] = 0.0;
237   - m_coordsys = 0;
  283 + m_cd = GMatrix(2,2);
  284 + m_invcd = GMatrix(2,2);
  285 + m_pv2 = GVector(21);
238 286  
239 287 // Return
240 288 return;
... ... @@ -249,8 +297,7 @@ void GWcs::init_members(void)
249 297 void GWcs::copy_members(const GWcs& wcs)
250 298 {
251 299 // Copy attributes
252   -// m_ctype[0] = wcs.m_ctype[0];
253   -// m_ctype[1] = wcs.m_ctype[1];
  300 + m_coordsys = wcs.m_coordsys;
254 301 m_cdelt[0] = wcs.m_cdelt[0];
255 302 m_cdelt[1] = wcs.m_cdelt[1];
256 303 m_crpix[0] = wcs.m_crpix[0];
... ... @@ -259,9 +306,9 @@ void GWcs::copy_members(const GWcs& wcs)
259 306 m_crval[1] = wcs.m_crval[1];
260 307 m_longpole = wcs.m_longpole;
261 308 m_latpole = wcs.m_latpole;
262   - m_pv2[0] = wcs.m_pv2[0];
263   - m_pv2[1] = wcs.m_pv2[1];
264   - m_coordsys = wcs.m_coordsys;
  309 + m_cd = wcs.m_cd;
  310 + m_invcd = wcs.m_invcd;
  311 + m_pv2 = wcs.m_pv2;
265 312  
266 313 // Return
267 314 return;
... ... @@ -278,46 +325,6 @@ void GWcs::free_members(void)
278 325 }
279 326  
280 327  
281   -/***********************************************************************//**
282   - * @brief Constructor
283   - *
284   - * @param[in] crval Coordinates of reference pixel.
285   - * @param[in] crpix1 X coordinate of reference pixel.
286   - * @param[in] crpix2 Y coordinate of reference pixel.
287   - * @param[in] cdelt1 X increment at reference point in degrees/pixel.
288   - * @param[in] cdelt2 Y increment at reference point in degrees/pixel.
289   - * @param[in] coords Coordinate system ('EQU' or 'GAL').
290   - ***************************************************************************/
291   -void GWcs::set_wcs(const double& crval1, const double& crval2,
292   - const double& crpix1, const double& crpix2,
293   - const double& cdelt1, const double& cdelt2,
294   - const std::string& coords,
295   - const double* cd, const double* pv)
296   -{
297   - // Initialise class members
298   - init_members();
299   -
300   - // Set members
301   - m_crval[0] = crval1;
302   - m_crval[1] = crval2;
303   - m_crpix[0] = crpix1;
304   - m_crpix[1] = crpix2;
305   - m_cdelt[0] = cdelt1;
306   - m_cdelt[1] = cdelt2;
307   -
308   - // Set coordinate system
309   - coordsys(coords);
310   -
311   - // TODO: Set CD
312   -
313   - // TODO: Compute inverted CD
314   - //cdinv=invert(ds)
315   -
316   - // Return
317   - return;
318   -}
319   -
320   -
321 328 /*==========================================================================
322 329 = =
323 330 = GWcs friends =
... ...
src/sky/GWcsCAR.cpp
... ... @@ -60,16 +60,23 @@ GWcsCAR::GWcsCAR(void) : GWcs()
60 60 /***********************************************************************//**
61 61 * @brief Constructor
62 62 *
63   - * @param[in] crval Coordinates of reference pixel.
64   - * @param[in] crpix1 X coordinate of reference pixel.
65   - * @param[in] crpix2 Y coordinate of reference pixel.
66   - * @param[in] cdelt1 X increment at reference point in degrees/pixel.
67   - * @param[in] cdelt2 Y increment at reference point in degrees/pixel.
68   - * @param[in] coords Coordinate system ('EQU' or 'GAL').
  63 + * @param[in] coords Coordinate system.
  64 + * @param[in] crval1 X value of reference pixel.
  65 + * @param[in] crval1 Y value of reference pixel.
  66 + * @param[in] crpix1 X index of reference pixel.
  67 + * @param[in] crpix2 Y index of reference pixel.
  68 + * @param[in] cdelt1 Increment in x direction at reference pixel (deg).
  69 + * @param[in] cdelt2 Increment in y direction at reference pixel (deg).
  70 + * @param[in] cd Astrometry parameters (2x2 matrix, deg/pixel).
  71 + * @param[in] pv2 Projection parameters (length WCS type dependent).
69 72 ***************************************************************************/
70   -GWcsCAR::GWcsCAR(GSkyDir& crval, const double& crpix1, const double& crpix2,
  73 +GWcsCAR::GWcsCAR(const std::string& coords,
  74 + const double& crval1, const double& crval2,
  75 + const double& crpix1, const double& crpix2,
71 76 const double& cdelt1, const double& cdelt2,
72   - const std::string& coords) : GWcs()
  77 + const GMatrix& cd, const GVector& pv2) :
  78 + GWcs(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2)
  79 +
73 80 {
74 81 // Initialise class members
75 82 init_members();
... ...