diff --git a/ChangeLog b/ChangeLog
index 2974224..f55c1b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,7 +6,7 @@
Support energy dispersion in ctobssim, ctlike and ctmodel
-2014-01-30 Juergen Knoedlseder
+2014-02-05 Juergen Knoedlseder
* Bug fix Version 0.7.1 released
================================
diff --git a/NEWS b/NEWS
index a4d8286..cf3c5c1 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-08-00
Author(s) : Juergen Knoedlseder
-1 February 2014
+5 February 2014
1. Introduction
diff --git a/README b/README
index 7490233..ea2bc23 100644
--- a/README
+++ b/README
@@ -1,8 +1,8 @@
ctools information
==================
-Version: 00-07-00 (18 January 2014)
+Version: 00-07-01 (5 February 2014)
Author: Juergen Knodlseder (jurgen.knodlseder@irap.omp.eu)
-GammaLib dependency: 00-08-00
+GammaLib dependency: 00-08-01
License information
diff --git a/doc/source/_templates/download.html b/doc/source/_templates/download.html
index dc69d40..3dfc919 100644
--- a/doc/source/_templates/download.html
+++ b/doc/source/_templates/download.html
@@ -29,6 +29,11 @@ ctools and gammalib. {%endtrans%}
Mac OS X package |
+| 00-07-01 |
+00-08-01 |
+ctools-00-07-01-macosx10.3.dmg |
+
+
| 00-07-00 |
00-08-00 |
ctools-00-07-00-macosx10.3.dmg |
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 9739d8a..c7c62bd 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -51,7 +51,7 @@ copyright = u'2014, ctools developers'
version = '0.7'
# The full version, including alpha/beta/rc tags.
-release = '0.7'
+release = '0.7.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/source/user_manual/getting.rst b/doc/source/user_manual/getting.rst
index f0d1a81..2a2507e 100644
--- a/doc/source/user_manual/getting.rst
+++ b/doc/source/user_manual/getting.rst
@@ -265,16 +265,12 @@ can be given, for example:
Setting up the ctools environment
---------------------------------
-If you installed ctools in the same directory as GammaLib (which
-is the default) you are done.
-
-If you decided to install ctools in a different directory, you have to
-configure ctools by setting up some environment variables. This will be
-done automatically by an initialisation script that is found in the ``bin``
-directory of the directory into which ctools has been installed. Assuming
-that you have installed ctools into ``/usr/local/ctools`` you need to add
-the following to your ``$HOME/.bashrc`` or ``$HOME/.profile`` script on a
-Linux machine:
+You have to configure ctools by setting up some environment variables. This
+will be done automatically by an initialisation script that is found in the
+``bin`` directory of the directory into which ctools has been installed.
+Assuming that you have installed ctools into ``/usr/local/ctools`` you need
+to add the following to your ``$HOME/.bashrc`` or ``$HOME/.profile`` script
+on a Linux machine:
.. code-block:: bash
diff --git a/test/example_survey.py b/test/example_survey.py
index b66eff2..9eafce9 100755
--- a/test/example_survey.py
+++ b/test/example_survey.py
@@ -3,7 +3,7 @@
# This script simulates CTA surveys. It can be considered as the master
# script for CTA science simulations. Please modify as needed.
#
-# Copyright (C) 2011-2013 Juergen Knoedlseder
+# Copyright (C) 2011-2014 Juergen Knoedlseder
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -32,331 +32,331 @@ import obsutils
# Plot counts #
# =========== #
def plot_counts(obs):
- """
- Plot counts.
- """
- # Only proceed if matplotlib is available
- try:
- # Import matplotlib
- import matplotlib.pyplot as plt
-
- # Set legend fontsize
- params = {'legend.fontsize': 10}
- plt.rcParams.update(params)
-
- # Set plot styles
- styles = ['b-', 'g-', 'y-', 'n-']
-
- # Dump header
- print("")
- print("Make plots (using matplotlib):")
- print("==============================")
-
- # Create figure 1
- plt.figure(1,figsize=(12,6))
- plt.subplots_adjust(hspace=.7)
-
- # Create subplot 1
- plt.subplot(121)
- plt.title("Spectrum (summed over all pixels)")
-
- # Loop over observations
- for run in obs:
-
- # Get event list
- list = run.events()
-
- # Create energy axis
- ebounds = GEbounds()
- emin = GEnergy()
- emax = GEnergy()
- emin.TeV(0.1)
- emax.TeV(100.0)
- ebounds.setlog(emin, emax, 10)
- energy = [ebounds.elogmean(i).TeV() for i in range(ebounds.size())]
-
- # Create spectrum
- print("Extract data:")
- counts = [0.0 for i in range(ebounds.size())]
- print(list.size())
- for atom in list:
- index = ebounds.index(atom.energy())
- counts[index] = counts[index] + 1.0
-
- # Create error bars
- error = [sqrt(c) for c in counts]
-
- # Plot spectrum
- plt.loglog(energy, counts, 'ro', label='data')
- #plt.errorbar(energy, counts, error, fmt=None, ecolor='r')
-
- # Extract models
- print("Extract models:")
- sum_model = [0.0 for i in range(ebounds.size())]
- for k, m in enumerate(obs.models()):
- print("- "+m.name())
- model = [0.0 for i in range(ebounds.size())]
- for atom in list:
- index = ebounds.index(atom.energy())
- prob = m.eval(atom, run)
- model[index] = model[index] + prob * atom.size()
- for i in range(ebounds.size()):
- sum_model[i] = sum_model[i] + model[i]
- #plt.loglog(energy, model, styles[k], label=m.name())
- #plt.loglog(energy, sum_model, 'r-', label='total')
-
- # Put labels
- plt.xlabel("Energy (TeV)")
- plt.ylabel("Counts")
- plt.legend(loc="lower left")
-
- # Create subplot 2
- plt.subplot(122)
- plt.title("Offset (summed over all energies)")
-
- # Set Crab direction
- crab = GSkyDir()
- crab.radec_deg(83.63, 22.01)
-
- # Loop over observations
- for run in obs:
-
- # Get event list
- list = run.events()
-
- # Create offset histogram
- print("Extract data:")
- nx = 30
- doffset2 = 0.01
- offset2 = [(i+0.5)*doffset2 for i in range(nx)]
- counts = [0.0 for i in range(nx)]
- for atom in list:
- off = atom.dir().dist_deg(crab)
- off2 = off*off
- index = int(off2/doffset2)
- if index < nx:
- counts[index] = counts[index] + 1.0
-
- # Create error bars
- error = [sqrt(c) for c in counts]
-
- # Plot distribution
- #plt.semilogy(offset2, counts, 'ro', label='data')
-
- # Extract models
- print("Extract models:")
- sum_model = [0.0 for i in range(nx)]
- for k, m in enumerate(obs.models()):
- print("- "+m.name())
- model = [0.0 for i in range(nx)]
- for atom in list:
- off = atom.dir().dist_deg(crab)
- off2 = off*off
- index = int(off2/doffset2)
- if index < nx:
- prob = m.eval(atom, run)
- model[index] = model[index] + prob * atom.size()
- for i in range(nx):
- sum_model[i] = sum_model[i] + model[i]
- #plt.plot(offset2, model, styles[k], label=m.name())
- #plt.plot(offset2, sum_model, 'r-', label='total')
- #plt.ylim(ymin=0.1)
-
- # Put labels
- plt.xlabel("Offset (deg^2)")
- plt.ylabel("Counts")
- #plt.legend(loc="upper right")
-
- # Show counts spectra
- plt.show()
-
- except ImportError:
- print("Matplotlib is not (correctly) installed on your system.")
+ """
+ Plot counts.
+ """
+ # Only proceed if matplotlib is available
+ try:
+ # Import matplotlib
+ import matplotlib.pyplot as plt
+
+ # Set legend fontsize
+ params = {'legend.fontsize': 10}
+ plt.rcParams.update(params)
+
+ # Set plot styles
+ styles = ['b-', 'g-', 'y-', 'n-']
+
+ # Dump header
+ print("")
+ print("Make plots (using matplotlib):")
+ print("==============================")
+
+ # Create figure 1
+ plt.figure(1,figsize=(12,6))
+ plt.subplots_adjust(hspace=.7)
+
+ # Create subplot 1
+ plt.subplot(121)
+ plt.title("Spectrum (summed over all pixels)")
+
+ # Loop over observations
+ for run in obs:
+
+ # Get event list
+ list = run.events()
+
+ # Create energy axis
+ ebounds = GEbounds()
+ emin = GEnergy()
+ emax = GEnergy()
+ emin.TeV(0.1)
+ emax.TeV(100.0)
+ ebounds.setlog(emin, emax, 10)
+ energy = [ebounds.elogmean(i).TeV() for i in range(ebounds.size())]
+
+ # Create spectrum
+ print("Extract data:")
+ counts = [0.0 for i in range(ebounds.size())]
+ print(list.size())
+ for atom in list:
+ index = ebounds.index(atom.energy())
+ counts[index] = counts[index] + 1.0
+
+ # Create error bars
+ error = [sqrt(c) for c in counts]
+
+ # Plot spectrum
+ plt.loglog(energy, counts, 'ro', label='data')
+ #plt.errorbar(energy, counts, error, fmt=None, ecolor='r')
+
+ # Extract models
+ print("Extract models:")
+ sum_model = [0.0 for i in range(ebounds.size())]
+ for k, m in enumerate(obs.models()):
+ print("- "+m.name())
+ model = [0.0 for i in range(ebounds.size())]
+ for atom in list:
+ index = ebounds.index(atom.energy())
+ prob = m.eval(atom, run)
+ model[index] = model[index] + prob * atom.size()
+ for i in range(ebounds.size()):
+ sum_model[i] = sum_model[i] + model[i]
+ #plt.loglog(energy, model, styles[k], label=m.name())
+ #plt.loglog(energy, sum_model, 'r-', label='total')
+
+ # Put labels
+ plt.xlabel("Energy (TeV)")
+ plt.ylabel("Counts")
+ plt.legend(loc="lower left")
+
+ # Create subplot 2
+ plt.subplot(122)
+ plt.title("Offset (summed over all energies)")
+
+ # Set Crab direction
+ crab = GSkyDir()
+ crab.radec_deg(83.63, 22.01)
+
+ # Loop over observations
+ for run in obs:
+
+ # Get event list
+ list = run.events()
+
+ # Create offset histogram
+ print("Extract data:")
+ nx = 30
+ doffset2 = 0.01
+ offset2 = [(i+0.5)*doffset2 for i in range(nx)]
+ counts = [0.0 for i in range(nx)]
+ for atom in list:
+ off = atom.dir().dist_deg(crab)
+ off2 = off*off
+ index = int(off2/doffset2)
+ if index < nx:
+ counts[index] = counts[index] + 1.0
+
+ # Create error bars
+ error = [sqrt(c) for c in counts]
+
+ # Plot distribution
+ #plt.semilogy(offset2, counts, 'ro', label='data')
+
+ # Extract models
+ print("Extract models:")
+ sum_model = [0.0 for i in range(nx)]
+ for k, m in enumerate(obs.models()):
+ print("- "+m.name())
+ model = [0.0 for i in range(nx)]
+ for atom in list:
+ off = atom.dir().dist_deg(crab)
+ off2 = off*off
+ index = int(off2/doffset2)
+ if index < nx:
+ prob = m.eval(atom, run)
+ model[index] = model[index] + prob * atom.size()
+ for i in range(nx):
+ sum_model[i] = sum_model[i] + model[i]
+ #plt.plot(offset2, model, styles[k], label=m.name())
+ #plt.plot(offset2, sum_model, 'r-', label='total')
+ #plt.ylim(ymin=0.1)
+
+ # Put labels
+ plt.xlabel("Offset (deg^2)")
+ plt.ylabel("Counts")
+ #plt.legend(loc="upper right")
+
+ # Show counts spectra
+ plt.show()
+
+ except ImportError:
+ print("Matplotlib is not (correctly) installed on your system.")
- # Return
- return
+ # Return
+ return
# ======================================== #
# Add CTA background model to observations #
# ======================================== #
def add_background_model(obs):
- """
- Add standard CTA background model to observations container.
-
- We use a simple power law here, scaled to Konrad's E configuration
- performance table. The model needs still to be validated.
- """
- # Recover models from observation
- models = obs.models()
-
- # Define background model
- bgd_radial = GCTAModelRadialGauss(3.0)
- bgd_spectrum = GModelSpectralPlaw(61.8e-6, -1.85, GEnergy(1.0, "TeV"))
- bgd_model = GCTAModelRadialAcceptance(bgd_radial, bgd_spectrum)
- bgd_model.name("Background")
- bgd_model.instruments("CTA")
-
- # Add background model to container
- models.append(bgd_model)
-
- # Put container back in observation container
- obs.models(models)
-
- # Return observation container
- return obs
+ """
+ Add standard CTA background model to observations container.
+
+ We use a simple power law here, scaled to Konrad's E configuration
+ performance table. The model needs still to be validated.
+ """
+ # Recover models from observation
+ models = obs.models()
+
+ # Define background model
+ bgd_radial = GCTAModelRadialGauss(3.0)
+ bgd_spectrum = GModelSpectralPlaw(61.8e-6, -1.85, GEnergy(1.0, "TeV"))
+ bgd_model = GCTAModelRadialAcceptance(bgd_radial, bgd_spectrum)
+ bgd_model.name("Background")
+ bgd_model.instruments("CTA")
+
+ # Add background model to container
+ models.append(bgd_model)
+
+ # Put container back in observation container
+ obs.models(models)
+
+ # Return observation container
+ return obs
# ================= #
# Set Crab spectrum #
# ================= #
def crab_spec():
- """
- Set Crab spectrum based on MAGIC observations
- (Albert et al. 2008, ApJ, 674, 1037)
- """
- # Set parameters
- spectrum = GModelSpectralPlaw(5.7e-16, -2.48, GEnergy(0.3, "TeV"))
-
- # Return spectrum
- return spectrum
+ """
+ Set Crab spectrum based on MAGIC observations
+ (Albert et al. 2008, ApJ, 674, 1037)
+ """
+ # Set parameters
+ spectrum = GModelSpectralPlaw(5.7e-16, -2.48, GEnergy(0.3, "TeV"))
+
+ # Return spectrum
+ return spectrum
# =============================== #
# Setup single observation survey #
# =============================== #
def survey_single():
- """
- Creates a single observation survey for test purposes.
- """
- # Allocate observation container
- obs = GObservations()
-
- # Set single pointing at galactic centre
- pntdir = GSkyDir()
- pntdir.lb_deg(0.0, 0.0)
- #run = set_one_obs(pntdir)
- run = obsutils.set(pntdir)
- obs.append(run)
-
- # Define single point source with Crab flux at galactic centre
- center = GSkyDir()
- center.lb_deg(0.0, 0.0)
- point_spatial = GModelSpatialPointSource(center)
- point_spectrum = crab_spec()
- point = GModelSky(point_spatial, point_spectrum)
- point.name('GC source')
-
- # Create model container
- models = GModels()
- models.append(point)
- obs.models(models)
-
- # Return observation container
- return obs
+ """
+ Creates a single observation survey for test purposes.
+ """
+ # Allocate observation container
+ obs = GObservations()
+
+ # Set single pointing at galactic centre
+ pntdir = GSkyDir()
+ pntdir.lb_deg(0.0, 0.0)
+ #run = set_one_obs(pntdir)
+ run = obsutils.set(pntdir)
+ obs.append(run)
+
+ # Define single point source with Crab flux at galactic centre
+ center = GSkyDir()
+ center.lb_deg(0.0, 0.0)
+ point_spatial = GModelSpatialPointSource(center)
+ point_spectrum = crab_spec()
+ point = GModelSky(point_spatial, point_spectrum)
+ point.name('GC source')
+
+ # Create model container
+ models = GModels()
+ models.append(point)
+ obs.models(models)
+
+ # Return observation container
+ return obs
# =========================== #
# Setup Galactic plane survey #
# =========================== #
def survey_gplane(lrange=10, lstep=2):
- """
- Creates a single observation survey for test purposes.
-
- Keywords:
- lrange - Longitude range (integer deg)
- lstep - Longitude step size (integer deg)
- """
- # Allocate observation container
- obs = GObservations()
-
- # Loop over longitudes
- for l in range(-lrange,lrange+lstep,lstep):
-
- # Set pointing
- pntdir = GSkyDir()
- pntdir.lb_deg(l, 0.0)
- #run = set_one_obs(pntdir)
- run = obsutils.set(pntdir)
- run.id(str(l))
- obs.append(run)
-
- # Define single point source with Crab flux at galactic centre
- center = GSkyDir()
- center.lb_deg(0.0, 0.0)
- point_spatial = GModelSpatialPointSource(center)
- point_spectrum = crab_spec()
- point = GModelSky(point_spatial, point_spectrum)
- point.name('GC source')
-
- # Create model container
- models = GModels()
- models.append(point)
- obs.models(models)
-
- # Return observation container
- return obs
+ """
+ Creates a single observation survey for test purposes.
+
+ Keywords:
+ lrange - Longitude range (integer deg)
+ lstep - Longitude step size (integer deg)
+ """
+ # Allocate observation container
+ obs = GObservations()
+
+ # Loop over longitudes
+ for l in range(-lrange,lrange+lstep,lstep):
+
+ # Set pointing
+ pntdir = GSkyDir()
+ pntdir.lb_deg(l, 0.0)
+ #run = set_one_obs(pntdir)
+ run = obsutils.set(pntdir)
+ run.id(str(l))
+ obs.append(run)
+
+ # Define single point source with Crab flux at galactic centre
+ center = GSkyDir()
+ center.lb_deg(0.0, 0.0)
+ point_spatial = GModelSpatialPointSource(center)
+ point_spectrum = crab_spec()
+ point = GModelSky(point_spatial, point_spectrum)
+ point.name('GC source')
+
+ # Create model container
+ models = GModels()
+ models.append(point)
+ obs.models(models)
+
+ # Return observation container
+ return obs
#==========================#
# Main routine entry point #
#==========================#
if __name__ == '__main__':
- """
- CTA survey simulation and analysis script.
- """
- # Initialise flags
- need_help = False
-
- # Test for command line arguments
- print(sys.argv[0])
- if (len(sys.argv) > 1):
- if sys.argv[1] == "-h":
- need_help = True
- else:
- need_help = True
+ """
+ CTA survey simulation and analysis script.
+ """
+ # Initialise flags
+ need_help = False
+
+ # Test for command line arguments
+ print(sys.argv[0])
+ if (len(sys.argv) > 1):
+ if sys.argv[1] == "-h":
+ need_help = True
+ else:
+ need_help = True
- # Print help if needed and exit
- if need_help:
- print("Usage: example_survey.py [OPTIONS]")
- print(" -h Display this usage message")
- sys.exit()
-
- # Dump header
- print("***********************")
- print("* Simulate CTA survey *")
- print("***********************")
-
- # Remove any existing result files
- list = [glob.glob("*.fits"), glob.glob("*.log"), glob.glob("*.xml")]
- for files in list:
- for file in files:
- os.remove(file)
-
- # Setup single observation survey
- #obs = survey_single()
- obs = survey_gplane()
-
- # Add background model
- obs = add_background_model(obs)
-
- # Simulate events
- print("Simulate events")
- obs = obsutils.sim(obs)
-
- # Make counts map
- print("Make counts map")
- cntmap = obsutils.cntmap(obs)
-
- # Fit observations
- print("Fit observations")
- like = obsutils.fit(obs)
- #print like.opt()
- #print like.obs().models()
-
- # Make model map
- print("Make model map (this step will take some time)")
- modmap = obsutils.modmap(obs)
-
- # Show fit results
- #plot_counts(like.obs())
+ # Print help if needed and exit
+ if need_help:
+ print("Usage: example_survey.py [OPTIONS]")
+ print(" -h Display this usage message")
+ sys.exit()
+
+ # Dump header
+ print("***********************")
+ print("* Simulate CTA survey *")
+ print("***********************")
+
+ # Remove any existing result files
+ list = [glob.glob("*.fits"), glob.glob("*.log"), glob.glob("*.xml")]
+ for files in list:
+ for file in files:
+ os.remove(file)
+
+ # Setup single observation survey
+ #obs = survey_single()
+ obs = survey_gplane()
+
+ # Add background model
+ obs = add_background_model(obs)
+
+ # Simulate events
+ print("Simulate events")
+ obs = obsutils.sim(obs)
+
+ # Make counts map
+ print("Make counts map")
+ cntmap = obsutils.cntmap(obs)
+
+ # Fit observations
+ print("Fit observations")
+ like = obsutils.fit(obs)
+ #print like.opt()
+ #print like.obs().models()
+
+ # Make model map
+ print("Make model map (this step will take some time)")
+ modmap = obsutils.modmap(obs)
+
+ # Show fit results
+ #plot_counts(like.obs())