Commit 9eabfd897a4a58420504d4d901646e20871fe866
1 parent
a79dc16b
Add GModels::eval() vector evaluation method (#3455)
Showing
7 changed files
with
57 additions
and
7 deletions
ChangeLog
| 1 | -2020-11-18 | |
| 1 | +2020-11-21 | |
| 2 | 2 | |
| 3 | 3 | * Version 2.0.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Add GModels::eval() vector evaluation method (#3455) | |
| 6 | 7 | Fix GSkyMap::stack_maps() method for WCS maps |
| 7 | 8 | Add GCTAModelSkyCube class (#3442) |
| 8 | 9 | Add GSkyModel flux() and eflux() methods (#3439) | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in GammaLib 2.0.0 |
| 2 | 2 | |
| 3 | -18 November 2020 | |
| 3 | +21 November 2020 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | 1. Introduction |
| ... | ... | @@ -25,12 +25,14 @@ The following classes have been renamed: |
| 25 | 25 | - none |
| 26 | 26 | |
| 27 | 27 | The following methods have been added: |
| 28 | -- GModel::eval(GObservation&, GMatrixSparse*) | |
| 29 | -- GModelSky::eval(GObservation&, GMatrixSparse*) | |
| 30 | 28 | - GResponse::convolve(GModelSky&, GObservation&, GMatrixSparse*) |
| 31 | 29 | - GResponse::irf_spatial(GModelSky&, GObservation&, GMatrix*) |
| 32 | 30 | - GObservation::model(GModels&, GMatrixSparse*) |
| 33 | 31 | - GObservation::model_grad(GModel&, GModelPar&) |
| 32 | +- GModels::eval(GObservation&, GMatrixSparse*) | |
| 33 | +- GModel::eval(GObservation&, GMatrixSparse*) | |
| 34 | +- GModelSky::eval(GObservation&, GMatrixSparse*) | |
| 35 | +- GModelData::eval(GObservation&, GMatrixSparse*) | |
| 34 | 36 | - GModelSky::flux(GEnergy&, GEnergy&) |
| 35 | 37 | - GModelSky::flux(GSkyRegion&, GEnergy&, GEnergy&) |
| 36 | 38 | - GModelSky::eflux(GEnergy&, GEnergy&) |
| ... | ... | @@ -59,9 +61,9 @@ The following methods have been renamed: |
| 59 | 61 | - none |
| 60 | 62 | |
| 61 | 63 | The arguments for the following methods have been changed: |
| 62 | -- GCOMObservation::drm(GSkyModel&) was GCOMObservation::drm(GSource&) | |
| 63 | 64 | - GModelSpatial::flux(GSkyRegion&, GEnergy&, GTime&) was |
| 64 | 65 | GModelSpatial::flux(GSkyRegion*, GEnergy&, GTime&) |
| 66 | +- GCOMObservation::drm(GSkyModel&) was GCOMObservation::drm(GSource&) | |
| 65 | 67 | |
| 66 | 68 | The return value of the following methods has been changed: |
| 67 | 69 | - none |
| ... | ... | @@ -96,6 +98,9 @@ Implemented GMatrixSparse::row() and GMatrixSparse::add_to_row() methods. |
| 96 | 98 | |
| 97 | 99 | 8. Model module |
| 98 | 100 | --------------- |
| 101 | +Added GModels::eval() vector evaluation method to compute the model values for | |
| 102 | +all events within a given observation (#3455). | |
| 103 | + | |
| 99 | 104 | Added methods to GSkyModel to compute the photon flux and energy flux as |
| 100 | 105 | well as their errors (#3439, #3074). |
| 101 | 106 | ... | ... |
README.md
| 1 | 1 | GammaLib information |
| 2 | 2 | ==================== |
| 3 | -* Version: 2.0.0.dev (18 November 2020) | |
| 3 | +* Version: 2.0.0.dev (21 November 2020) | |
| 4 | 4 | |
| 5 | 5 | [](https://cta-jenkins.irap.omp.eu/job/gammalib-integrate-os/) |
| 6 | 6 | ... | ... |
doc/source/admin/release_history/2.0.rst
| 1 | 1 | .. _2.0: |
| 2 | 2 | |
| 3 | -GammaLib 2.0 release (18 November 2020) | |
| 3 | +GammaLib 2.0 release (21 November 2020) | |
| 4 | 4 | ======================================= |
| 5 | 5 | |
| 6 | 6 | Overview |
| ... | ... | @@ -40,6 +40,8 @@ Improvements |
| 40 | 40 | New features |
| 41 | 41 | ------------ |
| 42 | 42 | |
| 43 | +* [`3455 <https://cta-redmine.irap.omp.eu/issues/3455>`_] - | |
| 44 | + Add ``GModels::eval()`` vector evaluation method | |
| 43 | 45 | * [`3442 <https://cta-redmine.irap.omp.eu/issues/3442>`_] - |
| 44 | 46 | Add ``GCTAModelSkyCube`` class |
| 45 | 47 | * [`3439 <https://cta-redmine.irap.omp.eu/issues/3439>`_] - | ... | ... |
include/GModels.hpp
| ... | ... | @@ -36,6 +36,8 @@ class GEvent; |
| 36 | 36 | class GObservation; |
| 37 | 37 | class GModel; |
| 38 | 38 | class GFilename; |
| 39 | +class GVector; | |
| 40 | +class GMatrixSparse; | |
| 39 | 41 | class GOptimizerPars; |
| 40 | 42 | class GXml; |
| 41 | 43 | |
| ... | ... | @@ -190,6 +192,8 @@ public: |
| 190 | 192 | double eval(const GEvent& event, |
| 191 | 193 | const GObservation& obs, |
| 192 | 194 | const bool& gradients = false) const; |
| 195 | + GVector eval(const GObservation& obs, | |
| 196 | + GMatrixSparse* gradients = NULL) const; | |
| 193 | 197 | std::string print(const GChatter& chatter = NORMAL) const; |
| 194 | 198 | |
| 195 | 199 | protected: | ... | ... |
pyext/GModels.i
src/model/GModels.cpp
| ... | ... | @@ -35,6 +35,8 @@ |
| 35 | 35 | #include "GModel.hpp" |
| 36 | 36 | #include "GModelRegistry.hpp" |
| 37 | 37 | #include "GObservation.hpp" |
| 38 | +#include "GVector.hpp" | |
| 39 | +#include "GMatrixSparse.hpp" | |
| 38 | 40 | #include "GXml.hpp" |
| 39 | 41 | #include "GXmlElement.hpp" |
| 40 | 42 | #include "GOptimizerPars.hpp" |
| ... | ... | @@ -909,6 +911,40 @@ double GModels::eval(const GEvent& event, |
| 909 | 911 | |
| 910 | 912 | |
| 911 | 913 | /***********************************************************************//** |
| 914 | + * @brief Evaluate sum vector of all models | |
| 915 | + * | |
| 916 | + * @param[in] obs Observation. | |
| 917 | + * @param[in] gradients Pointer to gradients matrix. | |
| 918 | + * @return Vector of model values. | |
| 919 | + * | |
| 920 | + * Evaluates the sum vector of all models for all events in the observation. | |
| 921 | + * Only valid models are considered in this evaluation. | |
| 922 | + * | |
| 923 | + * If the @p gradients pointer is not NULL the method will fill the | |
| 924 | + * corresponding matrix with the parameter gradients of the model. | |
| 925 | + ***************************************************************************/ | |
| 926 | +GVector GModels::eval(const GObservation& obs, | |
| 927 | + GMatrixSparse* gradients) const | |
| 928 | +{ | |
| 929 | + // Get number of events | |
| 930 | + int nevents = obs.events()->size(); | |
| 931 | + | |
| 932 | + // Initialise model sum | |
| 933 | + GVector values(nevents); | |
| 934 | + | |
| 935 | + // Evaluate function for all models | |
| 936 | + for (int i = 0; i < size(); ++i) { | |
| 937 | + if (m_models[i]->is_valid(obs.instrument(), obs.id())) { | |
| 938 | + values += m_models[i]->eval(obs, gradients); | |
| 939 | + } | |
| 940 | + } | |
| 941 | + | |
| 942 | + // Return model values | |
| 943 | + return values; | |
| 944 | +} | |
| 945 | + | |
| 946 | + | |
| 947 | +/***********************************************************************//** | |
| 912 | 948 | * @brief Print models |
| 913 | 949 | * |
| 914 | 950 | * @param[in] chatter Chattiness. | ... | ... |