diff --git a/AUTHORS b/AUTHORS index 033feed..7102eec 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,6 +3,7 @@ François Brun (brun@cenbg.in2p3.fr) Joshua Cardenzana (jcardenzana@irap.omp.eu) Jean-Baptiste Cayrou (cayrou@etud.insa-toulouse.fr) Christoph Deil (Christoph.Deil@mpi-hd.mpg.de) +Leonardo Di Venere (leonardo.divenere@ba.infn.it) Alex Donath (Axel.Donath@mpi-hd.mpg.de) Stefan Eschbach (stefan.eschbach@fau.de) Florent Forest (florent.forest@isae.fr) diff --git a/ChangeLog b/ChangeLog index ae80078..b3c8932 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2017-04-10 +2017-04-11 * Version 1.3.0 released ========================= + Add GEventList::append_column() method (#1991) Add scalar addition and subtraction operators to matrix classes (#1990) Allow fitting of scale parameter in composite models (#1992) Add GCTAAeff::ebounds() method (#1989) diff --git a/NEWS b/NEWS index 881d158..d5ca0b1 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in GammaLib 1.3.0.dev1 -10 April 2017 +11 April 2017 1. Introduction @@ -47,6 +47,7 @@ The following methods have been added: - GCTAAeff2D::ebounds() - GCTAAeffArf::ebounds() - GCTAAeffPerfTable::ebounds() +- GCTAEventList::append_column(GFitsTableCol&) The following methods have been removed: - ... @@ -212,6 +213,11 @@ effective area returned is always zero. A counter has been added that leads to the exit of the loop in case that 1000 subsequent zero values are returned (#1988). +A GCTAEventList::append_column() method has been added to allow appending of +FITS columns to an event list. The method checks whether the length of the +FITS column is compatible with the number of events that are present in the +event list (#1991). + 21. COMPTEL interface --------------------- diff --git a/inst/cta/include/GCTAEventList.hpp b/inst/cta/include/GCTAEventList.hpp index a1447e9..e6054b3 100644 --- a/inst/cta/include/GCTAEventList.hpp +++ b/inst/cta/include/GCTAEventList.hpp @@ -40,6 +40,7 @@ class GFilename; class GFitsHDU; class GFitsTable; class GFitsBinTable; +class GFitsTableCol; /* __ Constants __________________________________________________________ */ namespace gammalib { @@ -85,6 +86,7 @@ public: // Implement other methods void append(const GCTAEventAtom& event); + void append_column(const GFitsTableCol& column); void reserve(const int& number); void remove(const int& index, const int& number = 1); void write(GFits& fits, const std::string& evtname, diff --git a/inst/cta/pyext/GCTAEventList.i b/inst/cta/pyext/GCTAEventList.i index 007249d..762257d 100644 --- a/inst/cta/pyext/GCTAEventList.i +++ b/inst/cta/pyext/GCTAEventList.i @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAEventList.i - CTA event list class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2016 by Juergen Knoedlseder * + * copyright (C) 2011-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -59,6 +59,7 @@ public: // Implement other methods void append(const GCTAEventAtom& event); + void append_column(const GFitsTableCol& column); void reserve(const int& number); void remove(const int& index, const int& number = 1); void write(GFits& fits, const std::string& evtname, diff --git a/inst/cta/src/GCTAEventList.cpp b/inst/cta/src/GCTAEventList.cpp index bef0241..e03633c 100644 --- a/inst/cta/src/GCTAEventList.cpp +++ b/inst/cta/src/GCTAEventList.cpp @@ -35,6 +35,7 @@ #include "GFits.hpp" #include "GFitsTable.hpp" #include "GFitsBinTable.hpp" +#include "GFitsTableCol.hpp" #include "GFitsTableFloatCol.hpp" #include "GFitsTableDoubleCol.hpp" #include "GFitsTableULongCol.hpp" @@ -46,6 +47,7 @@ /* __ Method name definitions ____________________________________________ */ #define G_OPERATOR "GCTAEventList::operator[](int&)" #define G_ROI "GCTAEventList::roi(GRoi&)" +#define G_APPEND_COLUMN "GCTAEventList::append_column(GFitsTableCol&)" #define G_FETCH "GCTAEventList::fetch()" /* __ Macros _____________________________________________________________ */ @@ -575,6 +577,44 @@ void GCTAEventList::append(const GCTAEventAtom& event) } + +/***********************************************************************//** + * @brief Append FITS table column to event list + * + * @param[in] column FITS table column to be appended. + * + * @exception GException::invalid_argument + * FITS column has incompatible length. + * + * Appends a FITS table column to the event list. The length of the FITS + * column must be identical to the number of events in the event list. + ***************************************************************************/ +void GCTAEventList::append_column(const GFitsTableCol& column) +{ + // Throw an exception if the column has an incompatible length + if (size() != column.length()) { + std::string msg = "Incompatible column length. Attempt to append a " + "column of length "+gammalib::str(column.length())+ + " to an event list with "+gammalib::str(size())+ + " events. Please specify a column of length "+ + gammalib::str(size())+"."; + throw GException::invalid_argument(G_APPEND_COLUMN, msg); + } + + // Make sure that the events are online + fetch(); + + // Clone the FITS column. De-allocation is done when the object is free'd + GFitsTableCol* ptr = column.clone(); + + // Append the column + m_columns.push_back(ptr); + + // Return + return; +} + + /***********************************************************************//** * @brief Remove events from event list *