def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") gta = GTAnalysis(args.config, logging={'verbosity': 3}, fileio={'workdir_regex': '\.xml$|\.npy$'}) gta.setup(overwrite=False) baseline_roi_fit(gta, make_plots=args.make_plots, minmax_npred=[1e3, np.inf]) localize_sources(gta, nstep=5, dtheta_max=0.5, update=True, prefix='base', make_plots=args.make_plots) gta.find_sources(sqrt_ts_threshold=5.0, search_skydir=gta.roi.skydir, search_minmax_radius=[1.0, np.nan]) gta.optimize() gta.print_roi() gta.print_params() gta.free_sources(skydir=gta.roi.skydir, distance=1.0, pars='norm') gta.fit(covar=True) gta.print_roi() gta.print_params() gta.write_roi(args.roi_baseline, make_plots=args.make_plots)
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError("Trying to run fermipy analysis, but don't have ST") gta = GTAnalysis(args.config, logging={'verbosity': 3}, fileio={'workdir_regex': '\.xml$|\.npy$'}) gta.setup(overwrite=False) gta.free_sources(False) gta.print_roi() gta.optimize() gta.print_roi() exclude = ['3FGL J1707.8+5626'] # Localize all point sources for src in sorted(gta.roi.sources, key=lambda t: t['ts'], reverse=True): # for s in gta.roi.sources: if not src['SpatialModel'] == 'PointSource': continue if src['offset_roi_edge'] > -0.1: continue if src.name in exclude: continue if not '3FGL' in src.name: continue gta.localize(src.name, nstep=5, dtheta_max=0.5, update=True, prefix='base', make_plots=True) gta.optimize() gta.print_roi() gta.write_roi('base_roi', make_plots=True) gta.find_sources(sqrt_ts_threshold=5.0) gta.optimize() gta.print_roi() gta.print_params() gta.free_sources(skydir=gta.roi.skydir, distance=1.0, pars='norm') gta.fit() gta.print_roi() gta.print_params() gta.write_roi('fit_baseline', make_plots=True)
def main(): usage = "usage: %(prog)s [config file]" description = "Run fermipy analysis chain." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('--config', default='sample_config.yaml') parser.add_argument('--source', default=None) args = parser.parse_args() gta = GTAnalysis(args.config) if args.source is None: src_name = gta.roi.sources[0].name gta.setup() gta.optimize() loc = gta.localize(src_name, free_radius=1.0, update=True, make_plots=True) model = {'Index': 2.0, 'SpatialModel': 'PointSource'} srcs = gta.find_sources(model=model, sqrt_ts_threshold=5.0, min_separation=0.5) sed = gta.sed(src_name, free_radius=1.0, make_plots=True) gta.tsmap(make_plots=True) gta.write_roi('fit0') lc = gta.lightcurve(src_name, binsz=86400. * 7.0, free_radius=3.0, use_scaled_srcmap=True, multithread=False)
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") gta = GTAnalysis(args.config, logging={'verbosity': 3}, fileio={'workdir_regex': '\.xml$|\.npy$'}) gta.setup(overwrite=False) baseline_roi_fit(gta, make_plots=args.make_plots, minmax_npred=[1e3, np.inf]) localize_sources(gta, nstep=5, dtheta_max=0.5, update=True, prefix='base', make_plots=args.make_plots) gta.find_sources(sqrt_ts_threshold=5.0, search_skydir=gta.roi.skydir, search_minmax_radius=[1.0, np.nan]) gta.optimize() gta.print_roi() gta.print_params() gta.free_sources(skydir=gta.roi.skydir, distance=1.0, pars='norm') gta.fit(covar=True) gta.print_roi() gta.print_params() gta.write_roi(args.roi_baseline, make_plots=args.make_plots)
def main(): usage = "usage: %(prog)s [config file]" description = "Run fermipy analysis chain." parser = argparse.ArgumentParser(usage=usage,description=description) parser.add_argument('--config', default = 'sample_config.yaml') parser.add_argument('--source', default = None) args = parser.parse_args() gta = GTAnalysis(args.config) if args.source is None: src_name = gta.roi.sources[0].name gta.setup() gta.optimize() if (gta.roi[src_name]['ts'] > 1000. and gta.roi[src_name]['SpectrumType'] == 'PowerLaw'): gta.set_source_spectrum(src_name, spectrum_type='LogParabola', spectrum_pars={'beta' : {'value' : 0.0, 'scale' : 1.0, 'min' : 0.0, 'max' : 2.0}}) gta.free_source(src_name) gta.fit() gta.free_source(src_name, False) loc = gta.localize(src_name, free_radius=1.0, update=True, make_plots=True) model = {'Index' : 2.0, 'SpatialModel' : 'PointSource'} srcs = gta.find_sources(model=model, sqrt_ts_threshold=5.0, min_separation=0.5) sed = gta.sed(src_name, free_radius=1.0, make_plots=True) gta.tsmap(make_plots=True) gta.tsmap(prefix='excludeSource', exclude=[src_name], make_plots=True) gta.write_roi('fit0') lc = gta.lightcurve(src_name, binsz=86400.*28.0, free_radius=3.0, use_scaled_srcmap=True, multithread=False)
def main(): usage = "usage: %(prog)s [config file]" description = "Run fermipy analysis chain." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('--config', default='sample_config.yaml') parser.add_argument('--source', default=None) args = parser.parse_args() gta = GTAnalysis(args.config) if args.source is None: src_name = gta.roi.sources[0].name gta.setup() gta.optimize() loc = gta.localize(src_name, free_radius=1.0, update=True, make_plots=True) model = {'Index': 2.0, 'SpatialModel': 'PointSource'} srcs = gta.find_sources(model=model, sqrt_ts_threshold=5.0, min_separation=0.5) sed = gta.sed(src_name, free_radius=1.0, make_plots=True) gta.tsmap(make_plots=True) gta.write_roi('fit0') # make sure bins are shifted to line up with the end of the time window (where the neutrino arrived) tmax = 528835414 LCbins = tmax - 119 * 28 * 24 * 3600 + numpy.linspace(0, 119, 120) * 28 * 24 * 3600 lc = gta.lightcurve(src_name, time_bins=list(LCbins), free_radius=3.0, use_scaled_srcmap=True, multithread=False, shape_ts_threshold=100)
class ExtensionFit: def __init__(self, configFile): self.gta = GTAnalysis(configFile, logging={'verbosity': 3}) self.target = None self.targetRadius = None self.distance = None self.catalog = fits.getdata('/users-data/mfalxa/code/gll_psch_v13.fit', 1) def setSourceName(self, sourceObject, newName): self.gta.delete_source(sourceObject['name']) self.gta.add_source(newName, sourceObject) ''' INITIALIZE ''' def initialize(self, sizeROI, rInner, addToROI, TSMin, debug): self.gta.setup() if self.gta.config['selection']['emin'] >= 10000: self.gta.set_parameter('galdiff', 'Scale', 30000) if debug == True: self.gta.make_plots('startAll') self.gta.residmap(prefix='startAll', make_plots=True) # Get model source names sourceList = self.gta.get_sources(exclude=['isodiff', 'galdiff']) # Delete sources unassociated with TS < 50 for i in range(len(sourceList)): if sourceList[i]['catalog']['TS_value'] < TSMin and self.catalog[ 'CLASS'][self.catalog['Source_Name'] == sourceList[i] ['name']][0] == '': self.gta.delete_source(sourceList[i]['name']) closests = self.gta.get_sources(distance=rInner, exclude=['isodiff', 'galdiff']) # Delete all unidentified sources for i in range(len(closests)): if self.catalog['CLASS'][self.catalog['Source_Name'] == closests[i] ['name']][0].isupper() == False: self.gta.delete_source(closests[i]['name']) if self.catalog['CLASS'][self.catalog['Source_Name'] == closests[i] ['name']][0] == 'SFR': self.target = closests[i] self.setSourceName(self.target, 'TESTSOURCE') # If debug, save ROI and make plots if debug == True: self.gta.write_roi('startModel') self.gta.residmap(prefix='start', make_plots=True) self.gta.make_plots('start') # Optmize spectral parameters for sources with npred > 1 self.gta.optimize(npred_threshold=1, skip=['isodiff']) # Get model source names sourceList = self.gta.get_sources(distance=sizeROI + addToROI, square=True, exclude=['isodiff', 'galdiff']) # Iterate source localizing on source list for i in range(len(sourceList)): if sourceList[i].extended == False: self.gta.localize(sourceList[i]['name'], write_fits=False, write_npy=False, update=True) # Free sources within ROI size + extra distance from center self.gta.free_sources(distance=sizeROI + addToROI, square=True) # Re-optimize ROI self.gta.optimize(skip=['isodiff']) # Save and make plots if debug if debug == True: self.gta.write_roi('modelInitialized') self.gta.residmap(prefix='initialized', make_plots=True) self.gta.make_plots('initialized') # Lock sources self.gta.free_sources(free=False) ''' OUTER REGION ''' def outerRegionAnalysis(self, sizeROI, rInner, sqrtTsThreshold, minSeparation, debug): self.gta.free_sources(distance=sizeROI, pars='norm', square=True, free=True) self.gta.free_sources(distance=rInner, free=False) self.gta.free_source('galdiff', free=True) self.gta.free_source('isodiff', free=False) # Seek new sources until none are found sourceModel = { 'SpectrumType': 'PowerLaw', 'Index': 2.0, 'Scale': 30000, 'Prefactor': 1.e-15, 'SpatialModel': 'PointSource' } newSources = self.gta.find_sources(sqrt_ts_threshold=sqrtTsThreshold, min_separation=minSeparation, model=sourceModel, **{ 'search_skydir': self.gta.roi.skydir, 'search_minmax_radius': [rInner, sizeROI] }) if len(newSources) > 0: for i in range(len(newSources)): if newSources['sources'][i]['ts'] > 100.: self.gta.set_source_spectrum( newSources['sources'][i]['name'], spectrum_type='LogParabola') self.gta.free_source(newSources['sources'][i]['name']) self.gta.fit() self.gta.free_source(newSources['sources'][i]['name'], free=False) # Optimize all ROI self.gta.optimize(skip=['isodiff']) # Save sources found if debug == True: self.gta.residmap(prefix='outer', make_plots=True) self.gta.write_roi('outerAnalysisROI') self.gta.make_plots('outer') ''' INNER REGION ''' def innerRegionAnalysis(self, sizeROI, rInner, maxIter, sqrtTsThreshold, minSeparation, dmMin, TSm1Min, TSextMin, debug): self.gta.free_sources(distance=sizeROI, square=True, free=False) self.gta.free_sources(distance=rInner, free=True, exclude=['isodiff']) # Keep closest source if identified with star forming region in catalog or look for new source closest to center within Rinner if self.target != None: print('Closest source identified with star forming region : ', self.target['name']) self.gta.set_source_morphology('TESTSOURCE', **{'spatial_model': 'PointSource'}) else: closeSources = self.gta.find_sources(sqrt_ts_threshold=2., min_separation=minSeparation, max_iter=1, **{ 'search_skydir': self.gta.roi.skydir, 'search_minmax_radius': [0., rInner] }) dCenter = np.array([]) for i in range(len(closeSources['sources'])): dCenter = np.append( dCenter, self.gta.roi.skydir.separation( closeSources['sources'][i].skydir).value) self.target = closeSources['sources'][np.argmin(dCenter)] print('Target name : ', self.target['name']) self.setSourceName(self.target, 'TESTSOURCE') for i in [ x for x in range(len(closeSources['sources'])) if x != (np.argmin(dCenter)) ]: self.gta.delete_source(closeSources['sources'][i]['name']) self.gta.optimize(skip=['isodiff']) # Initialize n sources array nSources = [] # Save ROI without extension fit self.gta.write_roi('nSourcesFit') if debug == True: self.gta.make_plots('innerInit') self.gta.residmap(prefix='innerInit', make_plots=True) # Test for extension extensionTest = self.gta.extension('TESTSOURCE', make_plots=True, write_npy=debug, write_fits=debug, spatial_model='RadialDisk', update=True, free_background=True, fit_position=True) extLike = extensionTest['loglike_ext'] TSext = extensionTest['ts_ext'] print('TSext : ', TSext) extAIC = 2 * (len(self.gta.get_free_param_vector()) - self.gta._roi_data['loglike']) self.gta.write_roi('extFit') if debug == True: self.gta.residmap(prefix='ext0', make_plots=True) self.gta.make_plots('ext0') self.gta.load_roi('nSourcesFit', reload_sources=True) for i in range(1, maxIter + 1): # Test for n point sources nSourcesTest = self.gta.find_sources( sources_per_iter=1, sqrt_ts_threshold=sqrtTsThreshold, min_separation=minSeparation, max_iter=1, **{ 'search_skydir': self.gta.roi.skydir, 'search_minmax_radius': [0., rInner] }) if len(nSourcesTest['sources']) > 0: if nSourcesTest['sources'][0]['ts'] > 100.: self.gta.set_source_spectrum( nSourcesTest['sources'][0]['name'], spectrum_type='LogParabola') self.gta.free_source(nSourcesTest['sources'][0]['name']) self.gta.fit() self.gta.free_source(nSourcesTest['sources'][0]['name'], free=False) if debug == True: self.gta.make_plots('nSources' + str(i)) nSources.append(nSourcesTest['sources']) self.gta.localize(nSourcesTest['sources'][0]['name'], write_npy=debug, write_fits=debug, update=True) nAIC = 2 * (len(self.gta.get_free_param_vector()) - self.gta._roi_data['loglike']) self.gta.free_source(nSourcesTest['sources'][0]['name'], free=True) self.gta.residmap(prefix='nSources' + str(i), make_plots=True) self.gta.write_roi('n1SourcesFit') # Estimate Akaike Information Criterion difference between both models dm = extAIC - nAIC print('AIC difference between both models = ', dm) # Estimate TS_m+1 extensionTestPlus = self.gta.extension( 'TESTSOURCE', make_plots=True, write_npy=debug, write_fits=debug, spatial_model='RadialDisk', update=True, free_background=True, fit_position=True) TSm1 = 2 * (extensionTestPlus['loglike_ext'] - extLike) print('TSm+1 = ', TSm1) if debug == True: self.gta.residmap(prefix='ext' + str(i), make_plots=True) self.gta.make_plots('ext' + str(i)) if dm < dmMin and TSm1 < TSm1Min: self.gta.load_roi('extFit', reload_sources=True) break else: # Set extension test to current state and save current extension fit ROI and load previous nSources fit ROI extensionTest = extensionTestPlus extLike = extensionTestPlus['loglike_ext'] TSext = extensionTestPlus['ts_ext'] print('TSext : ', TSext) extAIC = 2 * (len(self.gta.get_free_param_vector()) - self.gta._roi_data['loglike']) self.gta.write_roi('extFit') self.gta.load_roi('n1SourcesFit', reload_sources=True) self.gta.write_roi('nSourcesFit') else: if TSext > TSextMin: self.gta.load_roi('extFit', reload_sources=True) break else: self.gta.load_roi('nSourcesFit', reload_sources=True) break self.gta.fit() # Get source radius depending on spatial model endSources = self.gta.get_sources() for i in range(len(endSources)): if endSources[i]['name'] == 'TESTSOURCE': self.target = endSources[i] self.distance = self.gta.roi.skydir.separation( endSources[i].skydir).value if endSources[i].extended == True: self.targetRadius = endSources[i]['SpatialWidth'] else: self.targetRadius = endSources[i]['pos_r95'] ''' CHECK OVERLAP ''' def overlapDisk(self, rInner, radiusCatalog): print('Target radius : ', self.targetRadius) # Check radius sizes if radiusCatalog < self.targetRadius: r = float(radiusCatalog) R = float(self.targetRadius) else: r = float(self.targetRadius) R = float(radiusCatalog) # Estimating overlapping area d = self.distance print('Distance from center : ', d) if d < (r + R): if R < (r + d): area = r**2 * np.arccos( (d**2 + r**2 - R**2) / (2 * d * r)) + R**2 * np.arccos( (d**2 + R**2 - r**2) / (2 * d * R)) - 0.5 * np.sqrt( (-d + r + R) * (d + r - R) * (d - r + R) * (d + r + R)) overlap = round((area / (np.pi * r**2)) * 100, 2) else: area = np.pi * r**2 overlap = 100.0 else: area = 0. overlap = 0. print('Overlapping surface : ', area) print('Overlap : ', overlap) if overlap > 68. and self.distance < rInner: associated = True else: associated = False return associated ''' CHECK UPPER LIMIT ''' def upperLimit(self, name, radius): sourceModel = { 'SpectrumType': 'PowerLaw', 'Index': 2.0, 'Scale': 30000, 'Prefactor': 1.e-15, 'SpatialModel': 'RadialDisk', 'SpatialWidth': radius, 'glon': self.gta.config['selection']['glon'], 'glat': self.gta.config['selection']['glat'] } self.gta.add_source(name, sourceModel, free=True) self.gta.fit() self.gta.residmap(prefix='upperLimit', make_plots=True) print('Upper limit : ', self.gta.get_sources()[0]['flux_ul95'])
fit_res = gta.optimize() #save results with 4FGL-only model gta.write_roi('fit_gtlike') cat_results = open('cat_results.txt', 'w') for s in gta.roi.sources: cat_results.write(str(s)+'\n') cat_results.close() #look for additional sources based on TS map peaks (TS>25) #average spectrum model = {'Index' : 2.2, 'SpatialModel' : 'PointSource'} find = gta.find_sources(model=model, sqrt_ts_threshold=5, min_separation=0.5, multithread = True) #hard spectrum model = {'Index' : 1.8, 'SpatialModel' : 'PointSource'} find = gta.find_sources(model=model, sqrt_ts_threshold=5, min_separation=0.5, multithread = True) #soft spectrum model = {'Index' : 2.4, 'SpatialModel' : 'PointSource'} find = gta.find_sources(model=model, sqrt_ts_threshold=5, min_separation=0.5, multithread = True) fit_res = gta.optimize() fit_res = gta.fit() #write output gta.write_roi('fit_srcfind')
def main(): usage = "usage: %(prog)s [config file]" description = "Run fermipy analysis chain." parser = argparse.ArgumentParser(usage=usage,description=description) parser.add_argument('--config', default = 'sample_config.yaml') parser.add_argument('--source', default = None) args = parser.parse_args() gta = GTAnalysis(args.config,logging={'verbosity' : 3}, fileio={'workdir_regex' : '\.xml$|\.npy$'}) gta.setup() names = [s.name for s in gta.roi.sources if not s.diffuse] gta.reload_sources(names) sqrt_ts_threshold=3 model0 = { 'SpatialModel' : 'PointSource', 'Index' : 1.5 } model1 = { 'SpatialModel' : 'PointSource', 'Index' : 2.0 } model2 = { 'SpatialModel' : 'PointSource', 'Index' : 2.5 } #src_name = gta.roi.sources[0].name if args.source is None: src_name = gta.config['selection']['target'] else: src_name = args.source # ----------------------------------- # Fit the Baseline Model # ----------------------------------- # Get a reasonable starting point for the spectral model gta.free_source(src_name) gta.fit() gta.free_source(src_name,False) gta.optimize() # Localize 3FGL sources for s in gta.roi.sources: if not s['SpatialModel'] == 'PointSource': continue if s['offset'] < 0.5 or s['ts'] < 25.: continue if s['offset_roi_edge'] > -0.1: continue gta.localize(s.name,nstep=5,dtheta_max=0.5,update=True, prefix='base') gta.free_source(s.name,False) gta.tsmap('base',model=model1) # Look for new point sources outside the inner 1.0 deg gta.find_sources('base',model=model1, search_skydir=gta.roi.skydir, max_iter=5,min_separation=0.5, sqrt_ts_threshold=sqrt_ts_threshold, search_minmax_radius=[1.0,None]) gta.optimize() gta.print_roi() gta.write_roi('base') # ----------------------------------- # Pass 0 - Source at Nominal Position # ----------------------------------- fit_region(gta,'fit0',src_name) # ------------------------------------- # Pass 1 - Source at Localized Position # ------------------------------------- gta.localize(src_name,nstep=5,dtheta_max=0.5,update=True, prefix='fit1') fit_region(gta,'fit1',src_name) fit_halo(gta,'fit1',src_name) gta.load_roi('fit1') # ------------------------------------- # Pass 2 - 2+ Point Sources # ------------------------------------- srcs = [] # Fit up to 4 sources for i in range(2,6): srcs_fit = gta.find_sources('fit%i'%i, search_skydir=gta.roi.skydir, max_iter=1, sources_per_iter=1, sqrt_ts_threshold=3, min_separation=0.5, search_minmax_radius=[None,1.0]) if len(srcs_fit['sources']) == 0: break srcs += srcs_fit['sources'] best_fit_idx = i gta.localize(src_name,nstep=5,dtheta_max=0.4, update=True,prefix='fit%i'%i) # Relocalize new sources for s in sorted(srcs, key=lambda t: t['ts'],reverse=True): gta.localize(s.name,nstep=5,dtheta_max=0.4, update=True,prefix='fit%i'%i) fit_region(gta,'fit%i'%i,src_name) fit_halo(gta,'fit%i'%i,src_name) gta.load_roi('fit%i'%i) new_source_data = [] for s in srcs: src_data = gta.roi[s.name].data new_source_data.append(copy.deepcopy(src_data)) np.save(os.path.join(gta.workdir,'new_source_data.npy'), new_source_data)
if np.abs(s['offset_glat']) > 0.5*roiwidth-0.2: continue gta.localize(s.name,nstep=5,dtheta_max=0.5,update=True, prefix='base') gta.free_source(s.name,False) gta.tsmap('base',model=model1) #gta.tsmap('base_emin40',model=model1,erange=[4.0,5.5]) # Look for new point sources outside the inner 1.0 deg gta.find_sources('base',model=model1, search_skydir=gta.roi.skydir, max_iter=4,min_separation=0.5, sqrt_ts_threshold=sqrt_ts_threshold, search_minmax_radius=[1.0,None]) gta.optimize() gta.print_roi() gta.write_roi('base') # ----------------------------------- # Pass 0 - Source at Nominal Position # ----------------------------------- fit_region(gta,'fit0',src_name) #fit_region(gta,'fit0_emin40',src_name,erange=[4.0,5.5])
def main(): usage = "usage: %(prog)s [config file]" description = "Run fermipy analysis chain." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('--config', default='sample_config.yaml') parser.add_argument('--source', default=None) args = parser.parse_args() gta = GTAnalysis(args.config, logging={'verbosity': 3}, fileio={'workdir_regex': '\.xml$|\.npy$'}) model0 = {'SpatialModel': 'PointSource', 'Index': 1.5} model1 = {'SpatialModel': 'PointSource', 'Index': 2.0} model2 = {'SpatialModel': 'PointSource', 'Index': 2.7} src_name = gta.config['selection']['target'] gta.setup(overwrite=True) gta.free_sources(False) gta.print_roi() gta.optimize() gta.print_roi() exclude = [] # Localize all point sources for s in sorted(gta.roi.sources, key=lambda t: t['ts'], reverse=True): # for s in gta.roi.sources: if not s['SpatialModel'] == 'PointSource': continue if s['offset_roi_edge'] > -0.1: continue if s.name in exclude: continue if not '3FGL' in s.name: continue if s.name == src_name: continue gta.localize(s.name, nstep=5, dtheta_max=0.5, update=True, prefix='base', make_plots=True) gta.optimize() gta.print_roi() gta.write_roi('base_roi', make_plots=True) exclude = [src_name] if not 'carina_2' in exclude: exclude += ['carina_2'] if not 'carina_3' in exclude: exclude += ['carina_3'] gta.tsmap('base', model=model0, make_plots=True, exclude=exclude) gta.residmap('base', model=model0, make_plots=True, exclude=exclude) gta.tsmap('base', model=model1, make_plots=True, exclude=exclude) gta.residmap('base', model=model1, make_plots=True, exclude=exclude) gta.tsmap('base', model=model2, make_plots=True, exclude=exclude) gta.residmap('base', model=model2, make_plots=True, exclude=exclude) gta.find_sources(sqrt_ts_threshold=5.0) gta.optimize() gta.print_roi() gta.print_params() gta.free_sources(skydir=gta.roi.skydir, distance=1.0, pars='norm') gta.fit() gta.print_roi() gta.print_params() gta.write_roi('fit0_roi', make_plots=True) m = gta.tsmap('fit0', model=model0, make_plots=True, exclude=exclude) gta.plotter.make_tsmap_plots(m, gta.roi, zoom=2, suffix='tsmap_zoom') gta.residmap('fit0', model=model0, make_plots=True, exclude=exclude) gta.tsmap('fit0', model=model1, make_plots=True, exclude=exclude) gta.plotter.make_tsmap_plots(m, gta.roi, zoom=2, suffix='tsmap_zoom') gta.residmap('fit0', model=model1, make_plots=True, exclude=exclude) gta.tsmap('fit0', model=model2, make_plots=True, exclude=exclude) gta.plotter.make_tsmap_plots(m, gta.roi, zoom=2, suffix='tsmap_zoom') gta.residmap('fit0', model=model2, make_plots=True, exclude=exclude) gta.sed(src_name, prefix='fit0', make_plots=True, free_radius=1.0) gta.free_source(src_name) gta.fit(reoptimize=True) gta.print_roi() gta.print_params() gta.write_roi('fit1_roi', make_plots=True)