Commit 983ca4e8641f5f10a2cf2e4653b122e1115375a0
1 parent
9a6f8e70
Add LAT event filename constructors.
Showing
7 changed files
with
56 additions
and
4 deletions
inst/lat/include/GLATEventCube.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLATEventCube.hpp - Fermi/LAT event cube class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -52,6 +52,7 @@ class GLATEventCube : public GEventCube { |
| 52 | 52 | public: |
| 53 | 53 | // Constructors and destructors |
| 54 | 54 | GLATEventCube(void); |
| 55 | + explicit GLATEventCube(const std::string& filename); | |
| 55 | 56 | GLATEventCube(const GLATEventCube& cube); |
| 56 | 57 | virtual ~GLATEventCube(void); |
| 57 | 58 | ... | ... |
inst/lat/include/GLATEventList.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLATEventList.hpp - Fermi/LAT event list class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -48,6 +48,7 @@ class GLATEventList : public GEventList { |
| 48 | 48 | public: |
| 49 | 49 | // Constructors and destructors |
| 50 | 50 | GLATEventList(void); |
| 51 | + explicit GLATEventList(const std::string& filename); | |
| 51 | 52 | GLATEventList(const GLATEventList& list); |
| 52 | 53 | virtual ~GLATEventList(void); |
| 53 | 54 | ... | ... |
inst/lat/pyext/GLATEventCube.i
| ... | ... | @@ -39,6 +39,7 @@ class GLATEventCube : public GEventCube { |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GLATEventCube(void); |
| 42 | + explicit GLATEventCube(const std::string& filename); | |
| 42 | 43 | GLATEventCube(const GLATEventCube& cube); |
| 43 | 44 | virtual ~GLATEventCube(void); |
| 44 | 45 | ... | ... |
inst/lat/pyext/GLATEventList.i
| ... | ... | @@ -39,6 +39,7 @@ class GLATEventList : public GEventList { |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GLATEventList(void); |
| 42 | + explicit GLATEventList(const std::string& filename); | |
| 42 | 43 | GLATEventList(const GLATEventList& list); |
| 43 | 44 | virtual ~GLATEventList(void); |
| 44 | 45 | ... | ... |
inst/lat/src/GLATEventCube.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLATEventCube.cpp - Fermi/LAT event cube class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -71,6 +71,26 @@ GLATEventCube::GLATEventCube(void) : GEventCube() |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | /***********************************************************************//** |
| 74 | + * @brief File name constructor | |
| 75 | + * | |
| 76 | + * @param[in] filename Counts cube filename. | |
| 77 | + * | |
| 78 | + * Construct event cube object by loading the events from a FITS file. | |
| 79 | + ***************************************************************************/ | |
| 80 | +GLATEventCube::GLATEventCube(const std::string& filename) : GEventCube() | |
| 81 | +{ | |
| 82 | + // Initialise members | |
| 83 | + init_members(); | |
| 84 | + | |
| 85 | + // Load counts cube | |
| 86 | + load(filename); | |
| 87 | + | |
| 88 | + // Return | |
| 89 | + return; | |
| 90 | +} | |
| 91 | + | |
| 92 | + | |
| 93 | +/***********************************************************************//** | |
| 74 | 94 | * @brief Copy constructor |
| 75 | 95 | * |
| 76 | 96 | * @param[in] cube LAT event cube. | ... | ... |
inst/lat/src/GLATEventList.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLATEventList.cpp - Fermi/LAT event list class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,6 +70,26 @@ GLATEventList::GLATEventList(void) : GEventList() |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | /***********************************************************************//** |
| 73 | + * @brief File name constructor | |
| 74 | + * | |
| 75 | + * @param[in] filename Counts cube filename. | |
| 76 | + * | |
| 77 | + * Construct event list object by loading the events from a FITS file. | |
| 78 | + ***************************************************************************/ | |
| 79 | +GLATEventList::GLATEventList(const std::string& filename) : GEventList() | |
| 80 | +{ | |
| 81 | + // Initialise members | |
| 82 | + init_members(); | |
| 83 | + | |
| 84 | + // Load event list | |
| 85 | + load(filename); | |
| 86 | + | |
| 87 | + // Return | |
| 88 | + return; | |
| 89 | +} | |
| 90 | + | |
| 91 | + | |
| 92 | +/***********************************************************************//** | |
| 73 | 93 | * @brief Copy constructor |
| 74 | 94 | * |
| 75 | 95 | * @param[in] list LAT event list. | ... | ... |
inst/lat/test/test_LAT.cpp
| ... | ... | @@ -453,6 +453,10 @@ void TestGLATObservation::test_one_unbinned_obs(const std::string& datadir) |
| 453 | 453 | int nevents = ft1.table("EVENTS")->nrows(); |
| 454 | 454 | ft1.close(); |
| 455 | 455 | |
| 456 | + // Try loading event list | |
| 457 | + GLATEventList list(lat_ft1); | |
| 458 | + test_value(list.number(), nevents, "Test number of events in list."); | |
| 459 | + | |
| 456 | 460 | // Load unbinned LAT observation |
| 457 | 461 | test_try("Load unbinned LAT observation"); |
| 458 | 462 | try { |
| ... | ... | @@ -534,6 +538,10 @@ void TestGLATObservation::test_one_binned_obs(const std::string& datadir, const |
| 534 | 538 | } |
| 535 | 539 | cntmap.close(); |
| 536 | 540 | |
| 541 | + // Try loading event list | |
| 542 | + GLATEventCube cube(lat_cntmap); | |
| 543 | + test_value(cube.number(), nevents, "Test number of events in cube."); | |
| 544 | + | |
| 537 | 545 | // Load LAT binned observation from counts map |
| 538 | 546 | test_try("Load LAT binned observation"); |
| 539 | 547 | try { | ... | ... |