Commit a74b1b856f1697dfb8b8a7c5de84045aac141d22
1 parent
0b4b83c2
extension number starts from 0
Showing
2 changed files
with
8 additions
and
8 deletions
include/GFits.hpp
| ... | ... | @@ -55,8 +55,8 @@ public: |
| 55 | 55 | void save(void); |
| 56 | 56 | void saveto(const std::string& filename, int clobber = 0); |
| 57 | 57 | void close(void); |
| 58 | - GFitsHDU* hdu(const std::string& extname); | |
| 59 | - GFitsHDU* hdu(int extno); | |
| 58 | + GFitsHDU* hdu(const std::string& extname) const; | |
| 59 | + GFitsHDU* hdu(int extno) const; | |
| 60 | 60 | int num_hdus(void) const; |
| 61 | 61 | |
| 62 | 62 | private: | ... | ... |
src/fits/GFits.cpp
| ... | ... | @@ -368,7 +368,7 @@ void GFits::close(void) |
| 368 | 368 | * HDU with specified extension name has not been found in FITS |
| 369 | 369 | * file. |
| 370 | 370 | ***************************************************************************/ |
| 371 | -GFitsHDU* GFits::hdu(const std::string& extname) | |
| 371 | +GFitsHDU* GFits::hdu(const std::string& extname) const | |
| 372 | 372 | { |
| 373 | 373 | // Initialise result to NULL pointer |
| 374 | 374 | GFitsHDU* ptr = NULL; |
| ... | ... | @@ -393,20 +393,20 @@ GFitsHDU* GFits::hdu(const std::string& extname) |
| 393 | 393 | /***********************************************************************//** |
| 394 | 394 | * @brief Get pointer to HDU |
| 395 | 395 | * |
| 396 | - * @param extno[in] Extension number (starting from 1) | |
| 396 | + * @param extno[in] Extension number (starting from 0) | |
| 397 | 397 | * |
| 398 | 398 | * @exception GException::fits_hdu_not_found |
| 399 | 399 | * HDU with specified extension number has not been found in FITS |
| 400 | 400 | * file. |
| 401 | 401 | ***************************************************************************/ |
| 402 | -GFitsHDU* GFits::hdu(int extno) | |
| 402 | +GFitsHDU* GFits::hdu(int extno) const | |
| 403 | 403 | { |
| 404 | 404 | // Verify that extension number is in valid range |
| 405 | - if (extno < 1 || extno > m_num_hdu) | |
| 406 | - throw GException::out_of_range("GFits::hdu(int)", extno, 1, m_num_hdu); | |
| 405 | + if (extno < 0 || extno >= m_num_hdu) | |
| 406 | + throw GException::out_of_range("GFits::hdu(int)", extno, 0, m_num_hdu-1); | |
| 407 | 407 | |
| 408 | 408 | // Get HDU pointer |
| 409 | - GFitsHDU* ptr = &(m_hdu[extno-1]); | |
| 409 | + GFitsHDU* ptr = &(m_hdu[extno]); | |
| 410 | 410 | |
| 411 | 411 | // Throw an error if HDU has not been found |
| 412 | 412 | if (ptr == NULL) { | ... | ... |