code: def _run_simulation(gta, roi_baseline,
                          injected_name, test_sources, current_seed, seed, non_null_src):
          
          gta.load_roi('sim_baseline_%06i.npy' % current_seed)
          gta.set_random_seed(seed)
          gta.simulate_roi()
          if injected_name:
              gta.zero_source(injected_name)
  
          gta.optimize()
          gta.find_sources(sqrt_ts_threshold=5.0, search_skydir=gta.roi.skydir,
                           search_minmax_radius=[1.0, np.nan])
          gta.optimize()
          gta.free_sources(skydir=gta.roi.skydir, distance=1.0, pars='norm')
          gta.fit(covar=True)
          gta.write_roi('sim_refit_%06i' % current_seed)
  
          for test_source in test_sources:
              test_source_name = test_source['name']
              sedfile = "sed_%s_%06i.fits" % (test_source_name, seed)
              correl_dict, test_src_name = add_source_get_correlated(gta, test_source_name,
                                                                     test_source['source_model'],
                                                                     correl_thresh=0.25,
                                                                     non_null_src=non_null_src)
  
              # Write the list of correlated sources
              correl_yaml = os.path.join(gta.workdir,
                                         "correl_%s_%06i.yaml" % (test_source_name, seed))
              write_yaml(correl_dict, correl_yaml)
  
              gta.free_sources(False)
              for src_name in correl_dict.keys():
                  gta.free_source(src_name, pars='norm')
  
              gta.sed(test_source_name, prefix=pkey, outfile=sedfile)
              # Set things back to how they were
              gta.delete_source(test_source_name)
              gta.load_xml('sim_refit_%06i' % current_seed)
docs: Simulate a realization of this analysis