Examples: Fetching Fit Parameters

This section includes a standard set of things that you might want to fetch after performing a binned or an unbinned analysis fit; for example:

# To fetch the index and error from a binned or unbinned analysis fit:

    model = like.model
    index= model[self.sourceName].funcs['Spectrum'].getParam('Index').getValue()
    indexError = model[self.sourceName].funcs['Spectrum'].getParam('Index').error()

Note: For 'self.sourceName', just substitute a string containing the exact source name in the model.xml file.

Examples: Other things you might want to fetch:

    logLike = like2.fit(optimizer=options.optimizer,covar=True)
    model = like2.model

# collect up and print results

    print model
   
    flux = like2.flux(options.sourceName,emin=options.emin,emax=options.emax)
    dflux = like2.fluxError(options.sourceName,options.emin,options.emax)

    prefactor = model[options.sourceName].funcs['Spectrum'].getParam('Prefactor').getValue( )
    dprefactor = model[options.sourceName].funcs['Spectrum'].getParam('Prefactor').error()

    index = model[options.sourceName].funcs['Spectrum'].getParam('Index1').getValue()
    dindex = model[options.sourceName].funcs['Spectrum'].getParam('Index1').error()

    cutoff = model[options.sourceName].funcs['Spectrum'].getParam('Cutoff').getValue()
    dcutoff = model[options.sourceName].funcs['Spectrum'].getParam('Cutoff').error()

    TS = like2.Ts(options.sourceName)

Note: The parameter name for an exp cutoff  index is 'Index1'. More generally you simply fetch a parameter by name.


Owned by: Richard Dubois

 

Last updated by: Chuck Patterson 03/22/2011