-5.0, 5) #Set prior on background (assumes Gaussian pdf with mu and sigma) pind = np.arange(0, n_size) #*(1.0/radim_pixsize) prior.set_prf(prf.array, pind, pind) prior.get_pointing_matrix() prior.upper_lim_map() print('fitting ' + str(prior.nsrc) + ' sources \n') print('using ' + str(prior.snpix) + ' pixels') from xidplus.numpyro_fit import LOFAR150 fit = LOFAR150.LOFAR_150(prior, num_samples=1000, num_warmup=1000) samples = fit.get_samples()['src_f'] posterior = xidplus.posterior_numpyro(fit, [prior]) if os.path.exists( 'data/xidplus_results/pybdsf/xidplus_run_{}'.format(n)) == True: () else: os.mkdir('data/xidplus_results/pybdsf/xidplus_run_{}'.format(n)) xidplus.save( [prior], posterior, 'data/xidplus_results/pybdsf/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.pkl' .format(n, n)) LOFAR_cat = cat.create_LOFAR_cat(posterior, prior, 0) LOFAR_cat = Table.read(LOFAR_cat)
def test_all_bands(self): fit=SPIRE.all_bands(self.priors) fit.print_summary() posterior_numpyro=xidplus.posterior_numpyro(fit,self.priors) self.assertAlmostEqual(np.mean(posterior_numpyro.samples['bkg']),np.mean(self.posterior.samples['bkg']),places=0)
p.moc = moc p.cut_down_prior() p.prior_bkg(0.0, 5) p.get_pointing_matrix() p.upper_lim_map() print('fitting ' + str(priors[0].nsrc) + ' sources \n') print('there are ' + str(priors[0].snpix) + ' pixels') print('fitting tile:' + str(tiles[taskid - 1]) + ' order: ' + str(order) + ' of ' + str(len(tiles)) + ' tiles') from xidplus.numpyro_fit import SPIRE fit = SPIRE.all_bands(priors, num_chains=4) posterior = xidplus.posterior_numpyro(fit, priors) outfile = output_folder + 'Tile_' + str(tiles[taskid - 1]) + '_' + str(order) posterior = xidplus.posterior_stan(fit, priors) xidplus.save(priors, posterior, outfile) post_rep_map = postmaps.replicated_maps(priors, posterior, nrep=2000) band = ['psw', 'pmw', 'plw'] for i, p in enumerate(priors): Bayesian_Pval = postmaps.make_Bayesian_pval_maps(priors[i], post_rep_map[i]) wcs_temp = wcs.WCS(priors[i].imhdu) ra, dec = wcs_temp.wcs_pix2world(priors[i].sx_pix, priors[i].sy_pix, 0) kept_pixels = np.array( moc_routines.sources_in_tile([tiles[taskid - 1]], order, ra, dec))
pind160=np.arange(0,radius160+1+radius160,1)*3600*np.abs(pacs160_psf[1].header['CDELT1'])/pixsize160 #get 160 scale in terms of pixel scale of map prior100.set_prf(pacs100_psf[1].data[centre100-radius100:centre100+radius100+1,centre100-radius100:centre100+radius100+1]/1000.0, pind100,pind100) prior160.set_prf(pacs160_psf[1].data[centre160-radius160:centre160+radius160+1,centre160-radius160:centre160+radius160+1]/1000.0, pind160,pind160) prior100.get_pointing_matrix() prior160.get_pointing_matrix() from xidplus.numpyro_fit import PACS fit=PACS.all_bands([prior100,prior160]) posterior=xidplus.posterior_numpyro(fit,[prior100,prior160]) priors = [prior100,prior160] import xidplus.catalogue as cat PACS_cat=cat.create_PACS_cat(posterior,priors[0],priors[1]) PACS_cat = Table.read(PACS_cat) mask = [PACS_cat['help_id'][i] in ids for i in range(len(PACS_cat))] PACS_cat = PACS_cat[mask] if os.path.exists('data/fir/PACS/v2_numpyro/xidplus_run_{}'.format(taskid))==True:() else: os.mkdir('data/fir/PACS/v2_numpyro/xidplus_run_{}'.format(taskid)) xidplus.save([prior100,prior160],posterior,'data/fir/PACS/v2_numpyro/xidplus_run_{}/lofar_xidplus_fir_{}'.format(taskid,taskid)) #the next couple of lines are an alternative way to save astropy table since the Table.write method is currently broken