pyLikelihood Attributes and Methods

Also see:

Users of the python-based likelihood analysis code will see only two classes, i.e.. BinnedObs and BinnedAnalysis for a binned likelihood. Other classes/functions are hidden by inheritance or import.

Note: The pyLikelihood code is distributed across multiple CVS modules within the ScienceTools release. This section:

  • Provides a list of public attributes and methods available through these fit classes.
  • Describes class and file structure to aid in tracking down a specific bit of code.

Finding code

First locate the ScienceTools release, e.g., a typical release directory installed at SLAC:

/nfs/farm/g/glast/u35/ReleaseManagerBuild/redhat5-i686-32bit-gcc41/Optimized/ScienceTools/09-17-00/

Analysis classes for binned likelihood

Based on ScienceTools/09-16-01, these classes are all defined in the pyLikelihood package.

Name Type Function package/file
BinnedObs class Encapsulates the data needed for fitting. pyLikelihood/BinnedAnalysis.py
BinnedAnalysis class

Performs binned likelihood fits.

pyLikelihood/BinnedAnalysis.py
   
  • Contains a BinnedObs
  • Inherits from AnalysisBase.
  • Imports pyLikelihood
  • Imports SrcModel
 
AnalysisBase class

Base class for all supported types of fits.

pyLikelihood/AnalysisBase.py
   
  • Imports pyLikelihood
  • Imports SrcModel
 
pyLikelihood
collection of
classes and
functions
  SWIG-produced interface to MINUIT and other Fortran/C/C++ codes.  
   

Class AnalysisBase

Attribute Name Default value Description
maxdist 20  
tol 1e-3 fit convergence tolerance (EDM)
covariance None  
covar_is_current False  
tolType ABSOLUTE  
optObject None  

 

Method(arguments) return value Description
setFitTolType (tolType) None set fit tolerance type
RELATIVE
ABSOLUTE
fit (verbosity=3,tol=None,optimizer=None,covar=False,OptObject=None) -log(likelihood) select optimizer
DRMNGB
DRMNFB
POWELL
LBFGS
MINUIT
NEWMINUIT
minosError    
setPlotter (plotter='hippo') plotter object select plotter package
par_index (srcName,parName) parameter index get selected source parameter index
getExtraSourceAttributes    
Ts (srcName, reoptimize=False, approx=True, tol=None, MaxIterations=10, verbosity=0) ts value return test statistic for source
Flux (srcName, emin=100, emax=3e5, energyFlux=False) flux get particle flux value
fluxError (srcName, emin=100, emax=3e5, energyFlux=False, npts=1000) fluxErr get particle flux uncertainty
energyFlux (srcName, emin=100, emax=3e5) energyFlux get energy flux
energyFluxError (srcName, emin=100, emax=3e5, npts=1000) energyFluxErr get energy flux uncertainty
setSpectrum (srcName, functionName)    
deleteSource (srcName)    
addSource (src)    
writeCountsSpectra (outfile='counts_spectra.fits')    
saveCurrentFit ()    
restoreBestFit ()    
NpredValue (src)    
total_nobs ()    
SyncSrcParams (src=None)    
sourceNames ()    
oplot (color=None)    
plot (oplot=0, color=None, omit=(), symbol='line')    
plotSource (srcName, color='black',symbol='line')    
normPar (srcName)    
freePars (srcName)    
setFreeFlag (srcName, pars, value)    
params ()    
thaw (i)    
freeze (i)    
writeXML (xmlFile=None)    

Owned by: Jim Chiang
Last updated by: Tom Glanzman and Chuck Patterson