Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new option in cfg file: ltcube and minos #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions enrico/config/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Submit = option('yes', 'no', default='no')
event = string(default=events.lis)
xml = string(default=model.xml)
tag = string(default='')
ltcube = string(default='')

[environ]
# Analysis environment configuration
Expand Down Expand Up @@ -104,6 +105,8 @@ Submit = option('yes', 'no', default='no')
FrozenSpectralIndex = float(default=0, min=0, max=5)
#Use the summed likelihood method
SummedLike = option('yes', 'no', default='no')
# Calculate MINOS errors?
minos = option('yes', 'no', default='yes')


[UpperLimit]
Expand Down Expand Up @@ -186,8 +189,8 @@ Submit = option('yes', 'no', default='no')
rad = float(default=1)
# list of sources
srclist = string(default="")
# number of photons to print
numberPhoton = integer(default=10)
# number of photons to print
numberPhoton = integer(default=10)

[Contours]
parname1 = string(default="Prefactor")
Expand Down
2 changes: 2 additions & 0 deletions enrico/energybin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def PrepareEbin(Fit, FitRunner):
#Replace the evt file with the fits file produced before
#in order to speed up the production of the fits files
config['file']['event'] = FitRunner.obs.eventfile
# use ltcube from global fit to speed up analysis
config['file']['ltcube'] = FitRunner.obs.Cubename
#update the config to allow the fit in energy bins
config['UpperLimit']['envelope'] = 'no'
config['Ebin']['NumEnergyBins'] = '0'#no new bin in energy!
Expand Down
12 changes: 8 additions & 4 deletions enrico/fitmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def GenerateFits(self):
self._log('gtbin', 'Create a count map')
self.obs.Gtbin()
self._log('gtltcube', 'Make live time cube')#run gtexpcube
self.obs.ExpCube()
if self.config["file"]["ltcube"] == "":
self.obs.ExpCube()
else:
print("Using live time cube from %s" % self.config["file"]["ltcube"])

#Choose between the binned of the unbinned analysis
if self.config['analysis']['likelihood'] == 'binned': #binned analysis chain
Expand Down Expand Up @@ -204,7 +207,8 @@ def GetAndPrintResults(self, Fit):
Scale = spectrum.getParam(par).getScale()
Result[par] = ParValue * Scale
Result['d'+par] = ParError * Scale
if ParError>0: # Compute MINOS errors for relevent parameters Fit.Ts(self.obs.srcname) > 5 and
# Compute MINOS errors for relevent parameters Fit.Ts(self.obs.srcname) > 5 and
if ParError>0 and self.config['Spectrum']['minos'] == 'yes':
try:
MinosErrors = Fit.minosError(self.obs.srcname, par)
if self.config['verbose'] == 'yes' :
Expand All @@ -218,8 +222,8 @@ def GetAndPrintResults(self, Fit):
(ParValue, ParError, Scale))
else:
if self.config['verbose'] == 'yes' :
print(par+" : %2.2f %2.0e" %
(ParValue, Scale))
print(par+" : %2.2f +/- %2.2f %2.0e" %
(ParValue, ParError, Scale))

try: # get covariance matrix
if self.config['verbose'] == 'yes' :
Expand Down
2 changes: 2 additions & 0 deletions enrico/gtfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __init__(self,folder,Configuration,tag=""):
#Fits files
self.eventfile = folder+'/'+self.srcname+inttag+"_Evt.fits"
self.Cubename = folder+'/'+self.srcname+inttag+"_ltCube.fits"
if Configuration['file']['ltcube'] != "":
self.Cubename = Configuration['file']['ltcube']
self.Mapname = folder+'/'+self.srcname+inttag+"_ExpMap.fits"
self.BinnedMapfile = folder+'/'+self.srcname+inttag+"_BinnedMap.fits"
self.cmapfile = folder+'/'+self.srcname+inttag+"_CountMap.fits"
Expand Down
2 changes: 1 addition & 1 deletion enrico/xml_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def addPSPLSuperExpCutoff(lib, name, ra, dec, eflux=0,
index1_free=1, index1_value=-2.0,
index1_min=-10.0, index1_max=-0.,
cutoff_free=1, cutoff_value=1e4,
cutoff_min=200, cutoff_max=3e5,
cutoff_min=100, cutoff_max=3e5,
index2_free=0, index2_value=1.0,
index2_min=0.0, index2_max=10.0,extendedName=""):
"""Add a source with a SUPEREXPCUTOFF model"""
Expand Down