def _test_pickeling(self): """ Test cspull pickeling """ # Perform pickeling tests of empty class self._pickeling(cscripts.cspull()) # Set-up unbinned cspull pull = cscripts.cspull() pull['inmodel'] = self._model pull['onsrc'] = 'NONE' pull['ntrials'] = 2 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 1.0 pull['emax'] = 100.0 pull['enumbins'] = 0 pull['tmin'] = 0.0 pull['tmax'] = 100.0 pull['deadc'] = 0.98 pull['rad'] = 5.0 pull['logfile'] = 'cspull_py1_pickle.log' pull['outfile'] = 'cspull_py1_pickle.dat' pull['chatter'] = 2 # Perform pickeling tests of filled class obj = self._pickeling(pull) # Run csphasecrv script and save light curve obj.logFileOpen() # Make sure we get a log file obj.run() # Check pull distribution file self._check_pull_file('cspull_py1_pickle.dat') # Return return
def create_pull(loge, emin, emax, models, ntrials=100, duration=180000.0, enumbins=0, log=False): """ Create pull distribution Parameters: emin - Minimum energy (TeV) emax - Maximum energy (TeV) Keywords: log - Create log file(s) """ # Generate output filename outfile = "pull_" + loge + ".dat" # Setup cspull tool pull = cspull() pull.models(models) pull["outfile"] = outfile pull["ntrials"] = ntrials pull["caldb"] = "prod2" pull["irf"] = "South_50h" pull["ra"] = 83.6331 pull["dec"] = 22.0145 pull["emin"] = emin pull["emax"] = emax pull["enumbins"] = enumbins pull["duration"] = duration # Optionally open the log file if log: pull.logFileOpen() # Run tool pull.run() # Return return
def create_pull(loge, emin, emax, models, ntrials=100, duration=180000.0, enumbins=0, log=False): """ Create pull distribution Parameters: emin - Minimum energy (TeV) emax - Maximum energy (TeV) Keywords: log - Create log file(s) """ # Generate output filename outfile = "pull_"+loge+".dat" # Setup cspull tool pull = cspull() pull.models(models) pull["outfile"] = outfile pull["ntrials"] = ntrials pull["caldb"] = "prod2" pull["irf"] = "South_50h" pull["ra"] = 83.6331 pull["dec"] = 22.0145 pull["emin"] = emin pull["emax"] = emax pull["enumbins"] = enumbins pull["duration"] = duration # Optionally open the log file if log: pull.logFileOpen() # Run tool pull.run() # Return return
def _test_python(self): """ Test cspull from Python """ # Set-up unbinned cspull pull = cscripts.cspull() pull['inmodel'] = self._model pull['onsrc'] = 'NONE' pull['outfile'] = 'cspull_py1.dat' pull['ntrials'] = 2 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 0.1 pull['emax'] = 100.0 pull['enumbins'] = 0 pull['tmin'] = 0.0 pull['tmax'] = 100.0 pull['deadc'] = 0.98 pull['rad'] = 5.0 pull['logfile'] = 'cspull_py1.log' pull['chatter'] = 2 # Run cspull script pull.logFileOpen() # Make sure we get a log file pull.run() #pull.save() # Check pull distribution file self._check_pull_file('cspull_py1.dat') # Set-up binned cspull pull = cscripts.cspull() pull['inmodel'] = self._model pull['onsrc'] = 'NONE' pull['outfile'] = 'cspull_py2.dat' pull['ntrials'] = 1 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 0.1 pull['emax'] = 100.0 pull['enumbins'] = 10 pull['tmin'] = 0.0 pull['tmax'] = 100.0 pull['deadc'] = 0.98 pull['rad'] = 5.0 pull['npix'] = 20 pull['binsz'] = 0.2 pull['coordsys'] = 'CEL' pull['proj'] = 'TAN' pull['logfile'] = 'cspull_py2.log' pull['chatter'] = 3 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py2.dat', rows=2) # Set-up cspull from event list pull = cscripts.cspull() pull['inobs'] = self._events pull['onsrc'] = 'NONE' pull['inmodel'] = self._model pull['outfile'] = 'cspull_py3.dat' pull['ntrials'] = 1 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py3.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py3.dat', rows=2) # Build observation container with unbinned observation cta = gammalib.GCTAObservation(self._events) obs = gammalib.GObservations() obs.append(cta) # Set-up cspull from observation container with unbinned observation pull = cscripts.cspull(obs) pull['inmodel'] = self._model pull['onsrc'] = 'NONE' pull['outfile'] = 'cspull_py4.dat' pull['ntrials'] = 1 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py4.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py4.dat', rows=2) # Set-up stacked cspull with one observation where response cubes # are specified in the input observation pull = cscripts.cspull() pull['inobs'] = self._inobs pull['inmodel'] = self._stacked_model pull['onsrc'] = 'NONE' pull['outfile'] = 'cspull_py5.dat' pull['ntrials'] = 1 pull['enumbins'] = 0 pull['logfile'] = 'cspull_py5.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py5.dat', rows=2) # Set-up stacked cspull with two observations from which response # cubes will be computed internally. The IRFs are also specified # in the input observation, hence we do not need to query the IRF # parameters. pull = cscripts.cspull() pull['inobs'] = self._inobs_two pull['inmodel'] = self._model pull['onsrc'] = 'NONE' pull['outfile'] = 'cspull_py6.dat' pull['ntrials'] = 1 pull['emin'] = 0.02 pull['emax'] = 100.0 pull['enumbins'] = 10 pull['npix'] = 20 pull['binsz'] = 0.2 pull['coordsys'] = 'CEL' pull['proj'] = 'TAN' pull['logfile'] = 'cspull_py6.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py6.dat', rows=2) # Return return
def _test_python(self): """ Test cspull from Python """ # Set-up unbinned cspull pull = cscripts.cspull() pull['inmodel'] = self._model pull['outfile'] = 'cspull_py1.dat' pull['ntrials'] = 3 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 0.1 pull['emax'] = 100.0 pull['enumbins'] = 0 pull['tmax'] = 1800.0 pull['deadc'] = 0.95 pull['rad'] = 5.0 pull['logfile'] = 'cspull_py1.log' pull['chatter'] = 2 # Run cspull script pull.logFileOpen() # Make sure we get a log file pull.run() #pull.save() # Check pull distribution file self._check_pull_file('cspull_py1.dat') # Set-up binned cspull pull = cscripts.cspull() pull['inmodel'] = self._model pull['outfile'] = 'cspull_py2.dat' pull['ntrials'] = 3 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['ra'] = 83.6331 pull['dec'] = 22.0145 pull['emin'] = 0.1 pull['emax'] = 100.0 pull['enumbins'] = 10 pull['tmax'] = 1800.0 pull['deadc'] = 0.95 pull['rad'] = 5.0 pull['npix'] = 100 pull['binsz'] = 0.02 pull['coordsys'] = 'CEL' pull['proj'] = 'TAN' pull['logfile'] = 'cspull_py2.log' pull['chatter'] = 3 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py2.dat') # Set-up cspull from event list pull = cscripts.cspull() pull['inobs'] = self._events pull['inmodel'] = self._model pull['outfile'] = 'cspull_py3.dat' pull['ntrials'] = 3 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py3.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py3.dat') # Build observation container with unbinned observation cta = gammalib.GCTAObservation(self._events) obs = gammalib.GObservations() obs.append(cta) # Set-up cspull from observation container with unbinned observation pull = cscripts.cspull(obs) pull['inmodel'] = self._model pull['outfile'] = 'cspull_py4.dat' pull['ntrials'] = 3 pull['caldb'] = self._caldb pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py4.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py4.dat') # Set-up stacked cspull with one observation where response cubes # are specified in the input observation pull = cscripts.cspull() pull['inobs'] = self._inobs pull['inmodel'] = self._stacked_model pull['outfile'] = 'cspull_py5.dat' pull['ntrials'] = 3 pull['enumbins'] = 0 pull['logfile'] = 'cspull_py5.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py5.dat') # Set-up stacked cspull with two observations from which response # cubes will be computed internally. The IRFs are also specified # in the input observation, hence we do not need to query the IRF # parameters. pull = cscripts.cspull() pull['inobs'] = self._inobs_two pull['inmodel'] = self._model pull['outfile'] = 'cspull_py6.dat' pull['ntrials'] = 3 pull['emin'] = 0.02 pull['emax'] = 100.0 pull['enumbins'] = 10 pull['npix'] = 20 pull['binsz'] = 0.2 pull['coordsys'] = 'CEL' pull['proj'] = 'TAN' pull['logfile'] = 'cspull_py6.log' pull['chatter'] = 4 # Execute cspull script pull.execute() # Check pull distribution file self._check_pull_file('cspull_py6.dat') # Return return
def generate_pull_distribution(model, obs='NONE', onsrc='NONE', onrad=0.2, \ trials=100, caldb='prod2', irf='South_50h', \ deadc=0.98, edisp=False, \ ra=83.63, dec=22.01, rad=5.0, \ emin=0.1, emax=100.0, enumbins=0, \ duration=1800.0, \ npix=200, binsz=0.02, \ coordsys='CEL', proj='TAN', \ debug=False, chatter=2): """ Generates pull distribution for a given model Parameters ---------- model : str Model XML filename (without .xml extension) obs : str, optional Input observation definition XML filename onsrc : str, optional Name of On source for On/Off analysis onrad : float, optional Radius of On region trials : int, optional Number of trials caldb : str, optional Calibration database irf : str, optional Name of instrument response function deadc : float, optional Deadtime correction factor edisp : bool, optional Use energy dispersion? ra : float, optional Right Ascension of pointing (deg) dec : float, optional Declination of pointing (deg) rad : float, optional Simulation radius (deg) emin : float, optional Minimum energy (TeV) emax : float, optional Maximum energy (TeV) enumbins : int, optional Number of energy bins (0 for unbinned analysis) duration : float, optional Observation duration (sec) npix : int, optional Number of pixels binsz : float, optional Pixel size (deg/pixel) coordsys : str, optional Coordinate system (CEL or GAL) proj : str, optional Sky projection debug : bool, optional Enable debugging? chatter : int, optional Chatter level Returns ------- outfile : str Name of pull distribution output file """ # Derive parameters _, tail = os.path.split(model) inmodel = model + '.xml' outfile = 'cspull_' + tail + '.dat' # Setup pull distribution generation pull = cscripts.cspull() pull['inobs'] = obs pull['inmodel'] = inmodel pull['onsrc'] = onsrc pull['onrad'] = onrad pull['outfile'] = outfile pull['caldb'] = caldb pull['irf'] = irf pull['edisp'] = edisp pull['ra'] = ra pull['dec'] = dec pull['rad'] = rad pull['emin'] = emin pull['emax'] = emax pull['tmin'] = 0.0 pull['tmax'] = duration pull['enumbins'] = enumbins pull['npix'] = npix pull['binsz'] = binsz pull['coordsys'] = coordsys pull['proj'] = proj pull['deadc'] = deadc pull['rad'] = rad pull['ntrials'] = trials pull['debug'] = debug pull['chatter'] = chatter # Generate pull distributions pull.run() # Return return outfile