Commit deaf5e66fedcd3c5035056a93b12dbb6319fc7e5

Authored by knodlseder
1 parent fcd17707

add eflux() method

include/GModelSpectral.hpp
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2009-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -64,6 +72,7 @@ public:
64 72 virtual double eval(const GEnergy& srcEng) const = 0;
65 73 virtual double eval_gradients(const GEnergy& srcEng) const = 0;
66 74 virtual double flux(const GEnergy& emin, const GEnergy& emax) const = 0;
  75 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const = 0;
67 76 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const = 0;
68 77 virtual void read(const GXmlElement& xml) = 0;
69 78 virtual void write(GXmlElement& xml) const = 0;
... ...
include/GModelSpectralConst.hpp
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2009-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -57,6 +65,7 @@ public:
57 65 virtual double eval(const GEnergy& srcEng) const;
58 66 virtual double eval_gradients(const GEnergy& srcEng) const;
59 67 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  68 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
60 69 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
61 70 virtual void read(const GXmlElement& xml);
62 71 virtual void write(GXmlElement& xml) const;
... ...
include/GModelSpectralExpPlaw.hpp
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2010-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -61,6 +69,7 @@ public:
61 69 virtual double eval(const GEnergy& srcEng) const;
62 70 virtual double eval_gradients(const GEnergy& srcEng) const;
63 71 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  72 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
64 73 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
65 74 virtual void read(const GXmlElement& xml);
66 75 virtual void write(GXmlElement& xml) const;
... ...
include/GModelSpectralFunc.hpp
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2010-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -60,6 +68,7 @@ public:
60 68 virtual double eval(const GEnergy& srcEng) const;
61 69 virtual double eval_gradients(const GEnergy& srcEng) const;
62 70 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  71 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
63 72 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
64 73 virtual void read(const GXmlElement& xml);
65 74 virtual void write(GXmlElement& xml) const;
... ...
include/GModelSpectralPlaw.hpp
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2009-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -60,6 +68,7 @@ public:
60 68 virtual double eval(const GEnergy& srcEng) const;
61 69 virtual double eval_gradients(const GEnergy& srcEng) const;
62 70 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  71 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
63 72 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
64 73 virtual void read(const GXmlElement& xml);
65 74 virtual void write(GXmlElement& xml) const;
... ...
include/GModelSpectralPlaw2.hpp
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -64,6 +72,7 @@ public:
64 72 virtual double eval(const GEnergy& srcEng) const;
65 73 virtual double eval_gradients(const GEnergy& srcEng) const;
66 74 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  75 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
67 76 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
68 77 virtual void read(const GXmlElement& xml);
69 78 virtual void write(GXmlElement& xml) const;
... ...
pyext/GModelSpectral.i
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2009-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -41,6 +49,7 @@ public:
41 49 virtual double eval(const GEnergy& srcEng) const = 0;
42 50 virtual double eval_gradients(const GEnergy& srcEng) const = 0;
43 51 virtual double flux(const GEnergy& emin, const GEnergy& emax) const = 0;
  52 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const = 0;
44 53 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const = 0;
45 54 virtual void read(const GXmlElement& xml) = 0;
46 55 virtual void write(GXmlElement& xml) const = 0;
... ...
pyext/GModelSpectralConst.i
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -42,6 +50,7 @@ public:
42 50 virtual double eval(const GEnergy& srcEng) const;
43 51 virtual double eval_gradients(const GEnergy& srcEng) const;
44 52 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  53 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
45 54 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
46 55 virtual void read(const GXmlElement& xml);
47 56 virtual void write(GXmlElement& xml) const;
... ...
pyext/GModelSpectralExpPlaw.i
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2009-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -44,6 +52,7 @@ public:
44 52 virtual double eval(const GEnergy& srcEng) const;
45 53 virtual double eval_gradients(const GEnergy& srcEng) const;
46 54 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  55 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
47 56 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
48 57 virtual void read(const GXmlElement& xml);
49 58 virtual void write(GXmlElement& xml) const;
... ...
pyext/GModelSpectralFunc.i
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -43,6 +51,7 @@ public:
43 51 virtual double eval(const GEnergy& srcEng) const;
44 52 virtual double eval_gradients(const GEnergy& srcEng) const;
45 53 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  54 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
46 55 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
47 56 virtual void read(const GXmlElement& xml);
48 57 virtual void write(GXmlElement& xml) const;
... ...
pyext/GModelSpectralPlaw.i
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2009-2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -43,6 +51,7 @@ public:
43 51 virtual double eval(const GEnergy& srcEng) const;
44 52 virtual double eval_gradients(const GEnergy& srcEng) const;
45 53 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  54 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
46 55 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
47 56 virtual void read(const GXmlElement& xml);
48 57 virtual void write(GXmlElement& xml) const;
... ...
pyext/GModelSpectralPlaw2.i
... ... @@ -4,10 +4,18 @@
4 4 * copyright (C) 2011 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
  7 + * This program is free software: you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation, either version 3 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + * This program is distributed in the hope that it will be useful, *
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15 + * GNU General Public License for more details. *
  16 + * *
  17 + * You should have received a copy of the GNU General Public License *
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. *
11 19 * *
12 20 ***************************************************************************/
13 21 /**
... ... @@ -43,6 +51,7 @@ public:
43 51 virtual double eval(const GEnergy& srcEng) const;
44 52 virtual double eval_gradients(const GEnergy& srcEng) const;
45 53 virtual double flux(const GEnergy& emin, const GEnergy& emax) const;
  54 + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const;
46 55 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const;
47 56 virtual void read(const GXmlElement& xml);
48 57 virtual void write(GXmlElement& xml) const;
... ...
src/model/GModelSpectralConst.cpp
... ... @@ -246,7 +246,7 @@ double GModelSpectralConst::eval_gradients(const GEnergy&amp; srcEng) const
246 246  
247 247  
248 248 /***********************************************************************//**
249   - * @brief Returns model flux between [emin, emax] (units: ph/cm2/s)
  249 + * @brief Returns model photon flux between [emin, emax] (units: ph/cm2/s)
250 250 *
251 251 * @param[in] emin Minimum photon energy.
252 252 * @param[in] emax Maximum photon energy.
... ... @@ -257,6 +257,7 @@ double GModelSpectralConst::eval_gradients(const GEnergy&amp; srcEng) const
257 257 * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum
258 258 * energy, respectively, and
259 259 * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV).
  260 + * The integration is done analytically.
260 261 ***************************************************************************/
261 262 double GModelSpectralConst::flux(const GEnergy& emin, const GEnergy& emax) const
262 263 {
... ... @@ -269,6 +270,33 @@ double GModelSpectralConst::flux(const GEnergy&amp; emin, const GEnergy&amp; emax) const
269 270  
270 271  
271 272 /***********************************************************************//**
  273 + * @brief Returns model energy flux between [emin, emax] (units: erg/cm2/s)
  274 + *
  275 + * @param[in] emin Minimum photon energy.
  276 + * @param[in] emax Maximum photon energy.
  277 + *
  278 + * Computes
  279 + * \f[\int_{E_{\rm min}}^{E_{\rm max}} I(E) E dE\f]
  280 + * where
  281 + * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum
  282 + * energy, respectively, and
  283 + * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV).
  284 + * The integration is done analytically.
  285 + ***************************************************************************/
  286 +double GModelSpectralConst::eflux(const GEnergy& emin, const GEnergy& emax) const
  287 +{
  288 + // Compute flux for a constant model
  289 + double flux = norm() * 0.5 * (emax.MeV()*emax.MeV() - emin.MeV()*emin.MeV());
  290 +
  291 + // Convert from MeV/cm2/s to erg/cm2/s
  292 + flux *= MeV2erg;
  293 +
  294 + // Return
  295 + return flux;
  296 +}
  297 +
  298 +
  299 +/***********************************************************************//**
272 300 * @brief Returns MC energy between [emin, emax]
273 301 *
274 302 * @param[in] emin Minimum photon energy.
... ...
src/model/GModelSpectralPlaw.cpp
... ... @@ -326,7 +326,7 @@ double GModelSpectralPlaw::eval_gradients(const GEnergy&amp; srcEng) const
326 326  
327 327  
328 328 /***********************************************************************//**
329   - * @brief Returns model flux between [emin, emax] (units: ph/cm2/s)
  329 + * @brief Returns model photon flux between [emin, emax] (units: ph/cm2/s)
330 330 *
331 331 * @param[in] emin Minimum photon energy.
332 332 * @param[in] emax Maximum photon energy.
... ... @@ -337,6 +337,7 @@ double GModelSpectralPlaw::eval_gradients(const GEnergy&amp; srcEng) const
337 337 * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum
338 338 * energy, respectively, and
339 339 * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV).
  340 + * The integration is done analytically.
340 341 ***************************************************************************/
341 342 double GModelSpectralPlaw::flux(const GEnergy& emin, const GEnergy& emax) const
342 343 {
... ... @@ -356,6 +357,40 @@ double GModelSpectralPlaw::flux(const GEnergy&amp; emin, const GEnergy&amp; emax) const
356 357  
357 358  
358 359 /***********************************************************************//**
  360 + * @brief Returns model energy flux between [emin, emax] (units: erg/cm2/s)
  361 + *
  362 + * @param[in] emin Minimum photon energy.
  363 + * @param[in] emax Maximum photon energy.
  364 + *
  365 + * Computes
  366 + * \f[\int_{E_{\rm min}}^{E_{\rm max}} I(E) E dE\f]
  367 + * where
  368 + * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum
  369 + * energy, respectively, and
  370 + * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV).
  371 + * The integration is done analytically.
  372 + ***************************************************************************/
  373 +double GModelSpectralPlaw::eflux(const GEnergy& emin, const GEnergy& emax) const
  374 +{
  375 + // Compute flux
  376 + double flux = norm() * pow(pivot(), -index());
  377 + if (index() != -2.0) {
  378 + double exponent = index() + 2.0;
  379 + flux *= (std::pow(emax.MeV(), exponent)-std::pow(emin.MeV(), exponent)) /
  380 + exponent;
  381 + }
  382 + else
  383 + flux *= (std::log(emax.MeV()) - std::log(emin.MeV()));
  384 +
  385 + // Convert from MeV/cm2/s to erg/cm2/s
  386 + flux *= MeV2erg;
  387 +
  388 + // Return flux
  389 + return flux;
  390 +}
  391 +
  392 +
  393 +/***********************************************************************//**
359 394 * @brief Returns Monte Carlo energy between [emin, emax]
360 395 *
361 396 * @param[in] emin Minimum photon energy.
... ...