quickLike (version 0.1.4rc)
index

Perform a likelihood analysis for Fermi LAT data.  
 
You should have completed all of the event selection and exposure
calculations in quickAnalysis before using this moduel. 
 
First, generate a default config file:
 
quickLike (-i|--initialize)
 
Then edit the config file to match your specific analysis by filling
out the various options.  Rename the config file from example.cfg to
<basename>.cfg where <basename> is a user defined prefix; usually the
name of your source of interest but not necisarily so.
 
If you haven't created a model file (if you have, make sure it's
called <basename>_model.xml before you use this module) you can create
one from the 2FGL by running
 
> quickAnalysis (-x|--xml=)<basename>
 
To run this, you need to have all of the relevant diffuse model files
and the 2FGL catalog file in your working directory as well as
<basename>_filtered_gti.fits in your working directory.  See the
documentation for quickAnalysis for more details.
 
Once you have a config file (<basename>.cfg) and model file
(<basename>_model.xml) you can then run python and execute the other
functions within the python interpreter.
 
This module logs all of the steps to a file called
<basename>_quickAnalysis.log as well as to the screen.

 
Modules
       
ConfigParser
bisect
glob
logging
math
numpy
os
pyLikelihood
pyLikelihood
re
sys

 
Classes
       
quickLike

 
class quickLike
    This is the base class.  A usual likelihood analysis will
consists of running the following functions (assuming you have a
configuration file):
 
* qL = quickLike('MySource', True)
* qL.makeObs()
* qL.initDRM()
* qL.fitDRM()
* qL.initMIN()
* qL.fitMIN()
 
This will set up all of the objects needed for the analysis and do an
initial fit with one of the DRM optimizers.  It'll save these results
and use them for the second fit with one of the Minuit optimizers.
 
If you do not have a configuration file, you'll need to input all
of the options for this module when you create the quickLike
object (see the various options below).  You can create a
configuration file by executing writeConfig().
 
* qL.writeConfig()
 
This module will catch any failures from the optimizers and will
report them to the user.  There are a few functions that are useful to
use in this case:
 
  Methods defined here:
Print(self)
Prints out information about the various objects to the
terminal and to the log file.
__init__(self, base='MySource', configFile=False, likelihoodConfig={'drmtol': 0.10000000000000001, 'mintol': 0.0001, 'model': 'MySource_model.xml', 'sourcename': 'Source Name'}, commonConfig={'base': 'MySource', 'binned': False, 'eventclass': 2, 'irfs': 'P7SOURCE_V6', 'verbosity': 0})
calcUpper(self, source, Emin=100, Emax=300000)
Calculates an upper limit for a source in your model.
customERange(self, Emin, Emax)
Sets a smaller energy range for the fitting of both the DRM
and MIN optimization steps.
decodeRetCode(self, optimizer, retCode)
Decodes the return codes from the Minuit and New Minuit fit
functions.  Used in the fitting functions in this module.
You'll probably never use this function.
fitDRM(self)
Performs a DRM inital fit on your data using the
<basename>_model.xml model file.  It tries an intial fit and
if that fails, tries a tighter tolerance.  If that fails, it
tries a looser tolerance.  If that fails, it tries to do this
initial fit with the MINUIT optimizer.  If that fails, this
function bails.  If the fit converges, it saves the results to
<basename>_likeDRM.xml which will be used in the NewMinuit
fit.  If no fit is found, it will save the results to
<basename>_badDRMFit.xml.  You can use this in the NewMinuit fit
if you use the useBadFit option in initMIN.  You need to have run
initDRM before you run this function.
fitMIN(self)
Does a New Minuit fit on your data based on the model
output by the fitDRM function.  You need to have run initMIN
before running this function.  Saves the results to
<basename>_likeMIN.xml if there is convergence.  If
convergence is not found, saves the results to
<basename>_badMINFit.xml.
initAltFit(self, opt='MINUIT')
Initiallizes a minuit optimizer to use as a backup to the
DRM optimizer.  This function is used internally in the fitDRM
function so you probably will never use it.  You need to run
makeObs before you run this function.  If it hasn't been run,
this function will exit.
initDRM(self)
Initializes the DRM optimizer (either binned or unbinned).
This is usually the second function that you run when using
this module.  You need to run makeObs before you run this
function.  If it hasn't been run, this function will exit.
initMIN(self, useBadFit=False, modelFile='')
Initiallizes a New Minuit optimizer to use as a backup to
the DRM optimizer.  This is usually run after you have
initially run fitDRM and created a <basename>_likeDRM.xml
model file which is used a seed for the New Minuit optimizer.
You can skip the DRM process if you like but you need to have
the proper model file (<basename>_likeDRM.xml) present in the
working directory. You need to run makeObs before you run this
function.  If it hasn't been run, this function will exit.  If
you want to use the non convergant fit from fitDRM, set
useBadFit to True.  You can also pass a custom model file name
via the modelFile parameter.
makeObs(self)
Creates either a binned or unbinned observation object for
use in the likelihood analysis.  This function checks for all
of the needed files first.  If you do not have a needed file,
see the quickAnalysis module for creation.  This function
should be run before any of the init or fit functions.
paramsAtLimit(self, limit=0.10000000000000001)
This function will print out any sources whoes parameters
are close to their limits.  You could use this to find sources
that are having issues being fit.  This function is useful
when you're having trouble getting convergence from the New
Minuit fit routine. The limit is in percentage difference of a
bound.  If one of the bounds is zero it uses the value of the
parameter to check for closeness (absolute instead of percent
differenct).  The default is 0.1 (1%) difference for a measure
of closeness.
printSource(self, source, Emin=100, Emax=300000)
Prints various details for a source in your model.
reLoadSource(self)
This function puts the source removed by the unLoadSource function
back into the model.
removeWeak(self, mySource='', tslimit=0, distlimit=0, RemoveFree=False, RemoveFixed=False)
This function has two main uses: it will print out details
on all of the sources in your model and it will remove sources
according to different requirements.  If you just want to
print out details, execute it this way:
 
<obj>.removeWeak(<my_source>)
 
Where <obj> is the quickLike object you're using here and
<my_source> is the name of your source of interest.  You can
then remove some of these sources from the model if you like.
For example, if you want to remove all of the fixed sources
with TS values less than 1, execute it this way:
 
<obj>.removeWeak(<my_source>,tslimit=1,RemoveFixed=True)
 
You can mix and match any of the options.  You could remove
all sources (fixed and free) that are below a TS value of 3
and are 10 degrees from your source of interest by executing:
 
<obj>.removeWeak(<my_source>,tslimit=3,distlimit=10,RemoveFree=True,RemoveFixed=True)
unLoadSource(self, name)
This function removes a source from the model and stores it so that
you can use it later if you would like.  This is useful if you are
working on an upper limit and need to get a fit to work before you can
calculate the upper limit.
writeConfig(self)
Writes all of the initialization variables to the config
file called <basename>.cfg

 
Functions
       
cli()
Command-line interface.  Call this without any options for usage notes.

 
Data
        TsMap = <GtApp.GtApp object>
__author__ = 'Jeremy S. Perkins (FSSC)'
__version__ = '0.1.4rc'
addCubes = <GtApp.GtApp object>
counts_map = <GtApp.GtApp object>
diffResps = <GtApp.GtApp object>
evtbin = <GtApp.GtApp object>
expCube = <GtApp.GtApp object>
expMap = <GtApp.GtApp object>
filter = <GtApp.GtApp object>
gtexpcube2 = <GtApp.GtApp object>
like = <GtApp.GtApp object>
maketime = <GtApp.GtApp object>
message = ImportError('cannot import name map',)
model_map = <GtApp.GtApp object>
obsSim = <GtApp.GtApp object>
rspgen = <GtApp.GtApp object>
srcMaps = <GtApp.GtApp object>

 
Author
        Jeremy S. Perkins (FSSC)