diff --git a/include/GFitsAsciiTable.hpp b/include/GFitsAsciiTable.hpp index cfdac19..482ad1f 100644 --- a/include/GFitsAsciiTable.hpp +++ b/include/GFitsAsciiTable.hpp @@ -40,7 +40,7 @@ public: GFitsAsciiTable& operator= (const GFitsAsciiTable& table); // Methods - void open(__fitsfile* fptr); + void open(__fitsfile* fptr); void close(void); GFitsAsciiTable* clone(void) const; GFitsTableCol* column(const std::string colname); diff --git a/include/GFitsBinTable.hpp b/include/GFitsBinTable.hpp index fe08573..37b08c5 100644 --- a/include/GFitsBinTable.hpp +++ b/include/GFitsBinTable.hpp @@ -15,7 +15,7 @@ #define GFITSBINTABLE_HPP /* __ Includes ___________________________________________________________ */ -#include +//#include #include "GFitsCfitsio.hpp" #include "GFitsData.hpp" #include "GFitsTableCol.hpp" @@ -44,7 +44,7 @@ public: GFitsBinTable& operator= (const GFitsBinTable& table); // Methods - void open(__fitsfile* fptr); + void open(__fitsfile* fptr); void close(void); GFitsBinTable* clone(void) const; GFitsTableCol* column(const std::string colname); diff --git a/include/GFitsCfitsio.hpp b/include/GFitsCfitsio.hpp index 13f6820..4708053 100644 --- a/include/GFitsCfitsio.hpp +++ b/include/GFitsCfitsio.hpp @@ -88,7 +88,10 @@ typedef fitsfile __fitsfile; #define __TDBLCOMPLEX 163 /* __ Type definition ____________________________________________________ */ -typedef int __fitsfile; +typedef struct { + int HDUposition; // HDU position in file; 0 = first HDU + int* Fptr; // Pointer to FITS file structure +} __fitsfile; /* __ Dummy function _____________________________________________________ */ inline diff --git a/include/GFitsData.hpp b/include/GFitsData.hpp index 057fb76..4fb1177 100644 --- a/include/GFitsData.hpp +++ b/include/GFitsData.hpp @@ -35,7 +35,7 @@ public: virtual GFitsData& operator= (const GFitsData& data); // Methods - virtual void open(__fitsfile* fptr) = 0; + virtual void open(__fitsfile* fptr) = 0; virtual void close(void) = 0; virtual GFitsData* clone(void) const = 0; diff --git a/include/GFitsHDU.hpp b/include/GFitsHDU.hpp index e07e06e..7b6b767 100644 --- a/include/GFitsHDU.hpp +++ b/include/GFitsHDU.hpp @@ -42,26 +42,24 @@ public: GFitsHDU& operator= (const GFitsHDU& hdu); // Methods - void open(__fitsfile* fptr, int hdunum); + void open(__fitsfile* fptr, int hdunum); void save(void); std::string extname(void) const; int extno(void) const; int exttype(void) const; GFitsHeader* header(void) const; GFitsData* data(void) const; - GFitsTableCol* column(const std::string colname) const; + GFitsTableCol* column(const std::string& colname) const; private: // Private methods void init_members(void); void copy_members(const GFitsHDU& hdu); void free_members(void); - void move2hdu(void); // Private data area - __fitsfile* m_fitsfile; // FITS file pointer + __fitsfile m_fitsfile; // FITS file pointer std::string m_name; // HDU name - int m_num; // HDU number (starting from 1) int m_type; // HDU type GFitsHeader* m_header; // HDU header GFitsData* m_data; // HDU data @@ -72,7 +70,7 @@ private: * Inline methods * ***************************************************************************/ inline std::string GFitsHDU::extname(void) const { return m_name; } -inline int GFitsHDU::extno(void) const { return m_num; } +inline int GFitsHDU::extno(void) const { return m_fitsfile.HDUposition; } inline int GFitsHDU::exttype(void) const { return m_type; } inline GFitsHeader* GFitsHDU::header(void) const { return m_header; } inline GFitsData* GFitsHDU::data(void) const { return m_data; } diff --git a/include/GFitsHeader.hpp b/include/GFitsHeader.hpp index c642c6c..d2ab72d 100644 --- a/include/GFitsHeader.hpp +++ b/include/GFitsHeader.hpp @@ -39,7 +39,7 @@ public: GFitsHeader& operator= (const GFitsHeader& header); // Methods - void open(__fitsfile* fptr); + void open(__fitsfile* fptr); void close(void); GFitsHeaderCard* card(const std::string keyname); GFitsHeaderCard* card(const int cardno); diff --git a/include/GFitsImage.hpp b/include/GFitsImage.hpp index 223e4d1..53af0e3 100644 --- a/include/GFitsImage.hpp +++ b/include/GFitsImage.hpp @@ -26,6 +26,9 @@ ***************************************************************************/ class GFitsImage : public GFitsData { + // I/O friends + friend ostream& operator<< (ostream& os, const GFitsImage& image); + public: // Constructors and destructors GFitsImage(); @@ -36,7 +39,7 @@ public: GFitsImage& operator= (const GFitsImage& image); // Methods - void open(__fitsfile* fptr); + void open(__fitsfile* fptr); void close(void); GFitsImage* clone(void) const; diff --git a/include/GFitsTableCol.hpp b/include/GFitsTableCol.hpp index 92422d8..d195be1 100644 --- a/include/GFitsTableCol.hpp +++ b/include/GFitsTableCol.hpp @@ -71,7 +71,7 @@ protected: int m_repeat; int m_width; int m_length; - __fitsfile* m_fitsfile; + __fitsfile m_fitsfile; private: // Private methods @@ -90,7 +90,7 @@ inline void GFitsTableCol::set_type(const int type) { m_type = type; } inline void GFitsTableCol::set_repeat(const int repeat) { m_repeat = repeat; } inline void GFitsTableCol::set_width(const int width) { m_width = width; } inline void GFitsTableCol::set_length(const int length) { m_length = length; } -inline void GFitsTableCol::set_fitsfile(const __fitsfile* fptr) { m_fitsfile = (__fitsfile*)fptr; } +inline void GFitsTableCol::set_fitsfile(const __fitsfile* fptr) { m_fitsfile = *fptr; } inline std::string GFitsTableCol::name(void) { return m_name; } inline int GFitsTableCol::colnum(void) { return m_colnum; } inline int GFitsTableCol::type(void) { return m_type; } diff --git a/src/fits/GFitsAsciiTable.cpp b/src/fits/GFitsAsciiTable.cpp index fe03578..1d1e538 100644 --- a/src/fits/GFitsAsciiTable.cpp +++ b/src/fits/GFitsAsciiTable.cpp @@ -13,9 +13,14 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ +#include #include "GException.hpp" #include "GFitsAsciiTable.hpp" -#include // cout, cerr +#include "GFitsTableStrCol.hpp" +#include "GFitsTableShtCol.hpp" +#include "GFitsTableLngCol.hpp" +#include "GFitsTableFltCol.hpp" +#include "GFitsTableDblCol.hpp" /* __ Namespaces _________________________________________________________ */ @@ -124,6 +129,7 @@ GFitsAsciiTable& GFitsAsciiTable::operator= (const GFitsAsciiTable& table) * Open Table * * ----------------------------------------------------------------------- * ***************************************************************************/ +/// NOT YET IMPLEMENTED void GFitsAsciiTable::open(__fitsfile* fptr) { cout << "open ASCII table" << endl; @@ -192,8 +198,6 @@ GFitsTableCol* GFitsAsciiTable::column(const int colnum) } - - /*========================================================================== = = = GFitsAsciiTable private methods = @@ -275,7 +279,7 @@ ostream& operator<< (ostream& os, const GFitsAsciiTable& table) os << " Number of rows ............: " << table.m_rows << endl; os << " Number of columns .........: " << table.m_cols << endl; for (int i = 0; i < table.m_cols; ++i) - os << i; + os << " " << *(table.m_columns[i]); // Return output stream return os; diff --git a/src/fits/GFitsBinTable.cpp b/src/fits/GFitsBinTable.cpp index bb9bc8f..24e51cc 100644 --- a/src/fits/GFitsBinTable.cpp +++ b/src/fits/GFitsBinTable.cpp @@ -13,6 +13,7 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ +#include #include "GException.hpp" #include "GTools.hpp" #include "GFitsBinTable.hpp" @@ -21,7 +22,6 @@ #include "GFitsTableLngCol.hpp" #include "GFitsTableFltCol.hpp" #include "GFitsTableDblCol.hpp" -#include // cout, cerr /* __ Namespaces _________________________________________________________ */ @@ -132,8 +132,13 @@ GFitsBinTable& GFitsBinTable::operator= (const GFitsBinTable& table) ***************************************************************************/ void GFitsBinTable::open(__fitsfile* fptr) { + // Move to HDU + int status = 0; + status = __ffmahd(fptr, (fptr->HDUposition)+1, NULL, &status); + if (status != 0) + throw GException::fits_error(G_OPEN, status); + // Determine number of rows in table - int status = 0; long nrows = 0; status = __ffgnrw(fptr, &nrows, &status); if (status != 0) diff --git a/src/fits/GFitsData.cpp b/src/fits/GFitsData.cpp index 9128895..ba98614 100644 --- a/src/fits/GFitsData.cpp +++ b/src/fits/GFitsData.cpp @@ -116,37 +116,10 @@ GFitsData& GFitsData::operator= (const GFitsData& data) = = ==========================================================================*/ -/*************************************************************************** - * Open Data * - * ----------------------------------------------------------------------- * - ***************************************************************************/ -void GFitsData::open(__fitsfile* fptr) -{ - // Return - return; -} - - -/*************************************************************************** - * Close Data * - * ----------------------------------------------------------------------- * - ***************************************************************************/ -void GFitsData::close(void) -{ - // Free members - free_members(); - - // Initialise members - init_members(); - - // Return - return; -} - /*========================================================================== = = - = GFitsData private methods = + = GFitsData private methods = = = ==========================================================================*/ diff --git a/src/fits/GFitsHDU.cpp b/src/fits/GFitsHDU.cpp index 24f76f9..ddb4133 100644 --- a/src/fits/GFitsHDU.cpp +++ b/src/fits/GFitsHDU.cpp @@ -13,17 +13,17 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ +#include #include "GException.hpp" #include "GTools.hpp" #include "GFitsHDU.hpp" -#include // cout, cerr /* __ Namespaces _________________________________________________________ */ /* __ Method name definitions ____________________________________________ */ #define G_OPEN "GFitsHDU::open(int)" -#define G_COLUMN "GFitsHDU::column(std::string)" -#define G_MOVE2HDU "GFitsHDU::move2hdu(void)" +#define G_SAVE "GFitsHDU::save()" +#define G_COLUMN "GFitsHDU::column(const std::string&)" /* __ Macros _____________________________________________________________ */ @@ -127,23 +127,25 @@ GFitsHDU& GFitsHDU::operator= (const GFitsHDU& hdu) ***************************************************************************/ void GFitsHDU::open(__fitsfile* fptr, int hdunum) { - // Store information - m_fitsfile = fptr; - m_num = hdunum; - // Move to HDU - move2hdu(); + int status = 0; + status = __ffmahd(fptr, hdunum, NULL, &status); + if (status != 0) + throw GException::fits_error(G_OPEN, status); + + // Store information. + // Note that the HDU number - 1 is stored in m_fitsfile->HDUposition !!! + m_fitsfile = *fptr; // Get HDU type - int status = 0; - status = __ffghdt(m_fitsfile, &m_type, &status); + status = __ffghdt(&m_fitsfile, &m_type, &status); if (status != 0) throw GException::fits_error(G_OPEN, status); // Allocate and open HDU header if (m_header != NULL) delete m_header; m_header = new GFitsHeader(); - m_header->open(m_fitsfile); + m_header->open(&m_fitsfile); // Open HDU data area if (m_data != NULL) delete m_data; @@ -161,7 +163,7 @@ void GFitsHDU::open(__fitsfile* fptr, int hdunum) throw GException::fits_unknown_HDU_type(G_OPEN, m_type); break; } - m_data->open(m_fitsfile); + m_data->open(&m_fitsfile); // Get HDU name from header m_name = strip_whitespace(m_header->string("EXTNAME")); @@ -172,8 +174,6 @@ void GFitsHDU::open(__fitsfile* fptr, int hdunum) m_name = "NoName"; } - //cout << "HDU #" << hdunum << ": " << m_type << " : " << m_name << endl; - // Return return; } @@ -183,10 +183,14 @@ void GFitsHDU::open(__fitsfile* fptr, int hdunum) * Save HDU to FITS file * * ----------------------------------------------------------------------- * ***************************************************************************/ +/// NOT YET IMPLEMENTED !!! void GFitsHDU::save(void) { // Move to HDU - move2hdu(); + int status = 0; + status = __ffmahd(&m_fitsfile, (m_fitsfile.HDUposition)+1, NULL, &status); + if (status != 0) + throw GException::fits_error(G_SAVE, status); // Save header //... @@ -198,11 +202,12 @@ void GFitsHDU::save(void) return; } + /*************************************************************************** * Return pointer to column of table * * ----------------------------------------------------------------------- * ***************************************************************************/ -GFitsTableCol* GFitsHDU::column(const std::string colname) const +GFitsTableCol* GFitsHDU::column(const std::string& colname) const { // Initialise pointer GFitsTableCol* ptr = NULL; @@ -241,10 +246,12 @@ GFitsTableCol* GFitsHDU::column(const std::string colname) const void GFitsHDU::init_members(void) { // Initialise members - m_fitsfile = NULL; - m_type = 0; - m_header = NULL; - m_data = NULL; + m_fitsfile.HDUposition = 0; + m_fitsfile.Fptr = NULL; + m_name.clear(); + m_type = 0; + m_header = NULL; + m_data = NULL; // Return return; @@ -254,21 +261,15 @@ void GFitsHDU::init_members(void) /*************************************************************************** * Copy class members * * ----------------------------------------------------------------------- * - * The function does not copy the FITS file pointer. This prevents that * - * several copies of the FITS file pointer exist in different instances of * - * GFitsHDU, which would lead to confusion since one instance could close * - * the file while for another it still would be opened. * - * The rule ONE INSTANCE - ONE FILE applies. * ***************************************************************************/ void GFitsHDU::copy_members(const GFitsHDU& hdu) { - // Reset FITS file attributes - m_fitsfile = NULL; - - // Copy other membres - m_type = hdu.m_type; - m_header = hdu.m_header->clone(); - m_data = hdu.m_data->clone(); + // Copy members + m_fitsfile = hdu.m_fitsfile; + m_name = hdu.m_name; + m_type = hdu.m_type; + m_header = hdu.m_header->clone(); + m_data = hdu.m_data->clone(); // Return return; @@ -294,23 +295,6 @@ void GFitsHDU::free_members(void) } -/*************************************************************************** - * Move FITS file pointer to HDU * - * ----------------------------------------------------------------------- * - ***************************************************************************/ -void GFitsHDU::move2hdu(void) -{ - // Move FITS file pointer to HDU - int status = 0; - status = __ffmahd(m_fitsfile, m_num, NULL, &status); - if (status != 0) - throw GException::fits_error(G_MOVE2HDU, status); - - // Return - return; -} - - /*========================================================================== = = = GFitsHDU friends = @@ -325,7 +309,7 @@ ostream& operator<< (ostream& os, const GFitsHDU& hdu) { // Put header in stream os << "=== GFitsHDU ===" << endl; - os << " HDU number ................: " << hdu.m_num << endl; + os << " HDU number ................: " << hdu.m_fitsfile.HDUposition << endl; os << " HDU name ..................: " << hdu.m_name << endl; os << " HDU type ..................: "; switch (hdu.m_type) { @@ -345,7 +329,7 @@ ostream& operator<< (ostream& os, const GFitsHDU& hdu) os << *hdu.m_header; switch (hdu.m_type) { case 0: // Image HDU - os << "Image"; + os << *(GFitsImage*)hdu.m_data; break; case 1: // ASCII Table HDU os << *(GFitsAsciiTable*)hdu.m_data; diff --git a/src/fits/GFitsHeader.cpp b/src/fits/GFitsHeader.cpp index 4156c5c..04aeb2d 100644 --- a/src/fits/GFitsHeader.cpp +++ b/src/fits/GFitsHeader.cpp @@ -13,9 +13,9 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ +#include #include "GException.hpp" #include "GFitsHeader.hpp" -#include // cout, cerr /* __ Namespaces _________________________________________________________ */ @@ -124,9 +124,14 @@ GFitsHeader& GFitsHeader::operator= (const GFitsHeader& header) ***************************************************************************/ void GFitsHeader::open(__fitsfile* fptr) { - // Determine number of cards in header + // Move to HDU int status = 0; - status = __ffghsp(fptr, &m_num_cards, NULL, &status); + status = __ffmahd(fptr, (fptr->HDUposition)+1, NULL, &status); + if (status != 0) + throw GException::fits_error(G_OPEN, status); + + // Determine number of cards in header + status = __ffghsp(fptr, &m_num_cards, NULL, &status); if (status != 0) throw GException::fits_error(G_OPEN, status); diff --git a/src/fits/GFitsHeaderCard.cpp b/src/fits/GFitsHeaderCard.cpp index 026c083..9446459 100644 --- a/src/fits/GFitsHeaderCard.cpp +++ b/src/fits/GFitsHeaderCard.cpp @@ -229,12 +229,17 @@ int GFitsHeaderCard::integer(void) ***************************************************************************/ void GFitsHeaderCard::read(__fitsfile* fptr, int keynum) { + // Move to HDU + int status = 0; + status = __ffmahd(fptr, (fptr->HDUposition)+1, NULL, &status); + if (status != 0) + throw GException::fits_error(G_READ_NUM, status); + // Read keyword char keyname[80]; char value[80]; char comment[80]; - int status = 0; - status = __ffgkyn(fptr, keynum, keyname, value, comment, &status); + status = __ffgkyn(fptr, keynum, keyname, value, comment, &status); if (status != 0) throw GException::fits_error(G_READ_NUM, status); @@ -257,11 +262,16 @@ void GFitsHeaderCard::read(__fitsfile* fptr, int keynum) ***************************************************************************/ void GFitsHeaderCard::read(__fitsfile* fptr, std::string keyname) { + // Move to HDU + int status = 0; + status = __ffmahd(fptr, (fptr->HDUposition)+1, NULL, &status); + if (status != 0) + throw GException::fits_error(G_READ_NUM, status); + // Read keyword char value[80]; char comment[80]; - int status = 0; - status = __ffgkey(fptr, (char*)keyname.c_str(), value, comment, &status); + status = __ffgkey(fptr, (char*)keyname.c_str(), value, comment, &status); // Catch error if (status == 202) // Keyword not found @@ -288,10 +298,15 @@ void GFitsHeaderCard::read(__fitsfile* fptr, std::string keyname) ***************************************************************************/ void GFitsHeaderCard::write(__fitsfile* fptr) { - // Write keyword + // Move to HDU int status = 0; - status = __ffuky(fptr, __TSTRING, (char*)m_keyname.c_str(), - (char*)m_value.c_str(), (char*)m_comment.c_str(), &status); + status = __ffmahd(fptr, (fptr->HDUposition)+1, NULL, &status); + if (status != 0) + throw GException::fits_error(G_READ_NUM, status); + + // Write keyword + status = __ffuky(fptr, __TSTRING, (char*)m_keyname.c_str(), + (char*)m_value.c_str(), (char*)m_comment.c_str(), &status); if (status != 0) throw GException::fits_error(G_WRITE, status); diff --git a/src/fits/GFitsImage.cpp b/src/fits/GFitsImage.cpp index 27f08eb..c2b189d 100644 --- a/src/fits/GFitsImage.cpp +++ b/src/fits/GFitsImage.cpp @@ -13,9 +13,9 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ +#include #include "GException.hpp" #include "GFitsImage.hpp" -#include // cout, cerr /* __ Namespaces _________________________________________________________ */ @@ -124,6 +124,7 @@ GFitsImage& GFitsImage::operator= (const GFitsImage& image) * Open Image * * ----------------------------------------------------------------------- * ***************************************************************************/ +/// NOT YET IMPLEMENTED void GFitsImage::open(__fitsfile* fptr) { // Return @@ -201,6 +202,26 @@ void GFitsImage::free_members(void) = = ==========================================================================*/ +/*************************************************************************** + * Output operator * + * ----------------------------------------------------------------------- * + ***************************************************************************/ +/// DUMMY VERSION +ostream& operator<< (ostream& os, const GFitsImage& image) +{ + // Put header in stream + os << "=== GFitsImage ===" << endl; +/* + os << " Number of rows ............: " << table.m_rows << endl; + os << " Number of columns .........: " << table.m_cols << endl; + for (int i = 0; i < table.m_cols; ++i) + os << " " << *(table.m_columns[i]); +*/ + + // Return output stream + return os; +} + /*========================================================================== = = diff --git a/src/fits/GFitsTableCol.cpp b/src/fits/GFitsTableCol.cpp index 0a8dab9..613a0e4 100644 --- a/src/fits/GFitsTableCol.cpp +++ b/src/fits/GFitsTableCol.cpp @@ -13,9 +13,9 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ +#include #include "GException.hpp" #include "GFitsTableCol.hpp" -#include // cout, cerr /* __ Namespaces _________________________________________________________ */ @@ -131,12 +131,13 @@ void GFitsTableCol::init_members(void) { // Initialise members m_name.clear(); - m_colnum = 0; - m_type = 0; - m_repeat = 0; - m_width = 0; - m_length = 0; - m_fitsfile = NULL; + m_colnum = 0; + m_type = 0; + m_repeat = 0; + m_width = 0; + m_length = 0; + m_fitsfile.HDUposition = 0; + m_fitsfile.Fptr = NULL; // Return return; @@ -191,8 +192,8 @@ void GFitsTableCol::free_members(void) ostream& operator<< (ostream& os, const GFitsTableCol& column) { // Put header in stream - os << "'" << column.m_name << "' [colnum="; - os << column.m_colnum << "] "; + os << "'" << column.m_name << "'"; + os << " [" << column.m_colnum << "] "; os << column.m_type << " repeat="; os << column.m_repeat << " width="; os << column.m_width << " length="; diff --git a/src/fits/GFitsTableDblCol.cpp b/src/fits/GFitsTableDblCol.cpp index 82dce3c..d2e10f0 100644 --- a/src/fits/GFitsTableDblCol.cpp +++ b/src/fits/GFitsTableDblCol.cpp @@ -356,8 +356,9 @@ void GFitsTableDblCol::load(void) // Load column data int status = 0; - status = __ffgcv(m_fitsfile, __TDOUBLE, m_colnum, 1, 1, m_size, - m_nulval, m_data, &m_anynul, &status); + status = __ffmahd(&m_fitsfile, (m_fitsfile.HDUposition)+1, NULL, &status); + status = __ffgcv(&m_fitsfile, __TDOUBLE, m_colnum, 1, 1, m_size, + m_nulval, m_data, &m_anynul, &status); if (status != 0) throw GException::fits_error(G_LOAD, status); diff --git a/src/fits/GFitsTableFltCol.cpp b/src/fits/GFitsTableFltCol.cpp index 31dea2c..ff37a89 100644 --- a/src/fits/GFitsTableFltCol.cpp +++ b/src/fits/GFitsTableFltCol.cpp @@ -356,13 +356,12 @@ void GFitsTableFltCol::load(void) // Allocate memory if (m_data != NULL) delete [] m_data; m_data = new float[m_size]; -cout << endl; -cout << "m_size: " << m_size << endl; -cout << "m_colnum: " << m_colnum << endl; + // Load column data int status = 0; - status = __ffgcv(m_fitsfile, __TFLOAT, m_colnum, 1, 1, m_size, - m_nulval, m_data, &m_anynul, &status); + status = __ffmahd(&m_fitsfile, (m_fitsfile.HDUposition)+1, NULL, &status); + status = __ffgcv(&m_fitsfile, __TFLOAT, m_colnum, 1, 1, m_size, + m_nulval, m_data, &m_anynul, &status); if (status != 0) throw GException::fits_error(G_LOAD, status); diff --git a/src/fits/GFitsTableLngCol.cpp b/src/fits/GFitsTableLngCol.cpp index b1559f2..563aa6c 100644 --- a/src/fits/GFitsTableLngCol.cpp +++ b/src/fits/GFitsTableLngCol.cpp @@ -359,8 +359,9 @@ void GFitsTableLngCol::load(void) // Load column data int status = 0; - status = __ffgcv(m_fitsfile, __TLONG, m_colnum, 1, 1, m_size, - m_nulval, m_data, &m_anynul, &status); + status = __ffmahd(&m_fitsfile, (m_fitsfile.HDUposition)+1, NULL, &status); + status = __ffgcv(&m_fitsfile, __TLONG, m_colnum, 1, 1, m_size, + m_nulval, m_data, &m_anynul, &status); if (status != 0) throw GException::fits_error(G_LOAD, status); diff --git a/src/fits/GFitsTableShtCol.cpp b/src/fits/GFitsTableShtCol.cpp index b6554b8..5beef5a 100644 --- a/src/fits/GFitsTableShtCol.cpp +++ b/src/fits/GFitsTableShtCol.cpp @@ -359,8 +359,9 @@ void GFitsTableShtCol::load(void) // Load column data int status = 0; - status = __ffgcv(m_fitsfile, __TSHORT, m_colnum, 1, 1, m_size, - m_nulval, m_data, &m_anynul, &status); + status = __ffmahd(&m_fitsfile, (m_fitsfile.HDUposition)+1, NULL, &status); + status = __ffgcv(&m_fitsfile, __TSHORT, m_colnum, 1, 1, m_size, + m_nulval, m_data, &m_anynul, &status); if (status != 0) throw GException::fits_error(G_LOAD, status); diff --git a/src/fits/GFitsTableStrCol.cpp b/src/fits/GFitsTableStrCol.cpp index ddb93e4..e8ee1bf 100644 --- a/src/fits/GFitsTableStrCol.cpp +++ b/src/fits/GFitsTableStrCol.cpp @@ -392,8 +392,9 @@ void GFitsTableStrCol::load(void) // Load column data int status = 0; - status = __ffgcvs(m_fitsfile, m_colnum, 1, 1, m_size, - m_nulstr, m_data, &m_anynul, &status); + status = __ffmahd(&m_fitsfile, (m_fitsfile.HDUposition)+1, NULL, &status); + status = __ffgcvs(&m_fitsfile, m_colnum, 1, 1, m_size, m_nulstr, m_data, + &m_anynul, &status); if (status != 0) throw GException::fits_error(G_LOAD, status); diff --git a/test/test_GFits.cpp b/test/test_GFits.cpp index ef73e62..86b8269 100644 --- a/test/test_GFits.cpp +++ b/test/test_GFits.cpp @@ -41,6 +41,7 @@ void test_open(void) try { GFits fits; fits.open("test_GFits.fits"); + cout << endl << fits; } catch (exception &e) { std::cout << std::endl << "TEST ERROR: Unable to open FITS file." << std::endl; @@ -67,7 +68,6 @@ void test_columns(void) throw; } - // // Test single string column //