code: def localize_sources(gta, **kwargs):    
      
      # 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
          
          gta.localize(src.name, **kwargs)
  
      gta.optimize()
      gta.print_roi()
docs: Relocalize sources in the region of interest
  
      Parameters
      ----------
  
      gta : `fermipy.gtaanalysis.GTAnalysis`
          The analysis object
  
      kwargs : 
          These are passed to the gta.localize function