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

Warnings/exceptions if gtobssim is unavailable #9

Open
wants to merge 1 commit 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
6 changes: 6 additions & 0 deletions python/GtBurst/commands/gtburstInstTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
'gtltcube','gtbkg','gtdiffrsp']

for s in st:
if s == "gtobssim":
try:
fake = GtApp(s)
except:
print ("gtobssim is not available. Simulations will not work.")
continue
fake = GtApp(s)
except:
print("Error!")
Expand Down
23 changes: 21 additions & 2 deletions python/GtBurst/dataHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,12 @@ def __init__(self, *kargs, **kwargs):
self.gtexpcube2 = GtApp('gtexpcube2')
self.gtsrcmaps = GtApp('gtsrcmaps')
self.gtmodel = GtApp('gtmodel')
self.gtobssim = GtApp('gtobssim')
try:
self.gtobssim = GtApp('gtobssim')
except:
sys.stderr.write(
"\n\nWARNING: gtobssim and LATData.makeSimulation are currently unavailable." )
self.gtobssim = None
self.gtfindsrc = GtApp('gtfindsrc')
self.gttsmap = my_gttsmap()
self.gtrspgen = GtApp('gtrspgen')
Expand Down Expand Up @@ -2403,6 +2408,9 @@ def optimizeSourcePosition(self, xmlmodel, sourceName='GRB'):

def makeSimulation(self, gtlikexml, evroot='sim', seed=None, exclude=None):

if not self.gtobssim:
raise NotImplementedError("gtobssim and LATData.makeSimulation are currently unavailable.")

self.getCuts()

# First transform the xmlfile from the gtlike to the
Expand Down Expand Up @@ -2502,15 +2510,26 @@ def makeSimulation(self, gtlikexml, evroot='sim', seed=None, exclude=None):

class Simulation(object):
def __init__(self, ft2File, irf, trigTime):

self.ft2File = ft2File
self.irf = irfs[irf]
self.trigTime = float(trigTime)
self.gtobssim = GtApp('gtobssim')
try:
self.gtobssim = GtApp('gtobssim')
except:
sys.stderr.write(
"\n\nWARNING: gtobssim and doSimulation are currently unavailable." )
self.gtobssim = None
self.gtobssim = None
pass

# -------------------------------------------------- #

def doSimulation(self, infile, srclist, evroot, simtime, tstart, seed):

if not self.gtobssim:
raise NotImplementedError("gtobssim and doSimulation are currently unavailable.")

print ('I am now ready to simulate a GRB!')
os.environ['SIMDIR'] = '$PWD'
self.gtobssim['infile'] = infile
Expand Down