Commit 269acd3589bd249205f07219acbb130af737dd9b
1 parent
d61e970c
Implement handling of instrument specific scale factors.
The read() and write() methods now handle the reading and writing of instrument specific model scale factors. The spatial() method uses the scale factors to scale the IRF accordingly, if required.
Showing
1 changed file
with
18 additions
and
2 deletions
src/model/GModelSky.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSky.cpp - Abstract sky model base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -428,6 +428,9 @@ void GModelSky::read(const GXmlElement& xml) |
| 428 | 428 | // Set instruments |
| 429 | 429 | instruments(xml.attribute("instrument")); |
| 430 | 430 | |
| 431 | + // Read instrument scales | |
| 432 | + read_scales(xml); | |
| 433 | + | |
| 431 | 434 | // Set observation identifiers |
| 432 | 435 | ids(xml.attribute("id")); |
| 433 | 436 | |
| ... | ... | @@ -465,7 +468,7 @@ void GModelSky::write(GXmlElement& xml) const |
| 465 | 468 | src->attribute("name") = name(); |
| 466 | 469 | if (spectral() != NULL) src->append(new GXmlElement("spectrum")); |
| 467 | 470 | if (spatial() != NULL) src->append(new GXmlElement("spatialModel")); |
| 468 | - xml.append(src); | |
| 471 | + xml.append(src); // Appends pointer | |
| 469 | 472 | } |
| 470 | 473 | |
| 471 | 474 | // Set model attributes |
| ... | ... | @@ -488,6 +491,9 @@ void GModelSky::write(GXmlElement& xml) const |
| 488 | 491 | spatial()->write(*spat); |
| 489 | 492 | } |
| 490 | 493 | |
| 494 | + // Write instrument scales | |
| 495 | + write_scales(*src); | |
| 496 | + | |
| 491 | 497 | // Return |
| 492 | 498 | return; |
| 493 | 499 | } |
| ... | ... | @@ -815,6 +821,11 @@ GModelTemporal* GModelSky::xml_temporal(const GXmlElement& temporal) const |
| 815 | 821 | * |
| 816 | 822 | * This method computes the spatial model component for a given true photon |
| 817 | 823 | * energy and arrival time. |
| 824 | + * | |
| 825 | + * The method takes care of any instrument dependent scale factors. These | |
| 826 | + * scale factors will be applied to the IRF so that they are correctly | |
| 827 | + * taken into account in the spectral and temporal model gradient | |
| 828 | + * computations. | |
| 818 | 829 | ***************************************************************************/ |
| 819 | 830 | double GModelSky::spatial(const GEvent& event, |
| 820 | 831 | const GEnergy& srcEng, const GTime& srcTime, |
| ... | ... | @@ -839,6 +850,11 @@ double GModelSky::spatial(const GEvent& event, |
| 839 | 850 | // source model. |
| 840 | 851 | double irf = rsp->irf(event, source, obs); |
| 841 | 852 | |
| 853 | + // If required, apply instrument specific model scaling | |
| 854 | + if (!m_scales.empty()) { | |
| 855 | + irf *= scale(obs.instrument()).real_value(); | |
| 856 | + } | |
| 857 | + | |
| 842 | 858 | // Case A: evaluate gradients |
| 843 | 859 | if (grad) { |
| 844 | 860 | ... | ... |