From 269acd3589bd249205f07219acbb130af737dd9b Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 5 Feb 2013 17:12:08 +0100 Subject: [PATCH] Implement handling of instrument specific scale factors. --- src/model/GModelSky.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/model/GModelSky.cpp b/src/model/GModelSky.cpp index ba51318..ad15281 100644 --- a/src/model/GModelSky.cpp +++ b/src/model/GModelSky.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSky.cpp - Abstract sky model base class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2012 by Juergen Knoedlseder * + * copyright (C) 2011-2013 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -428,6 +428,9 @@ void GModelSky::read(const GXmlElement& xml) // Set instruments instruments(xml.attribute("instrument")); + // Read instrument scales + read_scales(xml); + // Set observation identifiers ids(xml.attribute("id")); @@ -465,7 +468,7 @@ void GModelSky::write(GXmlElement& xml) const src->attribute("name") = name(); if (spectral() != NULL) src->append(new GXmlElement("spectrum")); if (spatial() != NULL) src->append(new GXmlElement("spatialModel")); - xml.append(src); + xml.append(src); // Appends pointer } // Set model attributes @@ -488,6 +491,9 @@ void GModelSky::write(GXmlElement& xml) const spatial()->write(*spat); } + // Write instrument scales + write_scales(*src); + // Return return; } @@ -815,6 +821,11 @@ GModelTemporal* GModelSky::xml_temporal(const GXmlElement& temporal) const * * This method computes the spatial model component for a given true photon * energy and arrival time. + * + * The method takes care of any instrument dependent scale factors. These + * scale factors will be applied to the IRF so that they are correctly + * taken into account in the spectral and temporal model gradient + * computations. ***************************************************************************/ double GModelSky::spatial(const GEvent& event, const GEnergy& srcEng, const GTime& srcTime, @@ -839,6 +850,11 @@ double GModelSky::spatial(const GEvent& event, // source model. double irf = rsp->irf(event, source, obs); + // If required, apply instrument specific model scaling + if (!m_scales.empty()) { + irf *= scale(obs.instrument()).real_value(); + } + // Case A: evaluate gradients if (grad) { -- libgit2 0.21.4