From 11742474402a9654792bbefcef17cc68ab302be8 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 20 Nov 2013 12:25:31 +0100 Subject: [PATCH] Code revision before merging and updated ctbin version number and change information. --- AUTHORS | 2 +- ChangeLog | 3 ++- NEWS | 9 +++++++-- src/ctbin/ctbin.cpp | 35 ++++++++++++++++++++--------------- src/ctbin/ctbin.hpp | 6 +++--- src/ctbin/ctbin.par | 2 +- test/test_ctools.sh | 2 ++ 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/AUTHORS b/AUTHORS index b1c349e..72430a1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu) Jean-Baptiste Cayrou (cayrou@etud.insa-toulouse.fr) Christoph Deil (Christoph.Deil@mpi-hd.mpg.de) - +Michael Mayer (michael.mayer@desy.de) diff --git a/ChangeLog b/ChangeLog index 07cf961..5d72abb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2013-11-19 Juergen Knoedlseder +2013-11-20 Juergen Knoedlseder * Version 0.7.0 released ======================== @@ -6,6 +6,7 @@ Adapt to GammaLib-00-08-00 interface ctobssim now only simulates events within ROI and supports all kinds of data space models + ctbin now implements LIN and FILE binning algorithms 2012-12-21 Juergen Knoedlseder diff --git a/NEWS b/NEWS index 0f1e26a..599027b 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-07-00 Author(s) : Juergen Knoedlseder -19 November 2013 +20 November 2013 1. Introduction @@ -45,7 +45,12 @@ None 6. ctbin - CTA event binning ---------------------------- -None +The ebinalg parameter is now used to specify the type of binning. +Linear (LIN) binning and binning retrieved from a FITS file (FILE) +is now supported. For the latter, an extension named EBOUNDS or +ENERGYBINS is expected. + +The ebinalg and ebinfile parameters are now automatic. 7. ctlike - CTA maximum likelihood fitting diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index f779ad0..b66891f 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -434,14 +434,12 @@ void ctbin::get_parameters(void) } m_ebinalg = (*this)["ebinalg"].string(); - // if we have the binning given by a file - // read in filename next - if (m_ebinalg=="FILE") { - - // get binning filename + // If we have the binning given by a file then read filename + if (m_ebinalg == "FILE") { m_ebinfile = (*this)["ebinfile"].filename(); } - // otherwise read emin, emax and nebins + + // ... otherwise read emin, emax and nebins else{ m_emin = (*this)["emin"].real(); m_emax = (*this)["emax"].real(); @@ -500,9 +498,9 @@ void ctbin::bin_events(GCTAObservation* obs) // First check wether we have FITS-file defining // the binning - if (m_ebinalg=="FILE") { + if (m_ebinalg == "FILE") { - // open fits file to check which extension is given + // Open fits file to check which extension is given GFits file(m_ebinfile); if (file.hashdu("EBOUNDS")) { @@ -523,17 +521,24 @@ void ctbin::bin_events(GCTAObservation* obs) else { + // Close file file.close(); - // throw an exception todo: get the right status - int status=0; - throw GException::fits_hdu_not_found(G_BIN_EVENTS, "\'EBOUNDS\' or \'ENERGYBINS\'", status); - - } // endelse: no suited extension + + // Signal that no energy boundaries have been found + std::string msg = "No extension with name \"EBOUNDS\" or" + " \"ENERGYBINS\" found in FITS file" + " \""+m_ebinfile+"\".\n" + "An \"EBOUNDS\" or \"ENERGYBINS\" extension" + " is required if the parameter \"ebinalg\"" + " is set to \"FILE\"."; + throw GException::invalid_value(G_BIN_EVENTS, msg); + + } // endelse: no suited extension found // Set enumbins parameter to number of ebounds m_enumbins = ebds.size(); - } //endif: ebinalg was "FILE" + } // endif: ebinalg was "FILE" else { @@ -713,7 +718,7 @@ void ctbin::copy_members(const ctbin& app) m_prefix = app.m_prefix; m_proj = app.m_proj; m_coordsys = app.m_coordsys; - m_ebinalg = app.m_ebinalg; + m_ebinalg = app.m_ebinalg; m_ebinfile = app.m_ebinfile; m_usepnt = app.m_usepnt; m_emin = app.m_emin; diff --git a/src/ctbin/ctbin.hpp b/src/ctbin/ctbin.hpp index 4328394..79eb3f7 100644 --- a/src/ctbin/ctbin.hpp +++ b/src/ctbin/ctbin.hpp @@ -33,7 +33,7 @@ /* __Definitions _________________________________________________________ */ #define CTBIN_NAME "ctbin" -#define CTBIN_VERSION "00-04-00" +#define CTBIN_VERSION "00-05-00" /***********************************************************************//** @@ -89,8 +89,8 @@ protected: int m_enumbins; //!< Number of energy bins std::string m_proj; //!< WCS projection std::string m_coordsys; //!< Coordinate system - std::string m_ebinalg; //!< Algorithm for energy binning - std::string m_ebinfile; //!< FITS-file containing energy binning + std::string m_ebinalg; //!< Algorithm for energy binning + std::string m_ebinfile; //!< FITS-file containing energy binning double m_xref; //!< Longitude reference coordinate double m_yref; //!< Latitude reference coordinate double m_binsz; //!< Pixel size diff --git a/src/ctbin/ctbin.par b/src/ctbin/ctbin.par index c941869..af2e156 100644 --- a/src/ctbin/ctbin.par +++ b/src/ctbin/ctbin.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctbin.par # -# Version: 00-04-00 # +# Version: 00-05-00 # # # # Author: Jurgen Knodlseder # # Jurgen.Knodlseder@irap.omp.eu # diff --git a/test/test_ctools.sh b/test/test_ctools.sh index d2805cc..7b5076b 100755 --- a/test/test_ctools.sh +++ b/test/test_ctools.sh @@ -143,6 +143,7 @@ $ctbin evfile="events.fits" \ emin=0.1 \ emax=100.0 \ enumbins=20 \ + ebinalg="LOG" \ nxpix=200 \ nypix=200 \ binsz=0.02 \ @@ -165,6 +166,7 @@ $ctbin evfile="events2.fits" \ emin=0.3 \ emax=8.0 \ enumbins=10 \ + ebinalg="LOG" \ nxpix=50 \ nypix=50 \ binsz=0.02 \ -- libgit2 0.21.4