pyLikelihood: Help (Unbinned and Binned)
On this page:
Refer to:
Also see:
|
pyLikelihood provides a means by which a python script can:
(1) read in a source model and a data file, and (2) determine goodness of fit, i.e., how well the model fits the data.
The pyLikelihood package is a Python interface to underlying code written in C or C++, and ultimately enables you to perform an unbinned or binned analysis by running gtlike. In this sense, pyLikelihood is an interface to the gtlike tool.
Both unbinned and binned analyses have been respectively implemented in the UnbinnedAnalysis.py and BinnedAnalysis.py modules. Each module contains two classes: UnbinnedObs and UnbinnedAnalysis in the former, and BinnedObs and BinnedAnalysis in the latter. Since the respective analyses require different sets of input data, the "Obs" classes differ in how they are constructed.
The Analysis classes for both implementations encapsulate the information associated with a specific observation (defined in terms of the extraction region in the data space of photon arrival time, measured energy, and direction).
The "Obs" classes, however, differ in how they are constructed, since the respective analyses require different sets of input data. An observation also comprises ancillary information specific to the data selections such as the exposure information and the response functions to be used.
Note: Factoring into separate analysis and observation classes affords flexibility in mixing and matching observations and models in a single Python session or script while preserving computational resources, so that one can do something like this:
>>> analysis1 = UnbinnedAnalysis(unbinnedObs, "model1.xml")
>>> analysis2 = UnbinnedAnalysis(unbinnedObs, "model2.xml")
|
Even though the two UnbinnedAnalysis instances access the same data in memory, distinct source models may be fit concurrently to those data without interfering with one another. This is useful in comparing, via a likelihood ratio test, for example, how well one model compares to another.
Analysis Classes
observation – An instance of the UnbinnedObs class.
srcModel – Name of the XML file containing the source model definition.
optimizer – Optimizer package to use: DRMNFB, DRMNGB, MINUIT, NEWMINUIT, LGFGS (see Model Fitting in gtlike Help file.) |
binnedData –
srcModel – Name of the XML file containing the source model definition.
optimizer – Optimizer package to use: DRMNFB, DRMNGB, MINUIT, NEWMINUIT, LGFGS (see Model Fitting in gtlike Help file.)
|
Objects
eventfile – Event data file name(s), can be a single file name, a tuple, or a list of file names.
scFile – Spacecraft data file names; can also be an ascii file of FITS names.
expMap – Exposure map (produced by gtexpmap); geometry of map matches that of the extraction region used to create event files.
expCube – Livetime cube (produced by gtltcube); an off-axis histogram of livetimes at each point in the sky, partitioned as nested HealPix.
checkCuts – Debugging flag; should be set to True for a standard analysis.
irfs – Instrument response functions, e.g., HANDOFF. |
srcMaps – Counts map file with axes in position and energy, and source map extensions created using gtsrcmaps. The counts map may be created with gtcmap.
Note: If you provide a counts map without a complete set of source map extensions, the BinnedAnalysis class will examine the model definition file and compute source maps in memory for all the sources that do not have source maps in the counts map file.
expCube – Livetime cube (produced by gtltcube); an off-axis histogram of livetimes at each point in the sky, partitioned as nested HealPix.
binnedExpMap – Exposure map appropriate for binned analysis. (See gtexpmap.)
Note: Optional; if not specified, Likelihood will compute an exposure map matched to the geometry of the counts map in srcMaps, and output it as binned_exposure.fits.
irfs – Instrument response functions, e.g., HANDOFF. |
Note: The instrument response (PSF, effective area, energy resolution) is currently a function of energy, inclination angle (the angle between the source and the LAT normal), and photon category. Since the LAT usually surveys the sky, a source will be observed at different inclination angles. Each count will therefore be characterized by a different IRF. (See the Instrument response functions page in Confluence. )
Functions
|
addSource(src) |
|
|
|
|
|
|
|
covariance |
|
|
like.fit(covar=True) |
|
|
|
|
deleteSource(srcName) |
|
|
|
|
|
|
|
disp |
|
|
|
|
|
|
|
e_vals |
|
|
|
|
|
|
|
energies |
|
|
|
|
|
|
|
fit(verbosity=3, tol=None, optimizer=None, covar=False, optObject=None) |
|
|
|
|
|
|
|
freeze(i) |
|
|
|
|
|
|
|
logLike |
|
|
|
|
|
|
|
maxdist |
|
|
|
|
|
|
|
model |
|
|
|
|
|
|
|
nobs |
|
|
Number of observations. |
|
|
|
|
observation |
|
|
|
|
|
|
|
oplot(color=None) |
|
|
|
|
|
|
|
optimizer='Minuit' |
|
|
Available optimizer packages: Minuit, NewMinuit Drmnfb, Drmngb, Lbfgs.
(See the Model Fitting section in gtlike Help for details.) |
|
|
|
|
|
|
|
plot(oplot=0, color=None, omit=()) |
|
|
|
|
|
|
|
resids |
|
|
|
|
|
|
|
setPlotter(plotter='hippo') |
|
|
|
|
|
|
|
setFitTolType(tolType) ??????? |
|
|
|
|
|
|
|
sourceNames(self) |
|
|
|
|
|
|
|
srcModel |
|
|
|
|
|
|
|
state |
|
|
|
|
|
|
|
thaw(i) |
|
|
|
|
|
|
|
tol |
|
|
|
|
|
|
|
Ts(srcName, reoptimize=False, approx=True, tol=None) |
|
|
Test Statistic. |
|
|
|
|
writeCountsSpectra(outfile='counts_spectra.fits') |
|
|
|
|
|
|
|
writeXml(xmlFile=None) |
|
|
|
|
|
|
|
flux(srcName, emin=100, emax=3e5, energyFlux=False)??????? |
|
|
|
|
|
|
|
energyFlux(srcName, emin=100, emax=3e5)??????? |
|
|
|
|
|
|
|
energyFluxError(srcName, emin=100, emax=3e5, npts=1000)???????
|
|
|
|
|
|
|
|
fluxError(srcName, emin=100, emax=3e5, energyFlux=False, npts=1000) ??? |
|
|
|
|
|
|
|
plotSource(srcName, color='black',symbol='line')??????? |
|
|
|
|
|
|
|
|
Last updated by: Chuck Patterson
05/27/2009 |
|
|