def _test_python(self): """ Test csspec from Python """ # Set-up unbinned csspec spec = cscripts.csspec() spec['inobs'] = self._events spec['inmodel'] = self._model spec['srcname'] = 'Crab' spec['caldb'] = self._caldb spec['irf'] = self._irf spec['outfile'] = 'csspec_py1.fits' spec['ebinalg'] = 'LOG' spec['enumbins'] = 5 spec['emin'] = 0.1 spec['emax'] = 100.0 spec['logfile'] = 'csspec_py1.log' spec['chatter'] = 2 # Run csspec script spec.logFileOpen() # Make sure we get a log file spec.run() spec.save() # Check pull distribution file self._check_result_file('csspec_py1.fits', 5) # Set-up binned csspec spec = cscripts.csspec() spec['inobs'] = self._inobs spec['expcube'] = self._expcube spec['psfcube'] = self._psfcube spec['edispcube'] = self._edispcube spec['bkgcube'] = self._bkgcube spec['inmodel'] = self._model spec['srcname'] = 'Crab' spec['outfile'] = 'csspec_py2.fits' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 0.1 spec['emax'] = 100.0 spec['logfile'] = 'csspec_py2.log' spec['chatter'] = 3 # Execute csspec script spec.execute() # Check pull distribution file self._check_result_file('csspec_py2.fits', 2) # Return return
def create_spectrum(datadir): """ Simulate events and generate a source spectrum Returns ------- datadir : str Data directory """ # Set script parameters model_name = datadir + '/crab.xml' caldb = 'prod2' irf = 'South_0.5h' ra = 83.63 dec = 22.01 rad_sim = 3.0 tstart = 0.0 tstop = 1800.0 emin = 0.1 emax = 100.0 enumbins = 10 # Simulate events sim = ctools.ctobssim() sim['inmodel'] = model_name sim['caldb'] = caldb sim['irf'] = irf sim['ra'] = ra sim['dec'] = dec sim['rad'] = rad_sim sim['tmin'] = tstart sim['tmax'] = tstop sim['emin'] = emin sim['emax'] = emax sim.run() # Create spectrum spec = cscripts.csspec(sim.obs()) spec['srcname'] = 'Crab' spec['outfile'] = 'example_spectrum.fits' spec['expcube'] = 'NONE' spec['psfcube'] = 'NONE' spec['bkgcube'] = 'NONE' spec['edisp'] = False spec['emin'] = emin spec['emax'] = emax spec['enumbins'] = enumbins spec['ebinalg'] = 'LOG' spec.run() spec.save() # Get copy of spectrum spectrum = spec.spectrum().copy() # Return return spectrum
def make_spectrum(): """ Make a spectrum. """ # Set script parameters model_name = "${CTOOLS}/share/models/crab.xml" caldb = "prod2" irf = "South_50h" ra = 83.63 dec = 22.01 rad_sim = 3.0 tstart = 0.0 tstop = 1800.0 emin = 0.1 emax = 100.0 enumbins = 10 # Simulate events sim = ctools.ctobssim() sim["inmodel"] = model_name sim["caldb"] = caldb sim["irf"] = irf sim["ra"] = ra sim["dec"] = dec sim["rad"] = rad_sim sim["tmin"] = tstart sim["tmax"] = tstop sim["emin"] = emin sim["emax"] = emax sim.run() # Generate an energy binning #e_min = gammalib.GEnergy(emin, "TeV") #e_max = gammalib.GEnergy(emax, "TeV") #ebounds = gammalib.GEbounds(10, e_min, e_max) # Setup csspec run spec = cscripts.csspec(sim.obs()) spec["srcname"] = "Crab" spec["outfile"] = "spectrum.fits" spec["expcube"] = "NONE" spec["psfcube"] = "NONE" spec["bkgcube"] = "NONE" spec["edisp"] = False spec["emin"] = emin spec["emax"] = emax spec["enumbins"] = enumbins spec["binned"] = False spec.run() # Get copy of spectrum spectrum = spec.spectrum().copy() # Return return spectrum
def _test_pickeling(self): """ Test csspec pickeling """ # Perform pickeling tests of empty class self._pickeling(cscripts.csspec()) # Set-up unbinned csspec spec = cscripts.csspec() spec['inobs'] = self._events spec['inmodel'] = self._model spec['srcname'] = 'Crab' spec['caldb'] = self._caldb spec['irf'] = self._irf spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 1.0 spec['emax'] = 100.0 spec['outfile'] = 'csspec_py1_pickle.fits' spec['logfile'] = 'csspec_py1_pickle.log' spec['chatter'] = 2 spec['publish'] = True # Perform pickeling tests of filled class obj = self._pickeling(spec) # Run csspec script and save light curve obj.logFileOpen() # Make sure we get a log file obj.run() obj.save() # Check result file self._check_result_file('csspec_py1_pickle.fits', 2) # Return return
def csspec_run(self, input_obs_list, input_models=None, enumbins=20, output_file='spectrum.fits', log_file='csspec.log', force=False, save=False): spec = cscripts.csspec() if isinstance(input_obs_list, gammalib.GObservations): spec.obs(input_obs_list) elif os.path.isfile(input_obs_list) and os.path.isfile(input_models): # observations list from file spec["inobs"] = input_obs_list spec["inmodel"] = input_models else: raise Exception('Cannot understand input obs list for csspec') spec["srcname"] = self.name spec["caldb"] = self.caldb spec["irf"] = self.irf spec["method"] = "AUTO" spec["emin"] = 0.03 spec["emax"] = 150.0 spec['ebinalg'] = "LOG" spec["enumbins"] = enumbins spec['calc_ts'] = True spec['calc_ulim'] = True spec['outfile'] = output_file spec["logfile"] = log_file spec["nthreads"] = self.nthreads if force or not os.path.isfile(output_file): spec.logFileOpen() spec.run() elif os.path.isfile(output_file): spec._fits = gammalib.GFits(output_file) else: raise Exception("Cannot proceed with csspec") saved = False if (save and force) or (save and not os.path.isfile(output_file)): spec.save() saved = True logger.info("File {} created.".format(output_file)) return spec
def makeSpectralPoints(cfg): """ Computes spectrum """ outputdir = cfg.getValue('general', 'outputdir') spec = cscripts.csspec() if cfg.getValue('general', 'anatype') == 'unbinned': spec["inobs"] = outputdir + '/' + cfg.getValue('ctselect', 'output') spec["inmodel"] = outputdir + '/' + cfg.getValue('ctlike', 'output') elif cfg.getValue('general', 'anatype') == 'binned': spec["inobs"] = outputdir + '/' + cfg.getValue('ctbin', 'output') spec["inmodel"] = outputdir + '/' + cfg.getValue('ctlike', 'output') spec["expcube"] = outputdir + '/' + cfg.getValue('ctexpcube', 'output') spec["psfcube"] = outputdir + '/' + cfg.getValue('ctpsfcube', 'output') spec["bkgcube"] = outputdir + '/' + \ cfg.getValue('ctbkgcube', 'output_cube') else: Utilities.warning('Unknown type: {}'.format( cfg.getValue('general', 'anatype'))) sys.exit() spec["outfile"] = outputdir + '/' + cfg.getValue('csspec', 'output') spec["emin"] = cfg.getValue('csspec', 'emin') spec["emax"] = cfg.getValue('csspec', 'emax') spec["enumbins"] = cfg.getValue('csspec', 'enumbins') spec["srcname"] = "" spec["ebinalg"] = "LOG" if cfg.getValue('general', 'edisp'): spec["edisp"] = True else: spec["edisp"] = True if cfg.getValue('general', 'debug') is True: spec["debug"] = True # spec.run() spec.execute() # make copy of spectrum spectrum = spec.spectrum().copy() return spectrum
def stackedPipeline( name="Crab", obsfile="index.xml", l=0.01, b=0.01, emin=0.1, emax=100.0, enumbins=20, nxpix=200, nypix=200, binsz=0.02, coordsys="CEL", proj="CAR", caldb="prod2", irf="acdc1a", debug=False, inmodel="Crab", outmodel="results", ): """ Simulation and stacked analysis pipeline Parameters ---------- obs : `~gammalib.GObservations` Observation container ra : float, optional Right Ascension of counts cube centre (deg) dec : float, optional Declination of Region of counts cube centre (deg) emin : float, optional Minimum energy (TeV) emax : float, optional Maximum energy (TeV) enumbins : int, optional Number of energy bins nxpix : int, optional Number of pixels in X axis nypix : int, optional Number of pixels in Y axis binsz : float, optional Pixel size (deg) coordsys : str, optional Coordinate system proj : str, optional Coordinate projection debug : bool, optional Debug function """ # Bin events into counts map bin = ctools.ctbin() bin["inobs"] = obsfile bin["ebinalg"] = "LOG" bin["emin"] = emin bin["emax"] = emax bin["enumbins"] = enumbins bin["nxpix"] = nxpix bin["nypix"] = nypix bin["binsz"] = binsz bin["coordsys"] = coordsys bin["proj"] = proj bin["xref"] = l bin["yref"] = b bin["debug"] = debug bin["outobs"] = "cntcube.fits" bin.execute() print("Datacube : done!") # Create exposure cube expcube = ctools.ctexpcube() # expcube['incube']=bin.obs() expcube["inobs"] = obsfile expcube["incube"] = "NONE" expcube["ebinalg"] = "LOG" expcube["caldb"] = caldb expcube["irf"] = irf expcube["emin"] = emin expcube["emax"] = emax expcube["enumbins"] = enumbins expcube["nxpix"] = nxpix expcube["nypix"] = nypix expcube["binsz"] = binsz expcube["coordsys"] = coordsys expcube["proj"] = proj expcube["xref"] = l expcube["yref"] = b expcube["debug"] = debug expcube["outcube"] = "cube_exp.fits" expcube.execute() print("Expcube : done!") # Create PSF cube psfcube = ctools.ctpsfcube() psfcube["inobs"] = obsfile psfcube["incube"] = "NONE" psfcube["ebinalg"] = "LOG" psfcube["caldb"] = caldb psfcube["irf"] = irf psfcube["emin"] = emin psfcube["emax"] = emax psfcube["enumbins"] = enumbins psfcube["nxpix"] = 10 psfcube["nypix"] = 10 psfcube["binsz"] = 1.0 psfcube["coordsys"] = coordsys psfcube["proj"] = proj psfcube["xref"] = l psfcube["yref"] = b psfcube["debug"] = debug psfcube["outcube"] = "psf_cube.fits" psfcube.execute() print("Psfcube : done!") edispcube = ctools.ctedispcube() edispcube["inobs"] = obsfile edispcube["ebinalg"] = "LOG" edispcube["incube"] = "NONE" edispcube["caldb"] = caldb edispcube["irf"] = irf edispcube["xref"] = l edispcube["yref"] = b edispcube["proj"] = proj edispcube["coordsys"] = coordsys edispcube["binsz"] = 1.0 edispcube["nxpix"] = 10 edispcube["nypix"] = 10 edispcube["emin"] = emin edispcube["emax"] = emax edispcube["enumbins"] = enumbins edispcube["outcube"] = "edisp_cube.fits" edispcube["debug"] = debug edispcube.execute() print("Edispcube : done!") # Create background cube bkgcube = ctools.ctbkgcube() bkgcube["inobs"] = obsfile bkgcube["incube"] = "cntcube.fits" bkgcube["caldb"] = caldb bkgcube["irf"] = irf bkgcube["debug"] = debug bkgcube["inmodel"] = str(inmodel) bkgcube["outcube"] = "bkg_cube.fits" bkgcube["outmodel"] = "bkg_cube.xml" bkgcube.execute() print("Bkgcube : done!") # Fix the instrumental background parameters bkgcube.models()["BackgroundModel"]["Prefactor"].fix() bkgcube.models()["BackgroundModel"]["Index"].fix() # # # Attach background model to observation container bin.obs().models(bkgcube.models()) # # # # Set Exposure and Psf cube for first CTA observation # # (ctbin will create an observation with a single container) bin.obs()[0].response(expcube.expcube(), psfcube.psfcube(), edispcube.edispcube(), bkgcube.bkgcube()) # Perform maximum likelihood fitting like = ctools.ctlike(bin.obs()) # like['inmodel']='bkg_cube.xml' like["edisp"] = True # like['edispcube'] = 'edisp_cube.fits' # like['expcube'] = 'cube_exp.fits' # like['psfcube'] = 'psf_cube.fits' # like['bkgcube'] = 'bkg_cube.fits' like["outmodel"] = str(outmodel) # like['outcovmat']=inmodel+'_covmat.txt' like["debug"] = debug # Switch this always on for results in console # like['statistic']='CSTAT' like.execute() print("Likelihood : done!") # Set the best-fit models (from ctlike) for the counts cube bin.obs().models(like.obs().models()) # Obtain the best-fit butterfly try: butterfly = ctools.ctbutterfly(bin.obs()) butterfly["srcname"] = name butterfly["inmodel"] = str(outmodel) butterfly["edisp"] = True butterfly["emin"] = emin butterfly["emax"] = emax butterfly["outfile"] = str(outmodel.parent) + "/" + str( outmodel.stem) + ".txt" butterfly[ "debug"] = debug # Switch this always on for results in console # like['statistic']='CSTAT' butterfly.execute() print("Butterfly : done!") except: print("I COULDN'T CALCULATE THE BUTTERFLY....") # Extract the spectrum try: csspec = cscripts.csspec(bin.obs()) csspec["srcname"] = name csspec["inmodel"] = str(outmodel) csspec["method"] = "AUTO" csspec["ebinalg"] = "LOG" csspec["emin"] = emin csspec["emax"] = emax csspec["enumbins"] = 10 csspec["edisp"] = True csspec["outfile"] = str(outmodel.parent) + "/" + str( outmodel.stem) + ".fits" csspec["debug"] = debug # Switch this always on for results in console csspec.execute() print("Csspec : done!") except: print("I COULDN'T CALCULATE THE SPECTRUM....") # Return return
def spectrum(obsname, bkgname, srcmodel, pars, emin=0.3, emax=20.0, alpha=1.0): """ Generate spectrum Parameters ---------- obsname : str Observation definition XML file bkgname : str Background model definition XML file srcmodel : str Source model pars : dict Dictionary of analysis parameters emin : float, optional Minimum energy (TeV) emax : float, optional Maximum energy (TeV) alpha : float, optional Template map scaling factor """ # Set observation name _obsname = set_observation(obsname, srcmodel, bkgname, pars) # Set analysis analysis = set_analysis(srcmodel, bkgname, 'plaw', pars, alpha=alpha) # Set file names outfile = 'rx_spectrum_%s.fits' % (analysis) logfile = 'rx_spectrum_%s.log' % (analysis) # Continue only if result file does not exist if not os.path.isfile(outfile): # Load observations obs = gammalib.GObservations(_obsname) # Set background model for stacked analysis if pars['stacked']: bname = add_attribute(bkgname, '_stacked') models = set_model(srcmodel, 'plaw', bname, alpha=alpha) for model in models: if model.type() == 'CTACubeBackground': model.spectral()['Index'].fix() # ... otherwise create H.E.S.S. background model with power law # spectral component else: # Setup plaw background model bkg = cscripts.csbkgmodel() bkg['inobs'] = '$HESSDATA/obs/obs_rx.xml' bkg['instrument'] = 'HESS' bkg['spatial'] = 'LOOKUP' bkg['slufile'] = 'off_lookup.fits' bkg['gradient'] = True bkg['spectral'] = 'PLAW' bkg['runwise'] = True bkg['emin'] = emin bkg['emax'] = emax bkg['rad'] = 2.0 bkg.run() # Initialise model container models = gammalib.GModels() # Set source model source = set_source_model(srcmodel, spec='plaw', alpha=alpha) models.append(source) # Set background model bkg_models = bkg.models() for model in bkg_models: if model.type() == 'CTABackground': model.spectral()['Index'].fix() model.spatial()[0].fix() # Normalization model.spatial()[1].free() # DETX model.spatial()[2].free() # DETY # Append background models models.extend(bkg_models) # Append models obs.models(models) # Generate spectrum spec = cscripts.csspec(obs) spec['srcname'] = 'RX J1713.7-3946' spec['edisp'] = pars['edisp'] spec['outfile'] = outfile spec['method'] = 'SLICE' spec['ebinalg'] = 'LOG' spec['emin'] = emin spec['emax'] = emax spec['enumbins'] = 15 spec['logfile'] = logfile spec['debug'] = True spec['chatter'] = 4 spec.logFileOpen() spec.execute() # Return return
debug = True butterfly = ctools.ctbutterfly() butterfly['inobs'] = 'cntcube.fits' butterfly['inmodel'] = 'stacked_results_iem_add3_ext5.xml' butterfly['srcname'] = 'Src001' butterfly['expcube'] = 'expcube.fits' butterfly['psfcube'] = 'psfcube.fits' butterfly['bkgcube'] = 'bkgcube.fits' butterfly['outfile'] = 'butterfly_iem_add3_ext5.txt' butterfly['emin'] = 0.1 butterfly['emax'] = 100.0 butterfly['debug'] = debug butterfly.execute() spec = cscripts.csspec() spec['inobs'] = 'cntcube.fits' spec['inmodel'] = 'stacked_results_iem_add3_ext5.xml' spec['srcname'] = 'Src001' spec['expcube'] = 'expcube.fits' spec['psfcube'] = 'psfcube.fits' spec['bkgcube'] = 'bkgcube.fits' spec['outfile'] = 'spectrum_gc_iem_add3_ext5.fits' spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['emin'] = 0.1 spec['emax'] = 100.0 spec['enumbins'] = 30 spec['debug'] = debug spec.execute()
def spectrum(inobs, inmodel, srcname, outfile, emin=1e-2, emax=1e+3, enumbins=20, ebinalg='LOG', expcube=None, psfcube=None, bkgcube=None, edispcube=None, caldb=None, irf=None, edisp=False, method='SLICE', statistic='DEFAULT', calc_ts=True, calc_ulim=True, fix_srcs=True, fix_bkg=False, dll_sigstep=1, dll_sigmax=7, dll_freenodes=False, logfile=None, silent=False): """ Compute a spectrum for a given source. See http://cta.irap.omp.eu/ctools/users/reference_manual/csspec.html Parameters ---------- - inobs (string): input observation file - inmodel (string): input model - srcname (str): name of the source to compute - outfile (str): output spectrum file - emin,emax (float) min and max energy considered in TeV - enumbins (int): number of energy bins - ebinalg (string): energy bining algorithm - modcube (string): model map cube - expcube (string): exposure map cube - psfcube (string): psfcube - bkgcube (string): background cube - edispcube (string): energy dispersion cube - caldb (string): calibration database - irf (string): instrument response function - edisp (bool): apply energy dispersion - method (str): Spectrum generation method - statistic (str): Optimization statistic. - calc_ts (bool): Compute TS for each spectral point? - calc_ulim (bool): Compute upper limit for each spectral point? - fix_srcs (bool): Fix other sky model parameters? - fix_bkg (bool): Fix background model parameters? - dll_sigstep (float): sigma steps for the likelihood scan - dll_sigmax (float): sigma max for the likelihood scan - dll_freenodes (bool): free nodes for method = NODES - silent (bool): print information or not Outputs -------- - create spectrum fits - return a spectrum object """ spec = cscripts.csspec() spec['inobs'] = inobs spec['inmodel'] = inmodel spec['srcname'] = srcname if expcube is not None: spec['expcube'] = expcube if psfcube is not None: spec['psfcube'] = psfcube if edispcube is not None: spec['edispcube'] = edispcube if bkgcube is not None: spec['bkgcube'] = bkgcube if caldb is not None: spec['caldb'] = caldb if irf is not None: spec['irf'] = irf spec['edisp'] = edisp spec['outfile'] = outfile spec['method'] = method spec['ebinalg'] = ebinalg spec['emin'] = emin spec['emax'] = emax spec['enumbins'] = enumbins spec['ebinfile'] = 'NONE' spec['statistic'] = statistic spec['calc_ts'] = calc_ts spec['calc_ulim'] = calc_ulim spec['fix_srcs'] = fix_srcs spec['fix_bkg'] = fix_bkg spec['dll_sigstep'] = dll_sigstep spec['dll_sigmax'] = dll_sigmax spec['dll_freenodes'] = dll_freenodes if logfile is not None: spec['logfile'] = logfile if logfile is not None: spec.logFileOpen() spec.execute() if logfile is not None: spec.logFileClose() if not silent: print(spec) print('') return spec
def _test_python(self): """ Test csspec from Python """ # Set-up unbinned csspec (no multi-processing) spec = cscripts.csspec() spec['inobs'] = self._events spec['inmodel'] = self._model spec['srcname'] = 'Crab' spec['caldb'] = self._caldb spec['irf'] = self._irf spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 1.0 spec['emax'] = 100.0 spec['nthreads'] = 1 spec['outfile'] = 'csspec_py1.fits' spec['logfile'] = 'csspec_py1.log' spec['chatter'] = 2 spec['publish'] = True # Run csspec script spec.logFileOpen() # Make sure we get a log file spec.run() spec.save() # Check result file self._check_result_file('csspec_py1.fits', 2) # Set-up stacked csspec (no multi-processing) spec = cscripts.csspec() spec['inobs'] = self._cntcube spec['expcube'] = self._expcube spec['psfcube'] = self._psfcube spec['edispcube'] = self._edispcube spec['bkgcube'] = self._bkgcube spec['inmodel'] = self._bkgmodel spec['srcname'] = 'Crab' spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 0.1 spec['emax'] = 100.0 spec['nthreads'] = 1 spec['outfile'] = 'csspec_py2.fits' spec['logfile'] = 'csspec_py2.log' spec['chatter'] = 3 spec['publish'] = False # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py2.fits', 2) # Set-up On/Off csspec (no multi-processing) spec = cscripts.csspec() spec['inobs'] = self._inonoff spec['inmodel'] = self._onoff_model spec['srcname'] = 'Crab' spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 1.0 spec['emax'] = 10.0 spec['nthreads'] = 1 spec['outfile'] = 'csspec_py3.fits' spec['logfile'] = 'csspec_py3.log' spec['chatter'] = 4 spec['publish'] = False # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py3.fits', 2) # Set-up On/Off csspec with NODES method spec = cscripts.csspec() spec['inobs'] = self._inonoff spec['inmodel'] = self._onoff_model spec['srcname'] = 'Crab' spec['method'] = 'NODES' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 1.0 spec['emax'] = 10.0 spec['outfile'] = 'csspec_py4.fits' spec['logfile'] = 'csspec_py4.log' spec['chatter'] = 4 spec['publish'] = False # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py4.fits', 2) # Set-up On/Off csspec using WSTAT spec = cscripts.csspec() spec['inobs'] = self._inonoff spec['inmodel'] = self._onoff_model spec['srcname'] = 'Crab' spec['method'] = 'AUTO' spec['statistic'] = 'WSTAT' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 1.0 spec['emax'] = 10.0 spec['outfile'] = 'csspec_py5.fits' spec['logfile'] = 'csspec_py5.log' spec['chatter'] = 2 # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py5.fits', 2) # Return return
import gammalib
def _test_python(self): """ Test csspec from Python """ # Set-up unbinned csspec spec = cscripts.csspec() spec['inobs'] = self._events spec['inmodel'] = self._model spec['srcname'] = 'Crab' spec['caldb'] = self._caldb spec['irf'] = self._irf spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 5 spec['emin'] = 0.1 spec['emax'] = 100.0 spec['outfile'] = 'csspec_py1.fits' spec['logfile'] = 'csspec_py1.log' spec['chatter'] = 2 spec['publish'] = True # Run csspec script spec.logFileOpen() # Make sure we get a log file spec.run() spec.save() # Check result file self._check_result_file('csspec_py1.fits', 5) # Set-up stacked csspec spec = cscripts.csspec() spec['inobs'] = self._inobs spec['expcube'] = self._expcube spec['psfcube'] = self._psfcube spec['edispcube'] = self._edispcube spec['bkgcube'] = self._bkgcube spec['inmodel'] = self._bkgmodel spec['srcname'] = 'Crab' spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 2 spec['emin'] = 0.1 spec['emax'] = 100.0 spec['outfile'] = 'csspec_py2.fits' spec['logfile'] = 'csspec_py2.log' spec['chatter'] = 3 spec['publish'] = False # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py2.fits', 2) # Set-up On/Off csspec spec = cscripts.csspec() spec['inobs'] = self._inonoff spec['inmodel'] = self._onoff_model spec['srcname'] = 'Crab' spec['method'] = 'AUTO' spec['ebinalg'] = 'LOG' spec['enumbins'] = 10 spec['emin'] = 0.1 spec['emax'] = 10.0 spec['outfile'] = 'csspec_py3.fits' spec['logfile'] = 'csspec_py3.log' spec['chatter'] = 4 spec['publish'] = False # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py3.fits', 10) # Set-up On/Off csspec with NODES method spec = cscripts.csspec() spec['inobs'] = self._inonoff spec['inmodel'] = self._onoff_model spec['srcname'] = 'Crab' spec['method'] = 'NODES' spec['ebinalg'] = 'LOG' spec['enumbins'] = 10 spec['emin'] = 0.1 spec['emax'] = 10.0 spec['outfile'] = 'csspec_py4.fits' spec['logfile'] = 'csspec_py4.log' spec['chatter'] = 4 spec['publish'] = False # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py4.fits', 10) # Set-up On/Off csspec using WSTAT spec = cscripts.csspec() spec['inobs'] = self._inonoff spec['inmodel'] = self._onoff_model spec['srcname'] = 'Crab' spec['method'] = 'AUTO' spec['statistic'] = 'WSTAT' spec['ebinalg'] = 'LOG' spec['enumbins'] = 10 spec['emin'] = 0.1 spec['emax'] = 10.0 spec['outfile'] = 'csspec_py5.fits' spec['logfile'] = 'csspec_py5.log' spec['chatter'] = 2 # Execute csspec script spec.execute() # Check result file self._check_result_file('csspec_py5.fits', 10) # Return return