def Runsrcprob(config): config['space']['rad'] = config['srcprob']['rad'] Obs = Observation(config['out'], config, tag="srcprob") _log("Summary") Obs.printSum() if config['srcprob']['FitsGeneration'] =='yes': _log("Select data") Obs.FirstCut() if config['analysis']['ComputeDiffrsp'] == 'yes': _log("Compute diffuse responses") Obs.DiffResps() _log("Run gtsrcprob") Obs.SrcProb() probfile=fits.open(Obs.Probfile) srclist = open(config['srcprob']['srclist'],"r").readlines() for src in srclist: proba = probfile[1].data.field(string.split(src)[0]) energy = probfile[1].data.field("ENERGY") ra = probfile[1].data.field("RA") dec = probfile[1].data.field("DEC") time = probfile[1].data.field("TIME") indices = energy.argsort() mes = Loggin.Message() mes.info( "Results sorted by decreasing energy") Print(indices,config,ra,dec,proba,energy,time) print mes.info( "Results sorted by decreasing probability") indices = proba.argsort() Print(indices,config,ra,dec,proba,energy,time)
def AppLC(infile): '''Main function of the apperture photometrie Lightcurve script. Read the config file and run the analysis''' ROOT.gROOT.SetBatch(ROOT.kTRUE) #Batch mode enricodir = environ.DIRS.get('ENRICO_DIR') fermidir = environ.DIRS.get('FERMI_DIR') config = get_config(infile) folder = config['out'] #Create a subfolder name LightCurve LCoutfolder = folder + "/" + AppLCPath os.system("mkdir -p " + LCoutfolder) #Change the ROI to the desired radius in degree, legacy 1 deg. try: config['space']['rad'] = config['AppLC']['rad'] except NameError: config['space']['rad'] = 1 Nbins = config['AppLC']['NLCbin'] #Number of bins #Get The time bin dt = (config['time']['tmax'] - config['time']['tmin']) / Nbins #sec Obs = Observation(LCoutfolder, config, tag="") if config['AppLC']["FitsGeneration"] == "yes": _log('gtselect', 'Select data from library') #run gtselect Obs.FirstCut() Obs.SelectEvents() _log('gtmktime', 'Update the GTI and cut data based on ROI') #run gtdiffresp Obs.MkTime() #Binning from data or using a fix bin size if config['AppLC']['binsFromData'] == "no": _log('gtbin', 'bin the data into a light-curve using fixe time bin' ) #run gtbin print "Use a dt of %2.2e seconds" % (dt) Obs.GtLCbin(dt=dt) else: spfile = pyfits.open(Obs.eventfile) diff = spfile[1].data.field(9)[1:-1] - spfile[1].data.field(9)[:-2] dt = np.min( diff ) / 2. ##Compute the delta T as being the min delta t between 2 events divided by 2 timefile = LCoutfolder + "/Timebin.txt" MakeTimebinFile(Obs, timefile) _log('gtbindef', 'define de bins') #run gtbindef Obs.GtBinDef(timefile) _log('gtbin', 'bin the data into a light-curve using bins based on data' ) #run gtbin Obs.GtLCbin(dt=0) _log('gtexposure', 'compute the exposure') #run gtexposure Obs.GtExposure() #Get Some usefull value here. This allow PlotAppLC to be call independently Nbins = config['AppLC']['NLCbin'] #Number of bins #Plot the results and dump into ascii files PlotAppLC(Nbins, LCoutfolder, Obs.lcfile)