Commit ddd6fc57c9d861b16524c3d4ced6a9f3f6623f7b

Authored by Jürgen Knödlseder
1 parent c6e06afb

Revise GFitsTable class interface.

A major revision of the GFitsTable class interface has been done, making it more similar to the interface of other container classes. In particular, the column access operator now returns a pointer instead of a reference, preventing code slicing. The set() method has been introduced to set columns in a table. The append_column() and insert_column() methods have been renamed to append() and insert() as they act on columns, and a table is a column container. Some arguments or return values are now also declared as const references. A size() method has been added that return the number of table columns.

As the GFitsTable class is widely used throughout GammaLib, a number of classes had to be adapted to this new interface.
... ... @@ -102,6 +102,12 @@ GOptimizer & GOptimizerLM
102 102 The optimization operators have been removed and replaced by the
103 103 optimize method.
104 104  
  105 +GFitsTable
  106 + The column table operator[] now returns a pointer instead of a
  107 + reference. Set set() method has been added for column setting.
  108 + The append_column() and insert_column() methods have been
  109 + renamed to append() and insert().
  110 +
105 111 All GammaLib constants, defined in GTools.hpp, and functions are now
106 112 put in the gammalib namespace to avoid name clashes. Mathematical
107 113 constants and functions have been moved to a new model named GMath.
... ...
doc/source/user_manual/modules/fits.rst
1   -.. _sec_fits: FITS file interface ------------------- Overview ~~~~~~~~ :ref:`fig_uml_fits` present an overview over the C++ classes of the FITS module and their relations. .. _fig_uml_fits: .. figure:: uml_fits.png :width: 100% FITS module The FITS module provides a high-level interface to FITS files. The module is based on the cfitsio library for file access. The C++ classes of the module implement a logical representation of the FITS file in memory that can be handled independently of the file representation on disk. The central class of the FITS module is the ``GFits`` class that represents a FITS file. The class is a container for classes derived from the abstract ``GFitsHDU`` base class which represents a FITS extension (also called Header-Data Unit, HDU). Each extension is composed of one header, implemented by the ``GFitsHeader`` class and one data unit. The header is composed of cards representing the meta-data of the fits file. The cards are implemented by the ``GFitsHeaderCard`` class. The data unit is either an image, represented by the abstract ``GFitsImage`` base class, or a table, represented by the abstract ``GFitsTable`` base class. The image can be stored in various data types, each of which is implemented by a specific class derived from ``GFitsImage``. The table can be either an ASCII table, implemented by the ``GFitsASCIITable`` class or a binary table, implemented by the ``GFitsBinTable`` class. Each table is comprised of columns, represented by the abstract ``GFitsTableCol`` base class. This class is the same for ASCII and binary tables. Similar to images, table column data can be stored in a variety of data types, each of which is implemented by a specific class derived from ``GFitsTableCol``. Creating a FITS file ~~~~~~~~~~~~~~~~~~~~ The following example illustrates the creation of a FITS file comprising one image and one table (see ``examples/createfits.cpp`` for the source code; the line numbers are for reference and are not part of the source code):: 1 GFits fits; 2 GFitsImageDouble image(20,10); 3 for (int x = 0; x < 20; ++x) { 4 for (int y = 0; y < 10; ++y) { 5 image(x,y) = x+100.0*y; 6 } 7 } 8 fits.append(image); 9 GFitsBinTable table; 10 GFitsTableDoubleCol column("ENERGY", 10, 3); 11 for (int row = 0; row < 10; ++row) { 12 for (int index = 0; index < 3; ++index) { 13 column(row, index) = row*100.0+index; 14 } 15 } 16 table.append_column(column); 17 fits.append(table); 18 fits.saveto("my_fits_file.fits", true); 19 fits.close(); In line 1, a FITS object is allocated in memory. An image is created in line 2, comprising 20 pixels in the x-direction and 10 pixels in the y-direction, each pixel being a double precision value. Lines 3-7 fill the image by a nested loop over all pixels. The image is then appended to the FITS object in line 8. In line 9, a binary table is created. A column comprising double precision values is created in line 10. The name of the column is set to ``ENERGY``, and comprises 10 rows, each of which is composed of a 3-element vector. This so-called vector column is filled by the nested loop in lines 11-15. In line 16, the column is appended to the binary table, which in turn is appended to the FITS object in line 17. In line 18, the FITS object is saved into the file ``my_fits_file.fits``. The (optional) argument ``true`` indicates that any existing file with the same name will be overwritten (by default, an attempt to overwrite an existing file will lead to an exception, hence if overwriting is desired it has to be explicitly specified). In line 19, the FITS object is closed, implying that all memory related to the object is deallocated. Note that saving of a FITS object does not close the object itself; it continues to exist in memory and can be manipulated further, independently of the FITS file on disk. Line 19 could however be omitted, as a FITS object is automatically closed upon destruction of the object. Note also that up to line 17, the FITS object only exists in memory. The FITS file on disk is only created in line 18. Alternatively, one could have written:: 1 GFits fits("my_fits_file.fits", true); ... 18 fits.save(true); Here, the FITS file on disk is created in line 1. The (optional) ``true`` argument specifies that the FITS file should be created if it does not yet exist. By default, this argument is set to ``false``, and an exception is raised when creating the ``GFits`` object. If a file exists already, line 1 will in fact open the file, and lines 2-17 will add an image and a table *in addition* to the image and table that exists already in the file. Line 1 is in fact identical to:: GFits fits; fits.open("my_fits_file.fits", true); hence it creates an instance of the ``GFits`` object and then opens the file ``my_fits_file.fits``. Line 18 then saves the FITS file taking into account the modifications that have been made. Note that only at this point the modifications will be written to disk. The ``save`` method does not take any filename as it saves a file that has been opened before. It takes however the (optional) clobber flag that specifies whether a file should be overwritten or not (as for the ``saveto`` method this flag is set to ``false`` by default). Note that one can also combine file opening with the ``saveto`` method to create a copy of the FITS file. Specifying:: 1 GFits fits("my_fits_file.fits", true); ... 18 fits.saveto("my_fits_file2.fits", true); will open the file ``my_fits_file.fits`` and save the FITS object after the manipulations of line 2-17 into the file ``my_fits_file2.fits``. A final word on the ``append`` and ``append_column`` methods that are used in the example to append the image and tables to the FITS object, and the column to the binary table. These methods will append a *copy* of the object to the FITS object, hence after appending, any manipulations on the original object will not be reflected in the FITS object. If an object should be manipulated after it has been appended, a pointer to the object has to be retrieved from the FITS object using:: GFitsImage* image = fits.image(0); GFitsTable* table = fits.table(1); GFitsTableCol* column = (*table)["ENERGY"]; For reference, a screen capture of the FITS file that is created by the above example is shown below. .. _fig_fits_example: .. figure:: fits_example.png :width: 100% FITS file example
2 1 \ No newline at end of file
  2 +.. _sec_fits: FITS file interface ------------------- Overview ~~~~~~~~ :ref:`fig_uml_fits` present an overview over the C++ classes of the FITS module and their relations. .. _fig_uml_fits: .. figure:: uml_fits.png :width: 100% FITS module The FITS module provides a high-level interface to FITS files. The module is based on the cfitsio library for file access. The C++ classes of the module implement a logical representation of the FITS file in memory that can be handled independently of the file representation on disk. The central class of the FITS module is the ``GFits`` class that represents a FITS file. The class is a container for classes derived from the abstract ``GFitsHDU`` base class which represents a FITS extension (also called Header-Data Unit, HDU). Each extension is composed of one header, implemented by the ``GFitsHeader`` class and one data unit. The header is composed of cards representing the meta-data of the fits file. The cards are implemented by the ``GFitsHeaderCard`` class. The data unit is either an image, represented by the abstract ``GFitsImage`` base class, or a table, represented by the abstract ``GFitsTable`` base class. The image can be stored in various data types, each of which is implemented by a specific class derived from ``GFitsImage``. The table can be either an ASCII table, implemented by the ``GFitsASCIITable`` class or a binary table, implemented by the ``GFitsBinTable`` class. Each table is comprised of columns, represented by the abstract ``GFitsTableCol`` base class. This class is the same for ASCII and binary tables. Similar to images, table column data can be stored in a variety of data types, each of which is implemented by a specific class derived from ``GFitsTableCol``. Creating a FITS file ~~~~~~~~~~~~~~~~~~~~ The following example illustrates the creation of a FITS file comprising one image and one table (see ``examples/createfits.cpp`` for the source code; the line numbers are for reference and are not part of the source code):: 1 GFits fits; 2 GFitsImageDouble image(20,10); 3 for (int x = 0; x < 20; ++x) { 4 for (int y = 0; y < 10; ++y) { 5 image(x,y) = x+100.0*y; 6 } 7 } 8 fits.append(image); 9 GFitsBinTable table; 10 GFitsTableDoubleCol column("ENERGY", 10, 3); 11 for (int row = 0; row < 10; ++row) { 12 for (int index = 0; index < 3; ++index) { 13 column(row, index) = row*100.0+index; 14 } 15 } 16 table.append(column); 17 fits.append(table); 18 fits.saveto("my_fits_file.fits", true); 19 fits.close(); In line 1, a FITS object is allocated in memory. An image is created in line 2, comprising 20 pixels in the x-direction and 10 pixels in the y-direction, each pixel being a double precision value. Lines 3-7 fill the image by a nested loop over all pixels. The image is then appended to the FITS object in line 8. In line 9, a binary table is created. A column comprising double precision values is created in line 10. The name of the column is set to ``ENERGY``, and comprises 10 rows, each of which is composed of a 3-element vector. This so-called vector column is filled by the nested loop in lines 11-15. In line 16, the column is appended to the binary table, which in turn is appended to the FITS object in line 17. In line 18, the FITS object is saved into the file ``my_fits_file.fits``. The (optional) argument ``true`` indicates that any existing file with the same name will be overwritten (by default, an attempt to overwrite an existing file will lead to an exception, hence if overwriting is desired it has to be explicitly specified). In line 19, the FITS object is closed, implying that all memory related to the object is deallocated. Note that saving of a FITS object does not close the object itself; it continues to exist in memory and can be manipulated further, independently of the FITS file on disk. Line 19 could however be omitted, as a FITS object is automatically closed upon destruction of the object. Note also that up to line 17, the FITS object only exists in memory. The FITS file on disk is only created in line 18. Alternatively, one could have written:: 1 GFits fits("my_fits_file.fits", true); ... 18 fits.save(true); Here, the FITS file on disk is created in line 1. The (optional) ``true`` argument specifies that the FITS file should be created if it does not yet exist. By default, this argument is set to ``false``, and an exception is raised when creating the ``GFits`` object. If a file exists already, line 1 will in fact open the file, and lines 2-17 will add an image and a table *in addition* to the image and table that exists already in the file. Line 1 is in fact identical to:: GFits fits; fits.open("my_fits_file.fits", true); hence it creates an instance of the ``GFits`` object and then opens the file ``my_fits_file.fits``. Line 18 then saves the FITS file taking into account the modifications that have been made. Note that only at this point the modifications will be written to disk. The ``save`` method does not take any filename as it saves a file that has been opened before. It takes however the (optional) clobber flag that specifies whether a file should be overwritten or not (as for the ``saveto`` method this flag is set to ``false`` by default). Note that one can also combine file opening with the ``saveto`` method to create a copy of the FITS file. Specifying:: 1 GFits fits("my_fits_file.fits", true); ... 18 fits.saveto("my_fits_file2.fits", true); will open the file ``my_fits_file.fits`` and save the FITS object after the manipulations of line 2-17 into the file ``my_fits_file2.fits``. A final word on the ``append`` methods that are used in the example to append the image and tables to the FITS object, and the column to the binary table. These methods will append a *copy* of the object to the FITS object, hence after appending, any manipulations on the original object will not be reflected in the FITS object. If an object should be manipulated after it has been appended, a pointer to the object has to be retrieved from the FITS object using:: GFitsImage* image = fits.image(0); GFitsTable* table = fits.table(1); GFitsTableCol* column = (*table)["ENERGY"]; For reference, a screen capture of the FITS file that is created by the above example is shown below. .. _fig_fits_example: .. figure:: fits_example.png :width: 100% FITS file example
3 3 \ No newline at end of file
... ...
examples/cpp/createfits/createfits.cpp
... ... @@ -57,7 +57,7 @@ int main(void) {
57 57 column(row, index) = row*100.0+index;
58 58 }
59 59 }
60   - table.append_column(column);
  60 + table.append(column);
61 61  
62 62 // Append table to FITS object
63 63 fits.append(table);
... ...
include/GFitsTable.hpp
... ... @@ -41,23 +41,23 @@
41 41 * is a collection of columns with an identical number of rows. This class
42 42 * provides high level access to table columns.
43 43 *
44   - * @todo Implement remove_column method
  44 + * @todo Implement remove() method
45 45 ***************************************************************************/
46 46 class GFitsTable : public GFitsHDU {
47 47  
48 48 public:
49 49 // Constructors and destructors
50 50 GFitsTable(void);
51   - explicit GFitsTable(int nrows);
  51 + explicit GFitsTable(const int& nrows);
52 52 GFitsTable(const GFitsTable& table);
53 53 virtual ~GFitsTable(void);
54 54  
55 55 // Operators
56 56 GFitsTable& operator=(const GFitsTable& table);
57   - GFitsTableCol& operator[](const int& colnum);
58   - const GFitsTableCol& operator[](const int& colnum) const;
59   - GFitsTableCol& operator[](const std::string& colname);
60   - const GFitsTableCol& operator[](const std::string& colname) const;
  57 + GFitsTableCol* operator[](const int& colnum);
  58 + const GFitsTableCol* operator[](const int& colnum) const;
  59 + GFitsTableCol* operator[](const std::string& colname);
  60 + const GFitsTableCol* operator[](const std::string& colname) const;
61 61  
62 62 // Pure virtual methods
63 63 virtual void clear(void) = 0;
... ... @@ -65,15 +65,19 @@ public:
65 65 virtual HDUType exttype(void) const = 0;
66 66  
67 67 // Implemented Methods
68   - void append_column(GFitsTableCol& column);
69   - void insert_column(int colnum, GFitsTableCol& column);
70   - void append_rows(const int& nrows);
71   - void insert_rows(const int& rownum, const int& nrows);
72   - void remove_rows(const int& rownum, const int& nrows);
73   - int nrows(void) const;
74   - int ncols(void) const;
75   - bool hascolumn(const std::string& colname) const;
76   - std::string print(const GChatter& chatter = NORMAL) const;
  68 + const int& size(void) const;
  69 + GFitsTableCol* set(const int& colnum, const GFitsTableCol& column);
  70 + GFitsTableCol* set(const std::string& colname, const GFitsTableCol& column);
  71 + GFitsTableCol* append(const GFitsTableCol& column);
  72 + GFitsTableCol* insert(int colnum, const GFitsTableCol& column);
  73 + GFitsTableCol* insert(const std::string& colname, const GFitsTableCol& column);
  74 + void append_rows(const int& nrows);
  75 + void insert_rows(const int& row, const int& nrows);
  76 + void remove_rows(const int& row, const int& nrows);
  77 + const int& nrows(void) const;
  78 + const int& ncols(void) const;
  79 + bool hascolumn(const std::string& colname) const;
  80 + std::string print(const GChatter& chatter = NORMAL) const;
77 81  
78 82 protected:
79 83 // Protected methods
... ... @@ -98,6 +102,64 @@ private:
98 102 // Private methods
99 103 GFitsTableCol* alloc_column(int typecode) const;
100 104 GFitsTableCol* ptr_column(const std::string& colname) const;
  105 + int colnum(const std::string& colname) const;
101 106 };
102 107  
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Return number of columns in table
  111 + *
  112 + * @return Number of columns in table
  113 + *
  114 + * Returns the number of columns in table. This method is equivalent to the
  115 + * ncols() method.
  116 + ***************************************************************************/
  117 +inline
  118 +const int& GFitsTable::size(void) const
  119 +{
  120 + return m_cols;
  121 +}
  122 +
  123 +
  124 +/***********************************************************************//**
  125 + * @brief Return number of rows in table
  126 + *
  127 + * @return Number of rows in table
  128 + *
  129 + * Returns the number of rows in table.
  130 + ***************************************************************************/
  131 +inline
  132 +const int& GFitsTable::nrows(void) const
  133 +{
  134 + return m_rows;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Return number of columns in table
  140 + *
  141 + * @return Number of columns in table
  142 + *
  143 + * Returns the number of columns in table. This method is equivalent to the
  144 + * size() method.
  145 + ***************************************************************************/
  146 +inline
  147 +const int& GFitsTable::ncols(void) const
  148 +{
  149 + return m_cols;
  150 +}
  151 +
  152 +
  153 +/***********************************************************************//**
  154 + * @brief Append column to the table
  155 + *
  156 + * @param[in] column Table column.
  157 + * @return Pointer to table column that has been appended
  158 + ***************************************************************************/
  159 +inline
  160 +GFitsTableCol* GFitsTable::append(const GFitsTableCol& column)
  161 +{
  162 + return (insert(m_cols, column));
  163 +}
  164 +
103 165 #endif /* GFITSTABLE_HPP */
... ...
inst/cta/src/GCTAAeffArf.cpp
... ... @@ -306,9 +306,9 @@ void GCTAAeffArf::read_arf(const GFitsTable* hdu)
306 306 m_aeff.clear();
307 307  
308 308 // Get pointers to table columns
309   - const GFitsTableCol* energy_lo = &(*hdu)["ENERG_LO"];
310   - const GFitsTableCol* energy_hi = &(*hdu)["ENERG_HI"];
311   - const GFitsTableCol* specresp = &(*hdu)["SPECRESP"];
  309 + const GFitsTableCol* energy_lo = (*hdu)["ENERG_LO"];
  310 + const GFitsTableCol* energy_hi = (*hdu)["ENERG_HI"];
  311 + const GFitsTableCol* specresp = (*hdu)["SPECRESP"];
312 312  
313 313 // Determine unit conversion factors (default: TeV and cm^2)
314 314 std::string u_energy_lo = gammalib::tolower(gammalib::strip_whitespace(energy_lo->unit()));
... ...
inst/cta/src/GCTAEventList.cpp
... ... @@ -653,23 +653,23 @@ void GCTAEventList::read_events_v0(const GFitsTable* table)
653 653 m_events.reserve(num);
654 654  
655 655 // Get column pointers
656   - GFitsTableULongCol* ptr_eid = (GFitsTableULongCol*)&(*table)["EVENT_ID"];
657   - GFitsTableDoubleCol* ptr_time = (GFitsTableDoubleCol*)&(*table)["TIME"];
658   - GFitsTableShortCol* ptr_multip = (GFitsTableShortCol*)&(*table)["MULTIP"];
659   - GFitsTableFloatCol* ptr_ra = (GFitsTableFloatCol*)&(*table)["RA"];
660   - GFitsTableFloatCol* ptr_dec = (GFitsTableFloatCol*)&(*table)["DEC"];
661   - GFitsTableFloatCol* ptr_dir_err = (GFitsTableFloatCol*)&(*table)["DIR_ERR"];
662   - GFitsTableFloatCol* ptr_detx = (GFitsTableFloatCol*)&(*table)["DETX"];
663   - GFitsTableFloatCol* ptr_dety = (GFitsTableFloatCol*)&(*table)["DETY"];
664   - GFitsTableFloatCol* ptr_alt = (GFitsTableFloatCol*)&(*table)["ALT"];
665   - GFitsTableFloatCol* ptr_az = (GFitsTableFloatCol*)&(*table)["AZ"];
666   - GFitsTableFloatCol* ptr_corex = (GFitsTableFloatCol*)&(*table)["COREX"];
667   - GFitsTableFloatCol* ptr_corey = (GFitsTableFloatCol*)&(*table)["COREY"];
668   - GFitsTableFloatCol* ptr_core_err = (GFitsTableFloatCol*)&(*table)["CORE_ERR"];
669   - GFitsTableFloatCol* ptr_xmax = (GFitsTableFloatCol*)&(*table)["XMAX"];
670   - GFitsTableFloatCol* ptr_xmax_err = (GFitsTableFloatCol*)&(*table)["XMAX_ERR"];
671   - GFitsTableFloatCol* ptr_energy = (GFitsTableFloatCol*)&(*table)["ENERGY"];
672   - GFitsTableFloatCol* ptr_energy_err = (GFitsTableFloatCol*)&(*table)["ENERGY_ERR"];
  656 + GFitsTableULongCol* ptr_eid = (GFitsTableULongCol*)(*table)["EVENT_ID"];
  657 + GFitsTableDoubleCol* ptr_time = (GFitsTableDoubleCol*)(*table)["TIME"];
  658 + GFitsTableShortCol* ptr_multip = (GFitsTableShortCol*)(*table)["MULTIP"];
  659 + GFitsTableFloatCol* ptr_ra = (GFitsTableFloatCol*)(*table)["RA"];
  660 + GFitsTableFloatCol* ptr_dec = (GFitsTableFloatCol*)(*table)["DEC"];
  661 + GFitsTableFloatCol* ptr_dir_err = (GFitsTableFloatCol*)(*table)["DIR_ERR"];
  662 + GFitsTableFloatCol* ptr_detx = (GFitsTableFloatCol*)(*table)["DETX"];
  663 + GFitsTableFloatCol* ptr_dety = (GFitsTableFloatCol*)(*table)["DETY"];
  664 + GFitsTableFloatCol* ptr_alt = (GFitsTableFloatCol*)(*table)["ALT"];
  665 + GFitsTableFloatCol* ptr_az = (GFitsTableFloatCol*)(*table)["AZ"];
  666 + GFitsTableFloatCol* ptr_corex = (GFitsTableFloatCol*)(*table)["COREX"];
  667 + GFitsTableFloatCol* ptr_corey = (GFitsTableFloatCol*)(*table)["COREY"];
  668 + GFitsTableFloatCol* ptr_core_err = (GFitsTableFloatCol*)(*table)["CORE_ERR"];
  669 + GFitsTableFloatCol* ptr_xmax = (GFitsTableFloatCol*)(*table)["XMAX"];
  670 + GFitsTableFloatCol* ptr_xmax_err = (GFitsTableFloatCol*)(*table)["XMAX_ERR"];
  671 + GFitsTableFloatCol* ptr_energy = (GFitsTableFloatCol*)(*table)["ENERGY"];
  672 + GFitsTableFloatCol* ptr_energy_err = (GFitsTableFloatCol*)(*table)["ENERGY_ERR"];
673 673  
674 674 // Copy data from columns into GCTAEventAtom objects
675 675 GCTAEventAtom event;
... ... @@ -734,26 +734,26 @@ void GCTAEventList::read_events_v1(const GFitsTable* table)
734 734 m_events.reserve(num);
735 735  
736 736 // Get column pointers
737   - GFitsTableULongCol* ptr_eid = (GFitsTableULongCol*)&(*table)["EVENT_ID"];
738   - GFitsTableULongCol* ptr_oid = (GFitsTableULongCol*)&(*table)["OBS_ID"];
739   - GFitsTableDoubleCol* ptr_time = (GFitsTableDoubleCol*)&(*table)["TIME"];
740   - GFitsTableShortCol* ptr_multip = (GFitsTableShortCol*)&(*table)["MULTIP"];
741   - GFitsTableFloatCol* ptr_ra = (GFitsTableFloatCol*)&(*table)["RA"];
742   - GFitsTableFloatCol* ptr_dec = (GFitsTableFloatCol*)&(*table)["DEC"];
743   - GFitsTableFloatCol* ptr_dir_err = (GFitsTableFloatCol*)&(*table)["DIR_ERR"];
744   - GFitsTableFloatCol* ptr_detx = (GFitsTableFloatCol*)&(*table)["DETX"];
745   - GFitsTableFloatCol* ptr_dety = (GFitsTableFloatCol*)&(*table)["DETY"];
746   - GFitsTableFloatCol* ptr_alt = (GFitsTableFloatCol*)&(*table)["ALT"];
747   - GFitsTableFloatCol* ptr_az = (GFitsTableFloatCol*)&(*table)["AZ"];
748   - GFitsTableFloatCol* ptr_corex = (GFitsTableFloatCol*)&(*table)["COREX"];
749   - GFitsTableFloatCol* ptr_corey = (GFitsTableFloatCol*)&(*table)["COREY"];
750   - GFitsTableFloatCol* ptr_core_err = (GFitsTableFloatCol*)&(*table)["CORE_ERR"];
751   - GFitsTableFloatCol* ptr_xmax = (GFitsTableFloatCol*)&(*table)["XMAX"];
752   - GFitsTableFloatCol* ptr_xmax_err = (GFitsTableFloatCol*)&(*table)["XMAX_ERR"];
753   - GFitsTableFloatCol* ptr_shw = (GFitsTableFloatCol*)&(*table)["SHWIDTH"];
754   - GFitsTableFloatCol* ptr_shl = (GFitsTableFloatCol*)&(*table)["SHLENGTH"];
755   - GFitsTableFloatCol* ptr_energy = (GFitsTableFloatCol*)&(*table)["ENERGY"];
756   - GFitsTableFloatCol* ptr_energy_err = (GFitsTableFloatCol*)&(*table)["ENERGY_ERR"];
  737 + GFitsTableULongCol* ptr_eid = (GFitsTableULongCol*)(*table)["EVENT_ID"];
  738 + GFitsTableULongCol* ptr_oid = (GFitsTableULongCol*)(*table)["OBS_ID"];
  739 + GFitsTableDoubleCol* ptr_time = (GFitsTableDoubleCol*)(*table)["TIME"];
  740 + GFitsTableShortCol* ptr_multip = (GFitsTableShortCol*)(*table)["MULTIP"];
  741 + GFitsTableFloatCol* ptr_ra = (GFitsTableFloatCol*)(*table)["RA"];
  742 + GFitsTableFloatCol* ptr_dec = (GFitsTableFloatCol*)(*table)["DEC"];
  743 + GFitsTableFloatCol* ptr_dir_err = (GFitsTableFloatCol*)(*table)["DIR_ERR"];
  744 + GFitsTableFloatCol* ptr_detx = (GFitsTableFloatCol*)(*table)["DETX"];
  745 + GFitsTableFloatCol* ptr_dety = (GFitsTableFloatCol*)(*table)["DETY"];
  746 + GFitsTableFloatCol* ptr_alt = (GFitsTableFloatCol*)(*table)["ALT"];
  747 + GFitsTableFloatCol* ptr_az = (GFitsTableFloatCol*)(*table)["AZ"];
  748 + GFitsTableFloatCol* ptr_corex = (GFitsTableFloatCol*)(*table)["COREX"];
  749 + GFitsTableFloatCol* ptr_corey = (GFitsTableFloatCol*)(*table)["COREY"];
  750 + GFitsTableFloatCol* ptr_core_err = (GFitsTableFloatCol*)(*table)["CORE_ERR"];
  751 + GFitsTableFloatCol* ptr_xmax = (GFitsTableFloatCol*)(*table)["XMAX"];
  752 + GFitsTableFloatCol* ptr_xmax_err = (GFitsTableFloatCol*)(*table)["XMAX_ERR"];
  753 + GFitsTableFloatCol* ptr_shw = (GFitsTableFloatCol*)(*table)["SHWIDTH"];
  754 + GFitsTableFloatCol* ptr_shl = (GFitsTableFloatCol*)(*table)["SHLENGTH"];
  755 + GFitsTableFloatCol* ptr_energy = (GFitsTableFloatCol*)(*table)["ENERGY"];
  756 + GFitsTableFloatCol* ptr_energy_err = (GFitsTableFloatCol*)(*table)["ENERGY_ERR"];
757 757  
758 758 // Copy data from columns into GCTAEventAtom objects
759 759 GCTAEventAtom event;
... ... @@ -821,7 +821,7 @@ void GCTAEventList::read_events_hillas(const GFitsTable* table)
821 821 // HIL_MSW
822 822 if (table->hascolumn("HIL_MSW")) {
823 823 GFitsTableFloatCol* ptr =
824   - (GFitsTableFloatCol*)&(*table)["HIL_MSW"];
  824 + (GFitsTableFloatCol*)(*table)["HIL_MSW"];
825 825 for (int i = 0; i < num; ++i) {
826 826 m_events[i].m_hil_msw = (*ptr)(i);
827 827 }
... ... @@ -830,7 +830,7 @@ void GCTAEventList::read_events_hillas(const GFitsTable* table)
830 830 // HIL_MSW_ERR
831 831 if (table->hascolumn("HIL_MSW_ERR")) {
832 832 GFitsTableFloatCol* ptr =
833   - (GFitsTableFloatCol*)&(*table)["HIL_MSW_ERR"];
  833 + (GFitsTableFloatCol*)(*table)["HIL_MSW_ERR"];
834 834 for (int i = 0; i < num; ++i) {
835 835 m_events[i].m_hil_msw_err = (*ptr)(i);
836 836 }
... ... @@ -839,7 +839,7 @@ void GCTAEventList::read_events_hillas(const GFitsTable* table)
839 839 // HIL_MSL
840 840 if (table->hascolumn("HIL_MSL")) {
841 841 GFitsTableFloatCol* ptr =
842   - (GFitsTableFloatCol*)&(*table)["HIL_MSL"];
  842 + (GFitsTableFloatCol*)(*table)["HIL_MSL"];
843 843 for (int i = 0; i < num; ++i) {
844 844 m_events[i].m_hil_msl = (*ptr)(i);
845 845 }
... ... @@ -848,7 +848,7 @@ void GCTAEventList::read_events_hillas(const GFitsTable* table)
848 848 // HIL_MSL_ERR
849 849 if (table->hascolumn("HIL_MSL_ERR")) {
850 850 GFitsTableFloatCol* ptr =
851   - (GFitsTableFloatCol*)&(*table)["HIL_MSL_ERR"];
  851 + (GFitsTableFloatCol*)(*table)["HIL_MSL_ERR"];
852 852 for (int i = 0; i < num; ++i) {
853 853 m_events[i].m_hil_msl_err = (*ptr)(i);
854 854 }
... ... @@ -1112,32 +1112,32 @@ void GCTAEventList::write_events(GFitsBinTable* hdu) const
1112 1112 } // endfor: looped over rows
1113 1113  
1114 1114 // Append columns to table
1115   - hdu->append_column(col_eid);
1116   - hdu->append_column(col_oid);
1117   - hdu->append_column(col_time);
1118   - hdu->append_column(col_live);
1119   - hdu->append_column(col_multip);
1120   - hdu->append_column(col_telmask);
1121   - hdu->append_column(col_ra);
1122   - hdu->append_column(col_dec);
1123   - hdu->append_column(col_direrr);
1124   - hdu->append_column(col_detx);
1125   - hdu->append_column(col_dety);
1126   - hdu->append_column(col_alt);
1127   - hdu->append_column(col_az);
1128   - hdu->append_column(col_corex);
1129   - hdu->append_column(col_corey);
1130   - hdu->append_column(col_core_err);
1131   - hdu->append_column(col_xmax);
1132   - hdu->append_column(col_xmax_err);
1133   - hdu->append_column(col_shw);
1134   - hdu->append_column(col_shl);
1135   - hdu->append_column(col_energy);
1136   - hdu->append_column(col_energy_err);
1137   - hdu->append_column(col_hil_msw);
1138   - hdu->append_column(col_hil_msw_err);
1139   - hdu->append_column(col_hil_msl);
1140   - hdu->append_column(col_hil_msl_err);
  1115 + hdu->append(col_eid);
  1116 + hdu->append(col_oid);
  1117 + hdu->append(col_time);
  1118 + hdu->append(col_live);
  1119 + hdu->append(col_multip);
  1120 + hdu->append(col_telmask);
  1121 + hdu->append(col_ra);
  1122 + hdu->append(col_dec);
  1123 + hdu->append(col_direrr);
  1124 + hdu->append(col_detx);
  1125 + hdu->append(col_dety);
  1126 + hdu->append(col_alt);
  1127 + hdu->append(col_az);
  1128 + hdu->append(col_corex);
  1129 + hdu->append(col_corey);
  1130 + hdu->append(col_core_err);
  1131 + hdu->append(col_xmax);
  1132 + hdu->append(col_xmax_err);
  1133 + hdu->append(col_shw);
  1134 + hdu->append(col_shl);
  1135 + hdu->append(col_energy);
  1136 + hdu->append(col_energy_err);
  1137 + hdu->append(col_hil_msw);
  1138 + hdu->append(col_hil_msw_err);
  1139 + hdu->append(col_hil_msl);
  1140 + hdu->append(col_hil_msl_err);
1141 1141  
1142 1142 } // endif: there were events to write
1143 1143  
... ...
inst/cta/src/GCTAPsfVector.cpp
... ... @@ -286,17 +286,17 @@ void GCTAPsfVector::read(const GFitsTable* hdu)
286 286 const double conv = 0.6624305 * gammalib::deg2rad;
287 287  
288 288 // Get pointers to table columns
289   - const GFitsTableCol* energy_lo = &(*hdu)["ENERG_LO"];
290   - const GFitsTableCol* energy_hi = &(*hdu)["ENERG_HI"];
  289 + const GFitsTableCol* energy_lo = (*hdu)["ENERG_LO"];
  290 + const GFitsTableCol* energy_hi = (*hdu)["ENERG_HI"];
291 291  
292 292 // Handle various data formats (H.E.S.S. and MAGIC)
293 293 const GFitsTableCol* r68;
294 294 double r68_scale = 1.0;
295 295 if (hdu->hascolumn("R68")) {
296   - r68 = &(*hdu)["R68"];
  296 + r68 = (*hdu)["R68"];
297 297 }
298 298 else {
299   - r68 = &(*hdu)["ANGRES40"];
  299 + r68 = (*hdu)["ANGRES40"];
300 300 r68_scale = 1.0 / 0.6624305; // MAGIC PSF is already 1 sigma
301 301 }
302 302  
... ...
inst/cta/src/GCTAResponseTable.cpp
... ... @@ -975,7 +975,7 @@ void GCTAResponseTable::read_colnames(const GFitsTable* hdu)
975 975 for (int i = 0; i < hdu->ncols(); ++i) {
976 976  
977 977 // Get column name
978   - std::string colname = (*hdu)[i].name();
  978 + std::string colname = (*hdu)[i]->name();
979 979  
980 980 // If we search for a "_LO" column, check if we have one. If one
981 981 // is found, change the search mode to 1 and set the expected name
... ... @@ -1108,8 +1108,8 @@ void GCTAResponseTable::read_axes(const GFitsTable* hdu)
1108 1108 for (int i = 0; i < axes(); ++i) {
1109 1109  
1110 1110 // Get pointers to table columns
1111   - const GFitsTableCol* col_lo = &(*hdu)[m_colname_lo[i]];
1112   - const GFitsTableCol* col_hi = &(*hdu)[m_colname_hi[i]];
  1111 + const GFitsTableCol* col_lo = (*hdu)[m_colname_lo[i]];
  1112 + const GFitsTableCol* col_hi = (*hdu)[m_colname_hi[i]];
1113 1113  
1114 1114 // Extract number of bins. Make sure that both columns have the
1115 1115 // same number of bins
... ... @@ -1189,7 +1189,7 @@ void GCTAResponseTable::read_pars(const GFitsTable* hdu)
1189 1189 for (int i = 0; i < size(); ++i) {
1190 1190  
1191 1191 // Get pointer to table column
1192   - const GFitsTableCol* col = &(*hdu)[m_colname_par[i]];
  1192 + const GFitsTableCol* col = (*hdu)[m_colname_par[i]];
1193 1193  
1194 1194 // Extract number of bins. Verify that the number of bins
1195 1195 // corresponds to the expectation.
... ...
inst/lat/src/GLATAeff.cpp
... ... @@ -609,7 +609,7 @@ void GLATAeff::read_aeff(const GFitsTable* hdu)
609 609 m_aeff.reserve(size);
610 610  
611 611 // Get pointer to effective area column
612   - const GFitsTableCol* ptr = &(*hdu)["EFFAREA"];
  612 + const GFitsTableCol* ptr = (*hdu)["EFFAREA"];
613 613  
614 614 // Check consistency of effective area table
615 615 int num = ptr->number();
... ... @@ -667,7 +667,7 @@ void GLATAeff::read_efficiency(const GFitsTable* hdu)
667 667 m_eff_func2 = NULL;
668 668  
669 669 // Get pointer to efficiency factors column
670   - const GFitsTableCol* ptr = &(*hdu)["EFFICIENCY_PARS"];
  670 + const GFitsTableCol* ptr = (*hdu)["EFFICIENCY_PARS"];
671 671  
672 672 // Allocate vectors to hold the parameters
673 673 std::vector<double> par1;
... ... @@ -735,7 +735,7 @@ void GLATAeff::write_aeff(GFits&amp; file) const
735 735 col_aeff(0,i) = m_aeff[i];
736 736  
737 737 // Append columns to table
738   - hdu_aeff->append_column(col_aeff);
  738 + hdu_aeff->append(col_aeff);
739 739  
740 740 // Append HDU to FITS file
741 741 file.append(*hdu_aeff);
... ...
inst/lat/src/GLATEdisp.cpp
... ... @@ -375,8 +375,8 @@ void GLATEdisp::read_edisp(const GFitsTable* hdu)
375 375 m_ls1.reserve(size);
376 376  
377 377 // Get pointer to columns
378   - const GFitsTableCol* norm = &(*hdu)["NORM"];
379   - const GFitsTableCol* ls1 = &(*hdu)["LS1"];
  378 + const GFitsTableCol* norm = (*hdu)["NORM"];
  379 + const GFitsTableCol* ls1 = (*hdu)["LS1"];
380 380  
381 381 // Check consistency of columns
382 382 if (norm->number() != size)
... ... @@ -432,8 +432,8 @@ void GLATEdisp::write_edisp(GFits&amp; file) const
432 432 }
433 433  
434 434 // Append columns to table
435   - hdu_edisp->append_column(col_norm);
436   - hdu_edisp->append_column(col_ls1);
  435 + hdu_edisp->append(col_norm);
  436 + hdu_edisp->append(col_ls1);
437 437  
438 438 // Append HDU to FITS file
439 439 file.append(*hdu_edisp);
... ...
inst/lat/src/GLATEventList.cpp
... ... @@ -496,21 +496,21 @@ void GLATEventList::read_events(const GFitsTable&amp; table)
496 496 m_events.reserve(num);
497 497  
498 498 // Get column pointers
499   - GFitsTableDoubleCol* ptr_time = (GFitsTableDoubleCol*)&table["TIME"];
500   - GFitsTableFloatCol* ptr_energy = (GFitsTableFloatCol*)&table["ENERGY"];
501   - GFitsTableFloatCol* ptr_ra = (GFitsTableFloatCol*)&table["RA"];
502   - GFitsTableFloatCol* ptr_dec = (GFitsTableFloatCol*)&table["DEC"];
503   - GFitsTableFloatCol* ptr_theta = (GFitsTableFloatCol*)&table["THETA"];
504   - GFitsTableFloatCol* ptr_phi = (GFitsTableFloatCol*)&table["PHI"];
505   - GFitsTableFloatCol* ptr_zenith = (GFitsTableFloatCol*)&table["ZENITH_ANGLE"];
506   - GFitsTableFloatCol* ptr_azimuth = (GFitsTableFloatCol*)&table["EARTH_AZIMUTH_ANGLE"];
507   - GFitsTableLongCol* ptr_eid = (GFitsTableLongCol*)&table["EVENT_ID"];
508   - GFitsTableLongCol* ptr_rid = (GFitsTableLongCol*)&table["RUN_ID"];
509   - GFitsTableShortCol* ptr_recon = (GFitsTableShortCol*)&table["RECON_VERSION"];
510   - GFitsTableShortCol* ptr_calib = (GFitsTableShortCol*)&table["CALIB_VERSION"];
511   - GFitsTableShortCol* ptr_class = (GFitsTableShortCol*)&table["EVENT_CLASS"];
512   - GFitsTableShortCol* ptr_conv = (GFitsTableShortCol*)&table["CONVERSION_TYPE"];
513   - GFitsTableDoubleCol* ptr_ltime = (GFitsTableDoubleCol*)&table["LIVETIME"];
  499 + GFitsTableDoubleCol* ptr_time = (GFitsTableDoubleCol*)table["TIME"];
  500 + GFitsTableFloatCol* ptr_energy = (GFitsTableFloatCol*)table["ENERGY"];
  501 + GFitsTableFloatCol* ptr_ra = (GFitsTableFloatCol*)table["RA"];
  502 + GFitsTableFloatCol* ptr_dec = (GFitsTableFloatCol*)table["DEC"];
  503 + GFitsTableFloatCol* ptr_theta = (GFitsTableFloatCol*)table["THETA"];
  504 + GFitsTableFloatCol* ptr_phi = (GFitsTableFloatCol*)table["PHI"];
  505 + GFitsTableFloatCol* ptr_zenith = (GFitsTableFloatCol*)table["ZENITH_ANGLE"];
  506 + GFitsTableFloatCol* ptr_azimuth = (GFitsTableFloatCol*)table["EARTH_AZIMUTH_ANGLE"];
  507 + GFitsTableLongCol* ptr_eid = (GFitsTableLongCol*)table["EVENT_ID"];
  508 + GFitsTableLongCol* ptr_rid = (GFitsTableLongCol*)table["RUN_ID"];
  509 + GFitsTableShortCol* ptr_recon = (GFitsTableShortCol*)table["RECON_VERSION"];
  510 + GFitsTableShortCol* ptr_calib = (GFitsTableShortCol*)table["CALIB_VERSION"];
  511 + GFitsTableShortCol* ptr_class = (GFitsTableShortCol*)table["EVENT_CLASS"];
  512 + GFitsTableShortCol* ptr_conv = (GFitsTableShortCol*)table["CONVERSION_TYPE"];
  513 + GFitsTableDoubleCol* ptr_ltime = (GFitsTableDoubleCol*)table["LIVETIME"];
514 514  
515 515 // Copy data from columns into GLATEventAtom objects
516 516 GLATEventAtom event;
... ... @@ -565,7 +565,7 @@ void GLATEventList::read_events(const GFitsTable&amp; table)
565 565  
566 566 // Get column pointer
567 567 GFitsTableFloatCol* ptr_dif =
568   - static_cast<GFitsTableFloatCol*>(const_cast<GFitsTableCol*>(&table[std::string(keyword)]));
  568 + static_cast<GFitsTableFloatCol*>(const_cast<GFitsTableCol*>(table[std::string(keyword)]));
569 569  
570 570 // Copy data from columns into GLATEventAtom objects
571 571 for (int i = 0; i < num; ++i) {
... ...
inst/lat/src/GLATPsfBase.cpp
1 1 /***************************************************************************
2   - * GLATPsfBase.cpp - Fermi/LAT point spread function abstract base class *
  2 + * GLATPsfBase.cpp - Fermi/LAT point spread function abstract base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2013 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -21,7 +21,7 @@
21 21 /**
22 22 * @file GLATPsfBase.cpp
23 23 * @brief Fermi/LAT point spread function abstract base class implementation
24   - * @author J. Knoedlseder
  24 + * @author Juergen Knoedlseder
25 25 */
26 26  
27 27 /* __ Includes ___________________________________________________________ */
... ... @@ -199,7 +199,7 @@ void GLATPsfBase::free_members(void)
199 199 void GLATPsfBase::read_scale(const GFitsTable* hdu)
200 200 {
201 201 // Get pointer to column
202   - const GFitsTableCol* scale = &(*hdu)["PSFSCALE"];
  202 + const GFitsTableCol* scale = (*hdu)["PSFSCALE"];
203 203  
204 204 // Get scaling factors
205 205 if (front()) {
... ... @@ -256,7 +256,7 @@ void GLATPsfBase::write_scale(GFits&amp; file) const
256 256 col_scale(0,4) = m_scale_index;
257 257  
258 258 // Append column to table
259   - hdu_scale->append_column(col_scale);
  259 + hdu_scale->append(col_scale);
260 260  
261 261 // Append HDU to FITS file
262 262 file.append(*hdu_scale);
... ...
inst/lat/src/GLATPsfV1.cpp
... ... @@ -205,10 +205,10 @@ void GLATPsfV1::read(const GFitsTable* hdu)
205 205 m_gtail.reserve(size);
206 206  
207 207 // Get pointer to columns
208   - const GFitsTableCol* ncore = &(*hdu)["NCORE"];
209   - const GFitsTableCol* sigma = &(*hdu)["SIGMA"];
210   - const GFitsTableCol* gcore = &(*hdu)["GCORE"];
211   - const GFitsTableCol* gtail = &(*hdu)["GTAIL"];
  208 + const GFitsTableCol* ncore = (*hdu)["NCORE"];
  209 + const GFitsTableCol* sigma = (*hdu)["SIGMA"];
  210 + const GFitsTableCol* gcore = (*hdu)["GCORE"];
  211 + const GFitsTableCol* gtail = (*hdu)["GTAIL"];
212 212  
213 213 // Check consistency of columns
214 214 if (ncore->number() != size) {
... ... @@ -286,10 +286,10 @@ void GLATPsfV1::write(GFits&amp; file) const
286 286 }
287 287  
288 288 // Append columns to table
289   - hdu_rpsf->append_column(col_ncore);
290   - hdu_rpsf->append_column(col_sigma);
291   - hdu_rpsf->append_column(col_gcore);
292   - hdu_rpsf->append_column(col_gtail);
  289 + hdu_rpsf->append(col_ncore);
  290 + hdu_rpsf->append(col_sigma);
  291 + hdu_rpsf->append(col_gcore);
  292 + hdu_rpsf->append(col_gtail);
293 293  
294 294 // Append HDU to FITS file
295 295 file.append(*hdu_rpsf);
... ...
inst/lat/src/GLATPsfV3.cpp
... ... @@ -214,12 +214,12 @@ void GLATPsfV3::read(const GFitsTable* hdu)
214 214 m_gtail.reserve(size);
215 215  
216 216 // Get pointer to columns
217   - const GFitsTableCol* ncore = &(*hdu)["NCORE"];
218   - const GFitsTableCol* ntail = &(*hdu)["NTAIL"];
219   - const GFitsTableCol* score = &(*hdu)["SCORE"];
220   - const GFitsTableCol* stail = &(*hdu)["STAIL"];
221   - const GFitsTableCol* gcore = &(*hdu)["GCORE"];
222   - const GFitsTableCol* gtail = &(*hdu)["GTAIL"];
  217 + const GFitsTableCol* ncore = (*hdu)["NCORE"];
  218 + const GFitsTableCol* ntail = (*hdu)["NTAIL"];
  219 + const GFitsTableCol* score = (*hdu)["SCORE"];
  220 + const GFitsTableCol* stail = (*hdu)["STAIL"];
  221 + const GFitsTableCol* gcore = (*hdu)["GCORE"];
  222 + const GFitsTableCol* gtail = (*hdu)["GTAIL"];
223 223  
224 224 // Check consistency of columns
225 225 if (ncore->number() != size) {
... ... @@ -314,12 +314,12 @@ void GLATPsfV3::write(GFits&amp; file) const
314 314 }
315 315  
316 316 // Append columns to table
317   - hdu_rpsf->append_column(col_ncore);
318   - hdu_rpsf->append_column(col_ntail);
319   - hdu_rpsf->append_column(col_score);
320   - hdu_rpsf->append_column(col_stail);
321   - hdu_rpsf->append_column(col_gcore);
322   - hdu_rpsf->append_column(col_gtail);
  317 + hdu_rpsf->append(col_ncore);
  318 + hdu_rpsf->append(col_ntail);
  319 + hdu_rpsf->append(col_score);
  320 + hdu_rpsf->append(col_stail);
  321 + hdu_rpsf->append(col_gcore);
  322 + hdu_rpsf->append(col_gtail);
323 323  
324 324 // Append HDU to FITS file
325 325 file.append(*hdu_rpsf);
... ...
inst/lat/src/GLATResponseTable.cpp
1 1 /***************************************************************************
2   - * GLATResponseTable.cpp - Fermi/LAT Response table class *
  2 + * GLATResponseTable.cpp - Fermi/LAT Response table class *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2008-2013 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -184,10 +184,10 @@ void GLATResponseTable::read(const GFitsTable* hdu)
184 184 clear();
185 185  
186 186 // Get pointers to table columns
187   - const GFitsTableCol* energy_lo = &(*hdu)["ENERG_LO"];
188   - const GFitsTableCol* energy_hi = &(*hdu)["ENERG_HI"];
189   - const GFitsTableCol* ctheta_lo = &(*hdu)["CTHETA_LO"];
190   - const GFitsTableCol* ctheta_hi = &(*hdu)["CTHETA_HI"];
  187 + const GFitsTableCol* energy_lo = (*hdu)["ENERG_LO"];
  188 + const GFitsTableCol* energy_hi = (*hdu)["ENERG_HI"];
  189 + const GFitsTableCol* ctheta_lo = (*hdu)["CTHETA_LO"];
  190 + const GFitsTableCol* ctheta_hi = (*hdu)["CTHETA_HI"];
191 191  
192 192 // Extract number of bins
193 193 m_energy_num = energy_lo->number();
... ... @@ -264,10 +264,10 @@ void GLATResponseTable::write(GFitsTable* hdu) const
264 264 }
265 265  
266 266 // Append columns to boundary table
267   - hdu->append_column(col_energy_lo);
268   - hdu->append_column(col_energy_hi);
269   - hdu->append_column(col_ctheta_lo);
270   - hdu->append_column(col_ctheta_hi);
  267 + hdu->append(col_energy_lo);
  268 + hdu->append(col_energy_hi);
  269 + hdu->append(col_ctheta_lo);
  270 + hdu->append(col_ctheta_hi);
271 271  
272 272 // Return
273 273 return;
... ...
inst/mwl/src/GMWLSpectrum.cpp
1 1 /***************************************************************************
2   - * GMWLSpectrum.cpp - Multi-wavelength spectrum class *
  2 + * GMWLSpectrum.cpp - Multi-wavelength spectrum class *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2010-2013 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -636,19 +636,19 @@ void GMWLSpectrum::read_fits(const GFitsTable* table)
636 636  
637 637 // Extract column pointers
638 638 if (table->ncols() == 2) {
639   - c_energy = &(*table)[0];
640   - c_flux = &(*table)[1];
  639 + c_energy = (*table)[0];
  640 + c_flux = (*table)[1];
641 641 }
642 642 else if (table->ncols() == 3) {
643   - c_energy = &(*table)[0];
644   - c_flux = &(*table)[1];
645   - c_flux_err = &(*table)[2];
  643 + c_energy = (*table)[0];
  644 + c_flux = (*table)[1];
  645 + c_flux_err = (*table)[2];
646 646 }
647 647 else if (table->ncols() > 3) {
648   - c_energy = &(*table)[0];
649   - c_energy_err = &(*table)[1];
650   - c_flux = &(*table)[2];
651   - c_flux_err = &(*table)[3];
  648 + c_energy = (*table)[0];
  649 + c_energy_err = (*table)[1];
  650 + c_flux = (*table)[2];
  651 + c_flux_err = (*table)[3];
652 652 }
653 653 else {
654 654 throw GMWLException::bad_file_format(G_READ_FITS,
... ... @@ -659,14 +659,18 @@ void GMWLSpectrum::read_fits(const GFitsTable* table)
659 659 // Read spectral points and add to spectrum
660 660 for (int i = 0; i < table->nrows(); ++i) {
661 661 GMWLDatum datum;
662   - if (c_energy != NULL)
  662 + if (c_energy != NULL) {
663 663 datum.m_eng = conv_energy(c_energy->real(i), c_energy->unit());
664   - if (c_energy_err != NULL)
  664 + }
  665 + if (c_energy_err != NULL) {
665 666 datum.m_eng_err = conv_energy(c_energy_err->real(i), c_energy->unit());
666   - if (c_flux != NULL)
  667 + }
  668 + if (c_flux != NULL) {
667 669 datum.m_flux = conv_flux(datum.m_eng, c_flux->real(i), c_flux->unit());
668   - if (c_flux_err != NULL)
  670 + }
  671 + if (c_flux_err != NULL) {
669 672 datum.m_flux_err = conv_flux(datum.m_eng, c_flux_err->real(i), c_flux_err->unit());
  673 + }
670 674 m_data.push_back(datum);
671 675 }
672 676  
... ...
pyext/GFitsTable.i
... ... @@ -109,7 +109,7 @@ class GFitsTable : public GFitsHDU {
109 109 public:
110 110 // Constructors and destructors
111 111 GFitsTable(void);
112   - explicit GFitsTable(int nrows);
  112 + explicit GFitsTable(const int& nrows);
113 113 GFitsTable(const GFitsTable& table);
114 114 virtual ~GFitsTable(void);
115 115  
... ... @@ -119,14 +119,18 @@ public:
119 119 virtual HDUType exttype(void) const = 0;
120 120  
121 121 // Implemented Methods
122   - void append_column(GFitsTableCol& column);
123   - void insert_column(int colnum, GFitsTableCol& column);
124   - void append_rows(const int& nrows);
125   - void insert_rows(const int& rownum, const int& nrows);
126   - void remove_rows(const int& rownum, const int& nrows);
127   - bool hascolumn(const std::string& colname) const;
128   - int nrows(void) const;
129   - int ncols(void) const;
  122 + const int& size(void) const;
  123 + GFitsTableCol* set(const int& colnum, const GFitsTableCol& column);
  124 + GFitsTableCol* set(const std::string& colname, const GFitsTableCol& column);
  125 + GFitsTableCol* append(const GFitsTableCol& column);
  126 + GFitsTableCol* insert(int colnum, const GFitsTableCol& column);
  127 + GFitsTableCol* insert(const std::string& colname, const GFitsTableCol& column);
  128 + void append_rows(const int& nrows);
  129 + void insert_rows(const int& row, const int& nrows);
  130 + void remove_rows(const int& row, const int& nrows);
  131 + const int& nrows(void) const;
  132 + const int& ncols(void) const;
  133 + bool hascolumn(const std::string& colname) const;
130 134 };
131 135  
132 136  
... ... @@ -134,18 +138,18 @@ public:
134 138 * @brief GFitsTable class extension
135 139 ***************************************************************************/
136 140 %extend GFitsTable {
137   - GFitsTableCol& __getitem__(const int& colnum) {
  141 + GFitsTableCol* __getitem__(const int& colnum) {
138 142 return (*self)[colnum];
139 143 }
140   - GFitsTableCol& __getitem__(const std::string& colname) {
  144 + GFitsTableCol* __getitem__(const std::string& colname) {
141 145 return (*self)[colname];
142 146 }
143 147 void __setitem__(const int& colnum, const GFitsTableCol& col) {
144   - (*self)[colnum] = col;
  148 + self->set(colnum, col);
145 149 return;
146 150 }
147 151 void __setitem__(const std::string& colname, const GFitsTableCol& col) {
148   - (*self)[colname] = col;
  152 + self->set(colname, col);
149 153 return;
150 154 }
151 155 };
... ...
src/fits/GFitsTable.cpp
... ... @@ -55,8 +55,10 @@
55 55 /* __ Method name definitions ____________________________________________ */
56 56 #define G_ACCESS1 "GFitsTable::operator[](int&)"
57 57 #define G_ACCESS2 "GFitsTable::operator[](std::string&)"
58   -#define G_APPEND_COLUMN "GFitsTable::append_column(GFitsTableCol*)"
59   -#define G_INSERT_COLUMN "GFitsTable::insert_column(int, GFitsTableCol*)"
  58 +#define G_SET1 "GFitsTable::set(int&, GFitsTableCol&)"
  59 +#define G_SET2 "GFitsTable::set(std::string&, GFitsTableCol&)"
  60 +#define G_INSERT1 "GFitsTable::insert(int, GFitsTableCol&)"
  61 +#define G_INSERT2 "GFitsTable::insert(std::string&, GFitsTableCol&)"
60 62 #define G_INSERT_ROWS "GFitsTable::insert_rows(int&, int&)"
61 63 #define G_REMOVE_ROWS "GFitsTable::remove_rows(int&, int&)"
62 64 #define G_DATA_OPEN "GFitsTable::data_open(void*)"
... ... @@ -80,7 +82,7 @@
80 82 /***********************************************************************//**
81 83 * @brief Void constructor
82 84 *
83   - * Construct an instance of GFitsTable with zero rows.
  85 + * Construct void instance.
84 86 ***************************************************************************/
85 87 GFitsTable::GFitsTable(void) : GFitsHDU()
86 88 {
... ... @@ -97,9 +99,9 @@ GFitsTable::GFitsTable(void) : GFitsHDU()
97 99 *
98 100 * @param[in] nrows Number of rows in table.
99 101 *
100   - * Construct an instance of GFitsTable with a given number of rows.
  102 + * Construct instance for a specified number of table rows.
101 103 ***************************************************************************/
102   -GFitsTable::GFitsTable(int nrows) : GFitsHDU()
  104 +GFitsTable::GFitsTable(const int& nrows) : GFitsHDU()
103 105 {
104 106 // Initialise class members for clean destruction
105 107 init_members();
... ... @@ -115,7 +117,7 @@ GFitsTable::GFitsTable(int nrows) : GFitsHDU()
115 117 /***********************************************************************//**
116 118 * @brief Copy constructor
117 119 *
118   - * @param[in] table Table from which to construct instance.
  120 + * @param[in] table Table.
119 121 ***************************************************************************/
120 122 GFitsTable::GFitsTable(const GFitsTable& table) : GFitsHDU(table)
121 123 {
... ... @@ -153,6 +155,7 @@ GFitsTable::~GFitsTable(void)
153 155 * @brief Assignment operator
154 156 *
155 157 * @param[in] table Table.
  158 + * @return Table.
156 159 ***************************************************************************/
157 160 GFitsTable& GFitsTable::operator=(const GFitsTable& table)
158 161 {
... ... @@ -179,16 +182,17 @@ GFitsTable&amp; GFitsTable::operator=(const GFitsTable&amp; table)
179 182  
180 183  
181 184 /***********************************************************************//**
182   - * @brief Returns reference to table column
  185 + * @brief Returns pointer to table column
183 186 *
184 187 * @param[in] colnum Column number [0,...,ncols()-1].
  188 + * @return Table column pointer.
185 189 *
186 190 * @exception GException::fits_no_data
187 191 * No data found in table.
188 192 * @exception GException::out_of_range
189 193 * Column number is out of range.
190 194 ***************************************************************************/
191   -GFitsTableCol& GFitsTable::operator[](const int& colnum)
  195 +GFitsTableCol* GFitsTable::operator[](const int& colnum)
192 196 {
193 197 // If there is no data then throw an exception
194 198 if (m_columns == NULL) {
... ... @@ -197,8 +201,9 @@ GFitsTableCol&amp; GFitsTable::operator[](const int&amp; colnum)
197 201  
198 202 // Compile option: raise exception if column number is out of range
199 203 #if defined(G_RANGE_CHECK)
200   - if (colnum < 0 || colnum >= m_cols)
  204 + if (colnum < 0 || colnum >= m_cols) {
201 205 throw GException::out_of_range(G_ACCESS1, colnum, 0, m_cols-1);
  206 + }
202 207 #endif
203 208  
204 209 // Get column pointer
... ... @@ -207,22 +212,23 @@ GFitsTableCol&amp; GFitsTable::operator[](const int&amp; colnum)
207 212 throw GException::fits_no_data(G_ACCESS1, "No data for this column.");
208 213 }
209 214  
210   - // Return reference
211   - return *ptr;
  215 + // Return pointer
  216 + return ptr;
212 217 }
213 218  
214 219  
215 220 /***********************************************************************//**
216   - * @brief Returns reference to table column (const version)
  221 + * @brief Returns pointer to table column (const version)
217 222 *
218 223 * @param[in] colnum Column number [0,...,ncols()-1].
  224 + * @return Table column pointer.
219 225 *
220 226 * @exception GException::fits_no_data
221 227 * No data found in table.
222 228 * @exception GException::out_of_range
223 229 * Column number is out of range.
224 230 ***************************************************************************/
225   -const GFitsTableCol& GFitsTable::operator[](const int& colnum) const
  231 +const GFitsTableCol* GFitsTable::operator[](const int& colnum) const
226 232 {
227 233 // If there is no data then throw an exception
228 234 if (m_columns == NULL) {
... ... @@ -231,8 +237,9 @@ const GFitsTableCol&amp; GFitsTable::operator[](const int&amp; colnum) const
231 237  
232 238 // Compile option: raise exception if column number is out of range
233 239 #if defined(G_RANGE_CHECK)
234   - if (colnum < 0 || colnum >= m_cols)
  240 + if (colnum < 0 || colnum >= m_cols) {
235 241 throw GException::out_of_range(G_ACCESS1, colnum, 0, m_cols-1);
  242 + }
236 243 #endif
237 244  
238 245 // Get column pointer
... ... @@ -241,22 +248,23 @@ const GFitsTableCol&amp; GFitsTable::operator[](const int&amp; colnum) const
241 248 throw GException::fits_no_data(G_ACCESS1, "No data for this column.");
242 249 }
243 250  
244   - // Return reference
245   - return *ptr;
  251 + // Return pointer
  252 + return ptr;
246 253 }
247 254  
248 255  
249 256 /***********************************************************************//**
250   - * @brief Returns reference to table column
  257 + * @brief Returns pointer to table column
251 258 *
252 259 * @param[in] colname Column name.
  260 + * @return Table column pointer.
253 261 *
254 262 * @exception GException::fits_no_data
255 263 * No data found in table.
256 264 * @exception GException::fits_column_not_found
257 265 * Column name not found.
258 266 ***************************************************************************/
259   -GFitsTableCol& GFitsTable::operator[](const std::string& colname)
  267 +GFitsTableCol* GFitsTable::operator[](const std::string& colname)
260 268 {
261 269 // If there is no data then throw an exception
262 270 if (m_columns == NULL) {
... ... @@ -271,22 +279,23 @@ GFitsTableCol&amp; GFitsTable::operator[](const std::string&amp; colname)
271 279 throw GException::fits_column_not_found(G_ACCESS2, colname);
272 280 }
273 281  
274   - // Return reference
275   - return *ptr;
  282 + // Return pointer
  283 + return ptr;
276 284 }
277 285  
278 286  
279 287 /***********************************************************************//**
280   - * @brief Returns reference to table column (const version)
  288 + * @brief Returns pointer to table column (const version)
281 289 *
282 290 * @param[in] colname Column name.
  291 + * @return Table column pointer.
283 292 *
284 293 * @exception GException::fits_no_data
285 294 * No data found in table.
286 295 * @exception GException::fits_column_not_found
287 296 * Column name not found.
288 297 ***************************************************************************/
289   -const GFitsTableCol& GFitsTable::operator[](const std::string& colname) const
  298 +const GFitsTableCol* GFitsTable::operator[](const std::string& colname) const
290 299 {
291 300 // If there is no data then throw an exception
292 301 if (m_columns == NULL) {
... ... @@ -301,8 +310,8 @@ const GFitsTableCol&amp; GFitsTable::operator[](const std::string&amp; colname) const
301 310 throw GException::fits_column_not_found(G_ACCESS2, colname);
302 311 }
303 312  
304   - // Return reference
305   - return *ptr;
  313 + // Return pointer
  314 + return ptr;
306 315 }
307 316  
308 317  
... ... @@ -313,29 +322,66 @@ const GFitsTableCol&amp; GFitsTable::operator[](const std::string&amp; colname) const
313 322 ==========================================================================*/
314 323  
315 324 /***********************************************************************//**
316   - * @brief Append column to the table
  325 + * @brief Set column
317 326 *
318   - * @param[in] column Column which should be appended to table.
  327 + * @param[in] colnum Column number [0,...,ncols()-1].
  328 + * @param[in] column Table column.
  329 + * @return Pointer to table column that has been set.
319 330 *
320   - * A column will be appended at the end of the table. See
321   - * GFitsTable::insert_column
322   - * for more details on the method.
  331 + * Sets the column of a table by making a deep copy of the @p column
  332 + * provided.
323 333 ***************************************************************************/
324   -void GFitsTable::append_column(GFitsTableCol& column)
  334 +GFitsTableCol* GFitsTable::set(const int& colnum, const GFitsTableCol& column)
325 335 {
326   - // Inserting at the end correspond to appending
327   - insert_column(m_cols, column);
  336 + // Check if column number is valid
  337 + if (colnum < 0 || colnum >= ncols()) {
  338 + throw GException::out_of_range(G_SET1, "Column number", colnum, ncols());
  339 + }
328 340  
329   - // Return
330   - return;
  341 + // Free existing column
  342 + if (m_columns[colnum] != NULL) delete m_columns[colnum];
  343 +
  344 + // Clone column
  345 + m_columns[colnum] = column.clone();
  346 +
  347 + // Return pointer to column
  348 + return m_columns[colnum];
331 349 }
332 350  
333 351  
334 352 /***********************************************************************//**
  353 + * @brief Set column
  354 + *
  355 + * @param[in] colname Column name.
  356 + * @param[in] column Table column.
  357 + * @return Pointer to table column that has been set.
  358 + *
  359 + * Sets the column of a table by making a deep copy of the @p column
  360 + * provided.
  361 + ***************************************************************************/
  362 +GFitsTableCol* GFitsTable::set(const std::string& colname,
  363 + const GFitsTableCol& column)
  364 +{
  365 + // Get column number
  366 + int colnum = this->colnum(colname);
  367 +
  368 + // If column has not been found throw an exception
  369 + if (colnum < 0) {
  370 + throw GException::fits_column_not_found(G_SET2, colname);
  371 + }
  372 +
  373 + // Set column and return pointer to column
  374 + return (set(colnum, column));
  375 +}
  376 +
  377 +
  378 +
  379 +/***********************************************************************//**
335 380 * @brief Insert column into the table
336 381 *
337   - * @param[in] colnum Column number to be inserted.
338   - * @param[in] column Column which should be inserted into the table.
  382 + * @param[in] colnum Column number [0,...,ncols()].
  383 + * @param[in] column Table column.
  384 + * @return Pointer to table column that has been appended.
339 385 *
340 386 * @exception GException::fits_bad_col_length
341 387 * The length of the column is incompatible with the number of
... ... @@ -343,7 +389,6 @@ void GFitsTable::append_column(GFitsTableCol&amp; column)
343 389 *
344 390 * A column will be inserted at position 'colnum' of the table. If the
345 391 * position is beyond the end of the table the column will be appended.
346   - * Any 'colnum' value smaller than 0 will be set automatically to 0.
347 392 *
348 393 * If the table is empty and has 0 rows, the number of rows will be set to
349 394 * the length of the column.
... ... @@ -351,24 +396,31 @@ void GFitsTable::append_column(GFitsTableCol&amp; column)
351 396 * The length of the column to be inserted has to be identical to the number
352 397 * of rows in the table.
353 398 ***************************************************************************/
354   -void GFitsTable::insert_column(int colnum, GFitsTableCol& column)
  399 +GFitsTableCol* GFitsTable::insert(int colnum, const GFitsTableCol& column)
355 400 {
356 401 // Make sure that 'colnum' is valid. Since we add one column the total
357 402 // number of columns at return will be m_cols+1, hence the column
358 403 // index is comprised between [0,m_cols]
359   - if (colnum < 0) colnum = 0;
360   - if (colnum > m_cols) colnum = m_cols;
  404 + //if (colnum < 0) colnum = 0;
  405 + //if (colnum > m_cols) colnum = m_cols;
  406 +
  407 + // Check if column number is valid
  408 + if (colnum < 0 || colnum > ncols()) {
  409 + throw GException::out_of_range(G_INSERT1, "Column number", colnum, ncols()+1);
  410 + }
361 411  
362 412 // If the table is empty and has 0 rows then set the number of rows in
363 413 // the table to the length of the column
364   - if (m_columns == NULL && m_rows == 0)
  414 + if (m_columns == NULL && m_rows == 0) {
365 415 m_rows = column.length();
  416 + }
366 417  
367 418 // Throw exception if the column length is incompatible with number of
368 419 // rows in the table
369   - if (m_rows != column.length())
370   - throw GException::fits_bad_col_length(G_INSERT_COLUMN,
  420 + if (m_rows != column.length()) {
  421 + throw GException::fits_bad_col_length(G_INSERT1,
371 422 column.length(), m_rows);
  423 + }
372 424  
373 425 // If no column data exist then allocate them now
374 426 if (m_columns == NULL) {
... ... @@ -389,8 +441,9 @@ void GFitsTable::insert_column(int colnum, GFitsTableCol&amp; column)
389 441 int src;
390 442 int dst;
391 443 for (src = 0, dst = 0; dst < m_cols+1; ++dst) {
392   - if (dst == colnum)
  444 + if (dst == colnum) {
393 445 tmp[dst] = NULL;
  446 + }
394 447 else {
395 448 tmp[dst] = m_columns[src];
396 449 src++;
... ... @@ -415,8 +468,33 @@ void GFitsTable::insert_column(int colnum, GFitsTableCol&amp; column)
415 468 // file
416 469 m_columns[colnum]->colnum(0);
417 470  
418   - // Return
419   - return;
  471 + // Return column pointer
  472 + return (m_columns[colnum]);
  473 +}
  474 +
  475 +
  476 +/***********************************************************************//**
  477 + * @brief Insert column into the table
  478 + *
  479 + * @param[in] colname Column name.
  480 + * @param[in] column Table column.
  481 + * @return Pointer to table column that has been appended
  482 + *
  483 + * Inserts the column at the position given by the specified column name.
  484 + ***************************************************************************/
  485 +GFitsTableCol* GFitsTable::insert(const std::string& colname,
  486 + const GFitsTableCol& column)
  487 +{
  488 + // Get column number
  489 + int colnum = this->colnum(colname);
  490 +
  491 + // If column has not been found throw an exception
  492 + if (colnum < 0) {
  493 + throw GException::fits_column_not_found(G_INSERT2, colname);
  494 + }
  495 +
  496 + // Insert column and return pointer to column
  497 + return (insert(colnum, column));
420 498 }
421 499  
422 500  
... ... @@ -425,8 +503,9 @@ void GFitsTable::insert_column(int colnum, GFitsTableCol&amp; column)
425 503 *
426 504 * @param[in] nrows Number of rows to be appended.
427 505 *
428   - * This method appends rows to a FITS table. This implies that all columns
429   - * will be loaded into memory.
  506 + * Appends @p nrows rows at the end of the FITS table. The method calls the
  507 + * insert() method to do the job. Note that a call of this method will lead
  508 + * to loading all table data into memory.
430 509 ***************************************************************************/
431 510 void GFitsTable::append_rows(const int& nrows)
432 511 {
... ... @@ -444,27 +523,31 @@ void GFitsTable::append_rows(const int&amp; nrows)
444 523 /***********************************************************************//**
445 524 * @brief Insert rows into the table
446 525 *
447   - * @param[in] rownum Row after which rows should be inserted (0=first row).
  526 + * @param[in] row Row at which rows are inserted [0,...,nrows()].
448 527 * @param[in] nrows Number of rows to be inserted.
449 528 *
450 529 * @exception GException::fits_invalid_row
451 530 * Specified rownum is invalid.
452 531 *
453   - * This method inserts rows into a FITS table. This implies that all columns
454   - * will be loaded into memory.
  532 + * Inserts @p nrows table rows at the specified @p row into the table. If the
  533 + * @p row index is set to the number of existing rows, nrows(), @p nrows
  534 + * will be appened at the end of the table.
  535 + *
  536 + * Note that this method will load all table data into memory.
455 537 ***************************************************************************/
456   -void GFitsTable::insert_rows(const int& rownum, const int& nrows)
  538 +void GFitsTable::insert_rows(const int& row, const int& nrows)
457 539 {
458   - // Make sure that rownum is valid
459   - if (rownum < 0 || rownum > m_rows)
460   - throw GException::fits_invalid_row(G_INSERT_ROWS, rownum, m_rows);
  540 + // Make sure that row is valid
  541 + if (row < 0 || row > m_rows) {
  542 + throw GException::fits_invalid_row(G_INSERT_ROWS, row, m_rows);
  543 + }
461 544  
462 545 // Continue only if there are rows to be inserted
463 546 if (nrows > 0) {
464 547  
465 548 // Insert rows for all columns
466 549 for (int icol = 0; icol < m_cols; ++icol) {
467   - m_columns[icol]->insert(rownum, nrows);
  550 + m_columns[icol]->insert(row, nrows);
468 551 }
469 552  
470 553 // Increment number of rows in table
... ... @@ -480,7 +563,7 @@ void GFitsTable::insert_rows(const int&amp; rownum, const int&amp; nrows)
480 563 /***********************************************************************//**
481 564 * @brief Remove rows from the table
482 565 *
483   - * @param[in] rownum Row after which rows should be removed (0=first row).
  566 + * @param[in] row Row from which on rows are removed [0,...,nrows()-1].
484 567 * @param[in] nrows Number of rows to be removed.
485 568 *
486 569 * @exception GException::fits_invalid_row
... ... @@ -488,25 +571,28 @@ void GFitsTable::insert_rows(const int&amp; rownum, const int&amp; nrows)
488 571 * @exception GException::fits_invalid_nrows
489 572 * Invalid number of rows specified.
490 573 *
491   - * This method inserts rows into a FITS table. This implies that all columns
492   - * will be loaded into memory.
  574 + * Removes @p nrows table rows from the specified @p row on from the table.
  575 + *
  576 + * Note that this method will load all column data into memory.
493 577 ***************************************************************************/
494   -void GFitsTable::remove_rows(const int& rownum, const int& nrows)
  578 +void GFitsTable::remove_rows(const int& row, const int& nrows)
495 579 {
496   - // Make sure that rownum is valid
497   - if (rownum < 0 || rownum >= m_rows)
498   - throw GException::fits_invalid_row(G_REMOVE_ROWS, rownum, m_rows-1);
  580 + // Make sure that row is valid
  581 + if (row < 0 || row >= m_rows) {
  582 + throw GException::fits_invalid_row(G_REMOVE_ROWS, row, m_rows-1);
  583 + }
499 584  
500 585 // Make sure that we don't remove beyond the limit
501   - if (nrows < 0 || nrows > m_rows-rownum)
502   - throw GException::fits_invalid_nrows(G_REMOVE_ROWS, nrows, m_rows-rownum);
  586 + if (nrows < 0 || nrows > m_rows-row) {
  587 + throw GException::fits_invalid_nrows(G_REMOVE_ROWS, nrows, m_rows-row);
  588 + }
503 589  
504 590 // Continue only if there are rows to be removed
505 591 if (nrows > 0) {
506 592  
507   - // Insert rows for all columns
  593 + // Remove rows for all columns
508 594 for (int icol = 0; icol < m_cols; ++icol) {
509   - m_columns[icol]->remove(rownum, nrows);
  595 + m_columns[icol]->remove(row, nrows);
510 596 }
511 597  
512 598 // Decrement number of rows in table
... ... @@ -520,29 +606,10 @@ void GFitsTable::remove_rows(const int&amp; rownum, const int&amp; nrows)
520 606  
521 607  
522 608 /***********************************************************************//**
523   - * @brief Return number of rows in table
524   - ***************************************************************************/
525   -int GFitsTable::nrows(void) const
526   -{
527   - // Return number of rows
528   - return m_rows;
529   -}
530   -
531   -
532   -/***********************************************************************//**
533   - * @brief Return number of columns in table
534   - ***************************************************************************/
535   -int GFitsTable::ncols(void) const
536   -{
537   - // Return number of columns
538   - return m_cols;
539   -}
540   -
541   -
542   -/***********************************************************************//**
543 609 * @brief Checks the presence of a column in table
544 610 *
545 611 * @param[in] colname Column name.
  612 + * @return True of the column exists, false otherwise.
546 613 ***************************************************************************/
547 614 bool GFitsTable::hascolumn(const std::string& colname) const
548 615 {
... ... @@ -589,8 +656,10 @@ std::string GFitsTable::print(const GChatter&amp; chatter) const
589 656 }
590 657  
591 658 // Append table dimensions
592   - result.append(gammalib::parformat("Number of rows")+gammalib::str(m_rows)+"\n");
593   - result.append(gammalib::parformat("Number of columns")+gammalib::str(m_cols)+"\n");
  659 + result.append(gammalib::parformat("Number of rows"));
  660 + result.append(gammalib::str(m_rows)+"\n");
  661 + result.append(gammalib::parformat("Number of columns"));
  662 + result.append(gammalib::str(m_cols)+"\n");
594 663  
595 664 // Append header information
596 665 result.append(m_header.print(chatter));
... ... @@ -1380,10 +1449,12 @@ void GFitsTable::copy_members(const GFitsTable&amp; table)
1380 1449 if (table.m_columns != NULL && m_cols > 0) {
1381 1450 m_columns = new GFitsTableCol*[m_cols];
1382 1451 for (int i = 0; i < m_cols; ++i) {
1383   - if (table.m_columns[i] != NULL)
  1452 + if (table.m_columns[i] != NULL) {
1384 1453 m_columns[i] = table.m_columns[i]->clone();
1385   - else
  1454 + }
  1455 + else {
1386 1456 m_columns[i] = NULL;
  1457 + }
1387 1458 }
1388 1459 }
1389 1460  
... ... @@ -1482,10 +1553,12 @@ GFitsTableCol* GFitsTable::alloc_column(int typecode) const
1482 1553 * @brief Returns pointer of column with given name
1483 1554 *
1484 1555 * @param[in] colname Name of column.
  1556 + * @return Pointer to table column (NULL if column has not been found).
1485 1557 *
1486   - * This method returns a pointer on the column with the specified name. It
1487   - * returns NULL if no column with the given name was found, or if the
1488   - * column is not allocated.
  1558 + * Returns a pointer to the column with the specified name. If more columns
  1559 + * with the same name exist, a pointer to the first of these columns is
  1560 + * returned. If no column with the specified name is found, a NULL pointer
  1561 + * will be returned.
1489 1562 ***************************************************************************/
1490 1563 GFitsTableCol* GFitsTable::ptr_column(const std::string& colname) const
1491 1564 {
... ... @@ -1505,3 +1578,32 @@ GFitsTableCol* GFitsTable::ptr_column(const std::string&amp; colname) const
1505 1578 // Return pointer
1506 1579 return ptr;
1507 1580 }
  1581 +
  1582 +
  1583 +/***********************************************************************//**
  1584 + * @brief Returns column number of a given column name
  1585 + *
  1586 + * @param[in] colname Name of column.
  1587 + * @return Column number (-1 if column has not been found).
  1588 + *
  1589 + * Returns the column number of the column with the specified name. If more
  1590 + * columns with the same name exist, the first of these columns is returned.
  1591 + ***************************************************************************/
  1592 +int GFitsTable::colnum(const std::string& colname) const
  1593 +{
  1594 + // Initialise column number
  1595 + int colnum = -1;
  1596 +
  1597 + // If there are columns then search for the specified name
  1598 + if (m_columns != NULL) {
  1599 + for (int i = 0; i < m_cols; ++i) {
  1600 + if (m_columns[i]->name() == colname) {
  1601 + colnum = i;
  1602 + break;
  1603 + }
  1604 + }
  1605 + }
  1606 +
  1607 + // Return column number
  1608 + return colnum;
  1609 +}
... ...
src/obs/GEbounds.cpp
... ... @@ -633,8 +633,8 @@ void GEbounds::read(GFitsTable* hdu)
633 633  
634 634 // Copy information
635 635 for (int i = 0; i < m_num; ++i) {
636   - m_min[i].keV((*hdu)["E_MIN"].real(i));
637   - m_max[i].keV((*hdu)["E_MAX"].real(i));
  636 + m_min[i].keV((*hdu)["E_MIN"]->real(i));
  637 + m_max[i].keV((*hdu)["E_MAX"]->real(i));
638 638 }
639 639  
640 640 } // endif: there were channels to read
... ... @@ -679,8 +679,8 @@ void GEbounds::write(GFits* file, const std::string&amp; extname) const
679 679  
680 680 // Create binary table
681 681 GFitsBinTable* table = new GFitsBinTable(m_num);
682   - table->append_column(cemin);
683   - table->append_column(cemax);
  682 + table->append(cemin);
  683 + table->append(cemax);
684 684 table->extname(extname);
685 685  
686 686 // Write to FITS file
... ...
src/obs/GEnergies.cpp
... ... @@ -438,11 +438,11 @@ void GEnergies::read(const GFitsTable* hdu)
438 438 }
439 439  
440 440 // Get the column with the name "Energy"
441   - const GFitsTableCol& col_energy = (*hdu)["Energy"];
  441 + const GFitsTableCol* col_energy = (*hdu)["Energy"];
442 442  
443 443 // Set energies
444 444 for (int i = 0; i < num; ++i) {
445   - append(GEnergy(col_energy.real(i), unit));
  445 + append(GEnergy(col_energy->real(i), unit));
446 446 }
447 447  
448 448 } // endif: there were energy bins
... ... @@ -478,7 +478,7 @@ void GEnergies::write(GFits* file, const std::string&amp; extname) const
478 478  
479 479 // Create energies table
480 480 GFitsBinTable* table = new GFitsBinTable(num);
481   - table->append_column(col_energy);
  481 + table->append(col_energy);
482 482 table->extname(extname);
483 483  
484 484 // Write to FITS file
... ...
src/obs/GGti.cpp
... ... @@ -606,8 +606,8 @@ void GGti::read(const GFitsTable* hdu)
606 606 m_start = new GTime[m_num];
607 607 m_stop = new GTime[m_num];
608 608 for (int i = 0; i < m_num; ++i) {
609   - m_start[i].set((*hdu)["START"].real(i), m_reference);
610   - m_stop[i].set((*hdu)["STOP"].real(i), m_reference);
  609 + m_start[i].set((*hdu)["START"]->real(i), m_reference);
  610 + m_stop[i].set((*hdu)["STOP"]->real(i), m_reference);
611 611 }
612 612  
613 613 // Set attributes
... ... @@ -647,8 +647,8 @@ void GGti::write(GFits* file, const std::string&amp; extname) const
647 647  
648 648 // Create GTI table
649 649 GFitsBinTable* table = new GFitsBinTable(m_num);
650   - table->append_column(cstart);
651   - table->append_column(cstop);
  650 + table->append(cstart);
  651 + table->append(cstop);
652 652 table->extname(extname);
653 653  
654 654 // Write time reference
... ...
src/sky/GSkymap.cpp
... ... @@ -1329,7 +1329,7 @@ void GSkymap::read_healpix(const GFitsTable* hdu)
1329 1329 // all columns. Only count columns that can fully hold the map.
1330 1330 m_num_maps = 0;
1331 1331 for (int icol = 0; icol < ncols; ++icol) {
1332   - const GFitsTableCol* col = &(*hdu)[icol];
  1332 + const GFitsTableCol* col = (*hdu)[icol];
1333 1333 if (col->number() % nentry == 0) {
1334 1334 m_num_maps += col->number() / nentry;
1335 1335 }
... ... @@ -1348,7 +1348,7 @@ void GSkymap::read_healpix(const GFitsTable* hdu)
1348 1348 for (int icol = 0; icol < ncols; ++icol) {
1349 1349  
1350 1350 // Get next column
1351   - const GFitsTableCol* col = &(*hdu)[icol];
  1351 + const GFitsTableCol* col = (*hdu)[icol];
1352 1352  
1353 1353 // Only consider columns that can fully hold maps
1354 1354 if (col->number() % nentry == 0) {
... ... @@ -1562,7 +1562,7 @@ GFitsBinTable* GSkymap::create_healpix_hdu(void) const
1562 1562  
1563 1563 // Create HDU that contains Healpix map in a binary table
1564 1564 hdu = new GFitsBinTable(rows);
1565   - hdu->append_column(column);
  1565 + hdu->append(column);
1566 1566  
1567 1567 } // endif: there were pixels
1568 1568  
... ...
src/xspec/GArf.cpp
... ... @@ -311,9 +311,9 @@ void GArf::read(const GFitsTable* hdu)
311 311 if (hdu != NULL) {
312 312  
313 313 // Get pointer to data columns
314   - const GFitsTableCol* energy_lo = &(*hdu)["ENERG_LO"];
315   - const GFitsTableCol* energy_hi = &(*hdu)["ENERG_HI"];
316   - const GFitsTableCol* specresp = &(*hdu)["SPECRESP"];
  314 + const GFitsTableCol* energy_lo = (*hdu)["ENERG_LO"];
  315 + const GFitsTableCol* energy_hi = (*hdu)["ENERG_HI"];
  316 + const GFitsTableCol* specresp = (*hdu)["SPECRESP"];
317 317  
318 318 // Determine effective area conversion factor. Internal
319 319 // units are cm^2
... ... @@ -384,9 +384,9 @@ void GArf::write(GFits&amp; fits) const
384 384 hdu->extname("SPECRESP");
385 385  
386 386 // Append columns to table
387   - hdu->append_column(energy_lo);
388   - hdu->append_column(energy_hi);
389   - hdu->append_column(specresp);
  387 + hdu->append(energy_lo);
  388 + hdu->append(energy_hi);
  389 + hdu->append(specresp);
390 390  
391 391 // Append HDU to FITS file
392 392 fits.append(*hdu);
... ...
src/xspec/GPha.cpp
... ... @@ -400,7 +400,7 @@ void GPha::read(const GFitsTable* hdu)
400 400 if (hdu != NULL) {
401 401  
402 402 // Get data column
403   - const GFitsTableCol& col_data = (*hdu)["COUNTS"];
  403 + const GFitsTableCol* col_data = (*hdu)["COUNTS"];
404 404  
405 405 // Extract number of channels in FITS file
406 406 int length = hdu->integer("NAXIS2");
... ... @@ -423,7 +423,7 @@ void GPha::read(const GFitsTable* hdu)
423 423  
424 424 // Copy data
425 425 for (int i = 0; i < length; ++i) {
426   - m_counts[i] = col_data.real(i);
  426 + m_counts[i] = col_data->real(i);
427 427 }
428 428  
429 429 } // endif: HDU was valid
... ... @@ -469,14 +469,14 @@ void GPha::write(GFits&amp; fits) const
469 469 hdu->extname("SPECTRUM");
470 470  
471 471 // Append columns to table
472   - hdu->append_column(col_chan);
473   - hdu->append_column(col_data);
474   - hdu->append_column(col_stat);
475   - hdu->append_column(col_syst);
476   - hdu->append_column(col_qual);
477   - hdu->append_column(col_grpg);
478   - hdu->append_column(col_area);
479   - hdu->append_column(col_back);
  472 + hdu->append(col_chan);
  473 + hdu->append(col_data);
  474 + hdu->append(col_stat);
  475 + hdu->append(col_syst);
  476 + hdu->append(col_qual);
  477 + hdu->append(col_grpg);
  478 + hdu->append(col_area);
  479 + hdu->append(col_back);
480 480  
481 481 // Append HDU to FITS file
482 482 fits.append(*hdu);
... ...
src/xspec/GRmf.cpp
... ... @@ -331,12 +331,12 @@ void GRmf::read(const GFitsTable* hdu)
331 331 m_ebds_true.clear();
332 332  
333 333 // Get pointer to data columns
334   - const GFitsTableCol* energy_lo = &(*hdu)["ENERG_LO"];
335   - const GFitsTableCol* energy_hi = &(*hdu)["ENERG_HI"];
336   - const GFitsTableCol* n_grp = &(*hdu)["N_GRP"];
337   - const GFitsTableCol* f_chan = &(*hdu)["F_CHAN"];
338   - const GFitsTableCol* n_chan = &(*hdu)["N_CHAN"];
339   - const GFitsTableCol* matrix = &(*hdu)["MATRIX"];
  334 + const GFitsTableCol* energy_lo = (*hdu)["ENERG_LO"];
  335 + const GFitsTableCol* energy_hi = (*hdu)["ENERG_HI"];
  336 + const GFitsTableCol* n_grp = (*hdu)["N_GRP"];
  337 + const GFitsTableCol* f_chan = (*hdu)["F_CHAN"];
  338 + const GFitsTableCol* n_chan = (*hdu)["N_CHAN"];
  339 + const GFitsTableCol* matrix = (*hdu)["MATRIX"];
340 340  
341 341 // Set matrix rows and columns
342 342 int rows = energy_lo->length();
... ... @@ -482,12 +482,12 @@ void GRmf::write(GFits&amp; fits) const
482 482 hdu->extname("MATRIX");
483 483  
484 484 // Append columns to table
485   - hdu->append_column(energy_lo);
486   - hdu->append_column(energy_hi);
487   - hdu->append_column(n_grp);
488   - hdu->append_column(f_chan);
489   - hdu->append_column(n_chan);
490   - hdu->append_column(matrix);
  485 + hdu->append(energy_lo);
  486 + hdu->append(energy_hi);
  487 + hdu->append(n_grp);
  488 + hdu->append(f_chan);
  489 + hdu->append(n_chan);
  490 + hdu->append(matrix);
491 491  
492 492 // Append HDU to FITS file
493 493 fits.append(*hdu);
... ...
test/test_GFits.cpp
... ... @@ -348,10 +348,10 @@
348 348 try { \
349 349 GFits fits; \
350 350 fits.open(filename, true); \
351   - GFitsBinTable table = GFitsBinTable(nrows); \
352   - table.append_column(col1); \
353   - table.insert_column(1, col2); \
354   - table.append_column(col3); \
  351 + GFitsBinTable table(nrows); \
  352 + table.append(col1); \
  353 + table.insert(1, col2); \
  354 + table.append(col3); \
355 355 fits.append(table); \
356 356 fits.save(); \
357 357 fits.close(); \
... ... @@ -498,8 +498,8 @@ void TestGFits::test_create(void)
498 498 first(1) = 2.0;
499 499 first(2) = 3.0;
500 500 second(0) = -99.0;
501   - table.append_column(first);
502   - table.append_column(second);
  501 + table.append(first);
  502 + table.append(second);
503 503  
504 504 // Append table to FILE file
505 505 fits.append(table);
... ... @@ -529,8 +529,8 @@ void TestGFits::test_create(void)
529 529 first(1) = 2.0;
530 530 first(2) = 3.0;
531 531 second(0) = -99.0;
532   - table.append_column(first);
533   - table.append_column(second);
  532 + table.append(first);
  533 + table.append(second);
534 534  
535 535 // Append table to FILE file
536 536 fits.append(table);
... ... @@ -1024,8 +1024,8 @@ void TestGFits::test_bintable_double(void)
1024 1024 test_try("Read Tables");
1025 1025 try {
1026 1026 GFits fits(filename);
1027   - col1 = static_cast<GFitsTableDoubleCol&>((*fits.table(1))["DOUBLE"]);
1028   - col2 = static_cast<GFitsTableDoubleCol&>((*fits.table(1))["DOUBLE10"]);
  1027 + col1 = static_cast<GFitsTableDoubleCol&>(*(*fits.table(1))["DOUBLE"]);
  1028 + col2 = static_cast<GFitsTableDoubleCol&>(*(*fits.table(1))["DOUBLE10"]);
1029 1029 fits.close();
1030 1030 test_try_success();
1031 1031 }
... ... @@ -1078,8 +1078,8 @@ void TestGFits::test_bintable_float(void)
1078 1078 test_try("Read Tables");
1079 1079 try {
1080 1080 GFits fits(filename);
1081   - col1 = static_cast<GFitsTableFloatCol&>((*fits.table(1))["FLOAT"]);
1082   - col2 = static_cast<GFitsTableFloatCol&>((*fits.table(1))["FLOAT10"]);
  1081 + col1 = static_cast<GFitsTableFloatCol&>(*(*fits.table(1))["FLOAT"]);
  1082 + col2 = static_cast<GFitsTableFloatCol&>(*(*fits.table(1))["FLOAT10"]);
1083 1083 fits.close();
1084 1084 test_try_success();
1085 1085 }
... ... @@ -1133,8 +1133,8 @@ void TestGFits::test_bintable_short(void)
1133 1133 test_try("Read Tables");
1134 1134 try {
1135 1135 GFits fits(filename);
1136   - col1 = static_cast<GFitsTableShortCol&>((*fits.table(1))["SHORT"]);
1137   - col2 = static_cast<GFitsTableShortCol&>((*fits.table(1))["SHORT10"]);
  1136 + col1 = static_cast<GFitsTableShortCol&>(*(*fits.table(1))["SHORT"]);
  1137 + col2 = static_cast<GFitsTableShortCol&>(*(*fits.table(1))["SHORT10"]);
1138 1138 fits.close();
1139 1139 test_try_success();
1140 1140 }
... ... @@ -1188,8 +1188,8 @@ void TestGFits::test_bintable_short(void)
1188 1188 test_try("Read Tables");
1189 1189 try {
1190 1190 GFits fits(filename);
1191   - col1 = static_cast<GFitsTableUShortCol&>((*fits.table(1))["USHORT"]);
1192   - col2 = static_cast<GFitsTableUShortCol&>((*fits.table(1))["USHORT10"]);
  1191 + col1 = static_cast<GFitsTableUShortCol&>(*(*fits.table(1))["USHORT"]);
  1192 + col2 = static_cast<GFitsTableUShortCol&>(*(*fits.table(1))["USHORT10"]);
1193 1193 fits.close();
1194 1194 test_try_success();
1195 1195 }
... ... @@ -1243,8 +1243,8 @@ void TestGFits::test_bintable_long(void)
1243 1243 test_try("Read Tables");
1244 1244 try {
1245 1245 GFits fits(filename);
1246   - col1 = static_cast<GFitsTableLongCol&>((*fits.table(1))["LONG"]);
1247   - col2 = static_cast<GFitsTableLongCol&>((*fits.table(1))["LONG10"]);
  1246 + col1 = static_cast<GFitsTableLongCol&>(*(*fits.table(1))["LONG"]);
  1247 + col2 = static_cast<GFitsTableLongCol&>(*(*fits.table(1))["LONG10"]);
1248 1248 fits.close();
1249 1249 test_try_success();
1250 1250 }
... ... @@ -1298,8 +1298,8 @@ void TestGFits::test_bintable_longlong(void)
1298 1298 test_try("Read Tables");
1299 1299 try {
1300 1300 GFits fits(filename);
1301   - col1 = static_cast<GFitsTableLongLongCol&>((*fits.table(1))["LONGLONG"]);
1302   - col2 = static_cast<GFitsTableLongLongCol&>((*fits.table(1))["LONGLONG10"]);
  1301 + col1 = static_cast<GFitsTableLongLongCol&>(*(*fits.table(1))["LONGLONG"]);
  1302 + col2 = static_cast<GFitsTableLongLongCol&>(*(*fits.table(1))["LONGLONG10"]);
1303 1303 fits.close();
1304 1304 test_try_success();
1305 1305 }
... ... @@ -1353,8 +1353,8 @@ void TestGFits::test_bintable_ulong(void)
1353 1353 test_try("Read Tables");
1354 1354 try {
1355 1355 GFits fits(filename);
1356   - col1 = static_cast<GFitsTableULongCol&>((*fits.table(1))["ULONG"]);
1357   - col2 = static_cast<GFitsTableULongCol&>((*fits.table(1))["ULONG10"]);
  1356 + col1 = static_cast<GFitsTableULongCol&>(*(*fits.table(1))["ULONG"]);
  1357 + col2 = static_cast<GFitsTableULongCol&>(*(*fits.table(1))["ULONG10"]);
1358 1358 fits.close();
1359 1359 test_try_success();
1360 1360 }
... ... @@ -1409,8 +1409,8 @@ void TestGFits::test_bintable_string(void)
1409 1409 test_try("Read Tables");
1410 1410 try {
1411 1411 GFits fits(filename);
1412   - col1 = static_cast<GFitsTableStringCol&>((*fits.table(1))["STRING"]);
1413   - col2 = static_cast<GFitsTableStringCol&>((*fits.table(1))["STRING10"]);
  1412 + col1 = static_cast<GFitsTableStringCol&>(*(*fits.table(1))["STRING"]);
  1413 + col2 = static_cast<GFitsTableStringCol&>(*(*fits.table(1))["STRING10"]);
1414 1414 fits.close();
1415 1415 test_try_success();
1416 1416 }
... ... @@ -1464,8 +1464,8 @@ void TestGFits::test_bintable_logical(void)
1464 1464 test_try("Read Tables");
1465 1465 try {
1466 1466 GFits fits(filename);
1467   - col1 = static_cast<GFitsTableBoolCol&>((*fits.table(1))["LOGICAL"]);
1468   - col2 = static_cast<GFitsTableBoolCol&>((*fits.table(1))["LOGICAL10"]);
  1467 + col1 = static_cast<GFitsTableBoolCol&>(*(*fits.table(1))["LOGICAL"]);
  1468 + col2 = static_cast<GFitsTableBoolCol&>(*(*fits.table(1))["LOGICAL10"]);
1469 1469 fits.close();
1470 1470 test_try_success();
1471 1471 }
... ... @@ -1519,8 +1519,8 @@ void TestGFits::test_bintable_bit(void)
1519 1519 test_try("Read Tables");
1520 1520 try {
1521 1521 GFits fits(filename);
1522   - col1 = static_cast<GFitsTableBitCol&>((*fits.table(1))["BIT"]);
1523   - col2 = static_cast<GFitsTableBitCol&>((*fits.table(1))["BIT10"]);
  1522 + col1 = *(static_cast<GFitsTableBitCol*>((*fits.table(1))["BIT"]));
  1523 + col2 = *(static_cast<GFitsTableBitCol*>((*fits.table(1))["BIT10"]));
1524 1524 fits.close();
1525 1525 test_try_success();
1526 1526 }
... ...
test/test_GFits.py
... ... @@ -154,34 +154,34 @@ class Test(GPythonTestSuite):
154 154  
155 155 # Set ASCII table
156 156 tbl_ascii = GFitsAsciiTable()
157   - # tbl_ascii.append_column(col1) # Need to implement ?/!
158   - # tbl_ascii.append_column(col2) # Need to implement ?/!
159   - tbl_ascii.append_column(col3)
160   - tbl_ascii.append_column(col4)
161   - tbl_ascii.append_column(col5)
162   - tbl_ascii.append_column(col6)
163   - tbl_ascii.append_column(col7)
164   - tbl_ascii.append_column(col8)
165   - tbl_ascii.append_column(col9)
166   - tbl_ascii.append_column(col10)
167   - tbl_ascii.append_column(col11)
  157 + # tbl_ascii.append(col1) # Need to implement ?/!
  158 + # tbl_ascii.append(col2) # Need to implement ?/!
  159 + tbl_ascii.append(col3)
  160 + tbl_ascii.append(col4)
  161 + tbl_ascii.append(col5)
  162 + tbl_ascii.append(col6)
  163 + tbl_ascii.append(col7)
  164 + tbl_ascii.append(col8)
  165 + tbl_ascii.append(col9)
  166 + tbl_ascii.append(col10)
  167 + tbl_ascii.append(col11)
168 168 tbl_ascii.extname("ASCII table")
169 169 fits.append(tbl_ascii)
170 170 sys.stdout.write(".")
171 171  
172 172 # Set binary table
173 173 tbl_bin = GFitsBinTable()
174   - tbl_bin.append_column(col1)
175   - tbl_bin.append_column(col2)
176   - tbl_bin.append_column(col3)
177   - tbl_bin.append_column(col4)
178   - tbl_bin.append_column(col5)
179   - tbl_bin.append_column(col6)
180   - tbl_bin.append_column(col7)
181   - tbl_bin.append_column(col8)
182   - tbl_bin.append_column(col9)
183   - tbl_bin.append_column(col10)
184   - tbl_bin.append_column(col11)
  174 + tbl_bin.append(col1)
  175 + tbl_bin.append(col2)
  176 + tbl_bin.append(col3)
  177 + tbl_bin.append(col4)
  178 + tbl_bin.append(col5)
  179 + tbl_bin.append(col6)
  180 + tbl_bin.append(col7)
  181 + tbl_bin.append(col8)
  182 + tbl_bin.append(col9)
  183 + tbl_bin.append(col10)
  184 + tbl_bin.append(col11)
185 185 tbl_bin.extname("Binary table")
186 186 fits.append(tbl_bin)
187 187 sys.stdout.write(".")
... ...