Commit 79b33a66670528797c8ef6ff197974ebdaa3763f

Authored by Jürgen Knödlseder
1 parent 5a1f3f14

Include header.

inst/lat/test/binned_integration.py
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 - 2 +# ==========================================================================
  3 +# This script tests the binned integration.
  4 +#
  5 +# Requires:
  6 +# - matplotlib
  7 +# - numpy
  8 +#
  9 +# Copyright (C) 2012 Jurgen Knodlseder
  10 +#
  11 +# This program is free software: you can redistribute it and/or modify
  12 +# it under the terms of the GNU General Public License as published by
  13 +# the Free Software Foundation, either version 3 of the License, or
  14 +# (at your option) any later version.
  15 +#
  16 +# This program is distributed in the hope that it will be useful,
  17 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19 +# GNU General Public License for more details.
  20 +#
  21 +# You should have received a copy of the GNU General Public License
  22 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  23 +#
  24 +# ==========================================================================
3 from gammalib import * 25 from gammalib import *
4 from math import * 26 from math import *
5 import os 27 import os
@@ -222,19 +244,19 @@ if __name__ == &#39;__main__&#39;: @@ -222,19 +244,19 @@ if __name__ == &#39;__main__&#39;:
222 energy.append(ebds.elogmean(i).MeV()) 244 energy.append(ebds.elogmean(i).MeV())
223 245
224 # Perform integrations 246 # Perform integrations
225 - analytical = int_analytical(ebds, gamma)  
226 - trapezoid = int_trapezoid(ebds, gamma) 247 + analytical = int_analytical(ebds, gamma)
  248 + trapezoid = int_trapezoid(ebds, gamma)
227 log_trapezoid = int_log_trapezoid(ebds, gamma) 249 log_trapezoid = int_log_trapezoid(ebds, gamma)
228 - mean = int_mean(ebds, gamma)  
229 - logmean = int_logmean(ebds, gamma)  
230 - geometric = int_geometric(ebds, gamma) 250 + mean = int_mean(ebds, gamma)
  251 + logmean = int_logmean(ebds, gamma)
  252 + geometric = int_geometric(ebds, gamma)
231 253
232 # Compute differences 254 # Compute differences
233 - diff_trapezoid = [] 255 + diff_trapezoid = []
234 diff_log_trapezoid = [] 256 diff_log_trapezoid = []
235 - diff_mean = []  
236 - diff_logmean = []  
237 - diff_geometric = [] 257 + diff_mean = []
  258 + diff_logmean = []
  259 + diff_geometric = []
238 for i in range(ebds.size()): 260 for i in range(ebds.size()):
239 diff_trapezoid.append(trapezoid[i] / analytical[i]) 261 diff_trapezoid.append(trapezoid[i] / analytical[i])
240 diff_log_trapezoid.append(log_trapezoid[i] / analytical[i]) 262 diff_log_trapezoid.append(log_trapezoid[i] / analytical[i])