Skip to content

Commit

Permalink
version for Pass 8 release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsanchez committed Jun 25, 2015
1 parent fe843f3 commit 966237f
Show file tree
Hide file tree
Showing 25 changed files with 662 additions and 118 deletions.
8 changes: 0 additions & 8 deletions bin/enrico_gui
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,4 @@ except:

gui=gui.EnricoGui(infile)

## Message
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
button = gtk.Button("The gui is in development. Use with caution")
button.connect_object("clicked", gtk.Widget.destroy, win)
win.add(button)
button.show()
win.show()

gtk.main()
Binary file added doc/source/_static/banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/source/_static/enrico.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions doc/source/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "!layout.html" %}


{% block rootrellink %}
<li><a href="{{ pathto('index') }}">home</a>|&nbsp;</li>
<li><a href="{{ pathto('search') }}">search</a>|&nbsp;</li>
<li><a href="{{ pathto('contents') }}">documentation </a> &raquo;</li>
{% endblock %}


{% block relbar1 %}

<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<a href="{{ pathto('index') }}"><img src="{{
pathto("_static/banner.png", 1) }}" border="0" alt="sampledoc"/></a>
</div>
{{ super() }}
{% endblock %}

{# put the sidebar before the body #}
{% block sidebar1 %}{{ sidebar() }}{% endblock %}
{% block sidebar2 %}{% endblock %}
82 changes: 66 additions & 16 deletions doc/source/configfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ Note :
* Coordinate are in degrees.
* Available models are 'PowerLaw', 'PowerLaw2', 'LogParabola', 'PLExpCutoff'

The parameter `spectrum` is used for the generation of the sky model. Of course, you can change the model describing the spectrum of any sources (by hand...). All the models supported by the ST are described `here <http://fermi.gsfc.nasa.gov/ssc/data/analysis/documentation/Cicerone/Cicerone_Likelihood/Model_Selection.html>`_. For now, the supported models by `enrico` are PowerLaw, PowerLaw2, LogParabola, PLExpCutoff, Generic. `Generic` is for the non-supported models. By supported, we mean that enrico can produce a xml file with such model and has some optional features. It is completely possible to run an analyze with enrico and a non-supported model.
The parameter `spectrum` is used for the generation of the sky model. Of course, you can change the model describing the spectrum of any sources (by hand...). All the models supported by the ST are described `here <http://fermi.gsfc.nasa.gov/ssc/data/analysis/documentation/Cicerone/Cicerone_Likelihood/Model_Selection.html>`_. For now, the supported models by `enrico` are PowerLaw, PowerLaw2, LogParabola, PLExpCutoff, Generic. `Generic` is for the non-supported models. By supported, we mean that enrico can produce a xml file with such model and has some optional features. It is completely possible to run an analyse with enrico and a non-supported model. For extragalactic sources, absorption by the extragalactic background light can be taken into account. This feature is disable if z=0:

* redshift has to be provided
* ebl_model is a id of a model - the number is defined in the ST. 0=Kneiske, 1=Primack05, 2=Kneiske_HighUV, 3=Stecker05, 4=Franceschini, 5=Finke, 6=Gilmore
* the EBL absorption can be scaled by a parameter which can be fitted if fit_tau = yes


.. code-block:: ini
Expand All @@ -40,6 +45,9 @@ The parameter `spectrum` is used for the generation of the sky model. Of course,
ra = 238.92935
dec = 11.190102
spectrum = PowerLaw2
redshift = 0.5
ebl_model = 4
fit_tau = no
Space
-----
Expand Down Expand Up @@ -136,16 +144,29 @@ Convtype is use to select either the front (0), back (1) or both (-1) events. If
[analysis]
# General analysis options
likelihood = binned
evclass = 2
zmax = 100.0
roicut = no
filter = DATA_QUAL==1&&LAT_CONFIG==1&&ABS(ROCK_ANGLE)<52
irfs = P7REP_SOURCE_V15
# if convtype =0 or 1, an ::FRONT of ::BACK is happend at the end of the irfs string automatically
convtype = -1
fitting
Events and IRFs
--------

This part is used to defined how enrico should select the event and which IRFs to use. You can defined the event class and evtype. By default IRFS are automatically selected using the evclass and evtype (see ST documentation), irfs default value is then CALDB.

event class (PSF, edisp, etc..) can be selected through this skim. For more information, please see XXX

Currently supported irfs with this system are the PASS8_R2 irfs.

.. code-block:: ini
[event]
irfs = CALDB
evclass = 128
evtype = 3
Fitting
-------

Option for the minimizer. You can use MINUIT, NEWMINUIT, DRMGB, etc. ftol is the tolerance that the minimizer should reach.
Expand All @@ -157,7 +178,7 @@ Option for the minimizer. You can use MINUIT, NEWMINUIT, DRMGB, etc. ftol is the
ftol = 1e-06
model
Model
-----

This section is about the sky model generation. If you have set correctly you environment variables, then enrico is able to find the galactic and extragalactic model. If you want to use other model, you can specify here, their names and locations.
Expand Down Expand Up @@ -216,8 +237,8 @@ UpperLimit

This section allows to set up the upper limit computation. During the
computation, the spectral index of the source (it is assumed that a POWERLAW or
POWERLAW2 model is used) is frozen to `SpectralIndex`. Two methods can be used,
Profile of Integral, see the Fermi web site for more informations.
POWERLAW2 model is used) is frozen to `SpectralIndex`. 3 methods can be used,
Profile or Integral (see the Fermi web site for more informations) and Poisson .base on the Feldman-Cousins method for low signal (Only 95 % yet available)

An upper limit, at the confidence level `cl`, is computed if the TS is below TSlimit. This hold only for `enrico_sed`

Expand All @@ -235,8 +256,9 @@ An upper limit, at the confidence level `cl`, is computed if the TS is below TSl
# Confidence level for the Ul computation
cl = 0.95
LightCurve
----------
LightCurve : running the analyse in time bins
----------------------------------------


Option for enrico_lc which run an entire analysis in time bins and produce all the fits files needed to use gtlike.

Expand Down Expand Up @@ -288,8 +310,8 @@ This section is devoted to the folded LC. This is designed for binary system ana
Period = 10
Ebin
----
Ebin : running the analyse in energy bins
--------------------------------

* FitsGeneration, if yes, enrico will make all the steps before running gtlike and generated all the fits files needed. If the files have already been generated, change FitsGeneration to no and enrico will only run gtlike

Expand All @@ -310,8 +332,8 @@ Ebin
Option for enrico_tsmap

TSMap
-----
TSMap : creating a TS map
--------------------------------

This section is used to configured `enrico_tsmap` and `enrico_plot_tsmap`

Expand Down Expand Up @@ -354,7 +376,7 @@ For the entire row 49 :
Finding the position of a source
Findsrc : Finding the position of a source
--------------------------------

This section is used to configured `enrico_findsrc`. It run the tool gtfindsource and update the file Roi_model.reg with the fitted position in red.
Expand All @@ -371,3 +393,31 @@ This section is used to configured `enrico_findsrc`. It run the tool gtfindsourc
#Reoptimize before
Refit = option('yes', 'no', default='yes')
srcprob : Get the highest energy event
--------------------------------

This section is used to configured `enrico_srcprob`.

This part get the highest energy events that can bee associated to the sources in the lit. The probability to be a source event is also computed (using unbinned analyse). The source list has to be an ascii text.

.. code-block:: ini
[srcprob]
#Generates fits files or not?
FitsGeneration = option('yes', 'no', default='yes')
#radius for the computation
rad = float(default=1)
# list of sources
srclist = string(default="")
# number of photons to print
numberPhoton = integer(default=10)
Contours : Compute confidence contour
--------------------------------

This section is used to configured `enrico_contour`. It is possible to compute the 1, 2 and 3 sigma contour of the 2 parameters given here.

.. code-block:: ini
[Contours]
parname1 = string(default="Prefactor")
parname2 = string(default="Index")
33 changes: 33 additions & 0 deletions doc/source/script.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Options:

* vmax is used to defined the max of the color scale



.. figure:: _static/Maps.png
:align: center

Maps of PG 1553+113, from top to bottom: counts map, model map, residuals map.


Plot TS Maps
------------------

Expand All @@ -32,3 +40,28 @@ Options:
* vmax is used to defined the max of the color scale

* stretch can be linear (default), log, sqrt, arcsinh or power


.. figure:: _static/TSMaps.png
:align: center

TS Map of PG 1553+113.

Convert Time
------------------

The script ConvertTime.py convert a given time to another units

Type can be : MJD, JD, MET or ISO

.. code-block:: ini
python ConvertTime.py type value
Here are some examples:

.. code-block:: ini
python ConvertTime.py MJD 56101
python ConvertTime.py ISO 2012-02-05
python ConvertTime.py ISO 2012-02-05 16:15:18
11 changes: 11 additions & 0 deletions doc/source/team.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. _team:

Enrico Developers
=================

Enrico was initially written by David Sanchez and Christoph Deil in 2011.

You can find up to date lists of contributors
`here <https://github.com/gammapy/enrico/graphs/contributors>`_
or
`here <http://www.ohloh.net/p/enrico/contributors/summary>`_.
1 change: 1 addition & 0 deletions doc/source/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ ScienceTools are described `here <http://fermi.gsfc.nasa.gov/ssc/data/analysis/s
* ``enrico_plot_tsmap`` : plot the TS Map resulting from enrico_tsmap
* ``enrico_scan`` : make a profile likelihood for each free parameter of the target
* ``enrico_findsrc`` : run gtfindsource
* ``enrico_contour`` : make a confidence contour of 2 parameters
56 changes: 53 additions & 3 deletions doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,18 @@ and store it into a xml file which will be used for the analysis.
Use the catalog : /CATALOG_PATH/gll_psc_v06.fit
Add 12 sources in the ROI of 10.0 degrees
3 sources have free parameters inside 3.0 degrees
Iso model file /gpfs/LAPP-DATA/hess/sanchez/Fermi/Soft/ScienceTools//IExternal/diffuseModels/v5r0/iso_P8R2_SOURCE_V6_v06.txt
Galactic model file /gpfs/LAPP-DATA/hess/sanchez/Fermi/Soft/ScienceTools//IExternal/diffuseModels/v5r0/gll_iem_v06.fits
write the Xml file in ~/myanalysis/PG155+113_PowerLaw2_model.xml
.. note::
Note that you give options for this step simply by mentioning
the config file. For the `enrico_xml` tool, the relevant options
are in the [space], [target] section. The out file is given by [file]/xml.

The Iso model can be guess using the evclass and evtype given in the config file.
If the file does not excist the default one is used

Get data
--------
Expand Down Expand Up @@ -247,19 +253,48 @@ An upper limits is calculated if the Test Statistic (TS) of the source is below
* bins in energy, use the option [Ebin]/TSEnergyBins.
* `enrico_lc`, use the option [LightCurve]/TSLightCurve.

Two methods are available :
3 methods are available :

* The profile method, which look for a decrease of a certain amount of the likelihood function
* The integral method which compute the integral of the likelihood function as a function of a parameter to set the UL
* The Poisson method based on Feldman-Cousins method for low signal

Both implementations are provided by the ScienceTools and used by enrico.
The first 2 implementations are provided by the ScienceTools and used by enrico.


.. note::
For upper limits, most of the relevant options are in the [UpperLimits]
section



Results
------------

At the end of `enrico_sed`, a file with the extension `.results` is created. After is an example for a POWERLAW model:


* Index : Value of the spectral index (for POWERLAW)
* Scale : Value of the scale parameter (MeV, for POWERLAW)
* Optimizer : optimizer used in the fit
* Emin : Value of the energy min (MeV)
* Emax : Value of the energy max (MeV)
* tmax : Value of the time max (MET)
* dScale : Error of the scale parameter (MeV, for POWERLAW)
* TS : Value of the Test statistic
* ModelType : Spectral model fitted
* SrcName : Name of the target
* Flux : fitted integral flux (ph/cm2/s)
* Npred : Number of predicted photons
* log_like : Value of the loglikehihood
* dIndex : Error of the spectral index (for POWERLAW)
* dFlux : Error fitted integral flux (ph/cm2/s)
* dPrefactor : Error Prefactor parameter (ph/MeV/cm2/s)
* tmin : Value of the time min (MET)
* Prefactor : Value Prefactor parameter (ph/MeV/cm2/s)

Summaries of the LC and Ebin computations are also given in a ascii file at the end of `enrico_plot_sed` and `enrico_plot_lc`

Plot results
------------

Expand Down Expand Up @@ -347,7 +382,22 @@ These maps are use to visualize the ROI and check and see any misfitted sources.
Make Profile likelihood
-----------------------

The tool `enrico_scan` allows to make profile likelihood of the free parameters of the target. Each plot is save under the `scan` folder. Fits files must have been generated before.
The tool `enrico_scan` allows to make a profile likelihood of the free parameters of the target. Each plot is save under the `scan` folder. Fits files must have been generated before.

Make Confidence contour
-----------------------

The tool `enrico_contour` allows to make a contour of 2 free parameters of the target. Each plot is save under the `contour` folder. Fits files must have been generated before.

Get the highest energy events
-----------------------

The tool `enrico_srcprob' compute the highest energy photons that can be associated to a list of sources (provided in an ascii file). The probability of the photons to be associated to the sources is also computed

Refine source position
-----------------------

The tool `enrico_findsrc' is based on gtfindsource and find the best position of a source

Check different models
----------------------
Expand Down
21 changes: 9 additions & 12 deletions enrico/RunGTlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from enrico.fitmaker import FitMaker


def Analysis(folder, config, tag="", convtyp='-1', verbose = 1):
def Analysis(folder, config, tag="" ,verbose = 1):
""" run an analysis"""
Obs = Observation(folder, config, convtyp, tag=tag)
Obs = Observation(folder, config, tag=tag)
if verbose:
utils._log('SUMMARY: ' + tag)
Obs.printSum()
Expand All @@ -25,8 +25,9 @@ def GenAnalysisObjects(config, verbose = 1, xmlfile =""):
folder = config['out']
if SummedLike == 'yes':
# Create two obs instances
FitRunnerfront = Analysis(folder, config, tag="FRONT", convtyp=0, verbose = verbose)
FitRunnerback = Analysis(folder, config, tag="BACK", convtyp=1, verbose = verbose)
sys.exit("not yet working")
FitRunnerfront = Analysis(folder, config, tag="FRONT", verbose = verbose)
FitRunnerback = Analysis(folder, config, tag="BACK", verbose = verbose)
if not(xmlfile ==""):
FitRunnerfront.obs.xmlfile = xmlfile
FitRunnerback.obs.xmlfile = xmlfile
Expand All @@ -38,12 +39,11 @@ def GenAnalysisObjects(config, verbose = 1, xmlfile =""):
Fit.addComponent(FitF)
FitRunner = FitRunnerback
else:
convtype = config['analysis']['convtype']
# Create one obs instance
FitRunner = Analysis(folder, config, tag="", convtyp=convtype, verbose = verbose)
if not(xmlfile ==""):
FitRunner.obs.xmlfile = xmlfile
Fit = FitRunner.CreateLikeObject()
FitRunner = Analysis(folder, config, tag="", verbose = verbose)
if not(xmlfile ==""):
FitRunner.obs.xmlfile = xmlfile
Fit = FitRunner.CreateLikeObject()
return FitRunner,Fit

def run(infile):
Expand All @@ -57,9 +57,6 @@ def run(infile):
FitRunner.PerformFit(Fit)

Result = FitRunner.GetAndPrintResults(Fit)#Get and dump the target specific results
if config['verbose'] == 'yes' :
utils.GetFluxes(Fit,FitRunner.obs.Emin,FitRunner.obs.Emax) #print the flux of all the sources

utils.DumpResult(Result, config)

#plot the SED and model map if possible and asked
Expand Down

0 comments on commit 966237f

Please sign in to comment.