overwrite=True) hp.write_map(f"outputs/map_rms_median_{nside}.fits", median_rms, overwrite=True) hp.write_map(f"outputs/map_error_mean_{nside}.fits", mean_error, overwrite=True) hp.write_map(f"outputs/map_error_median_{nside}.fits", median_error, overwrite=True) else: mean_rms = hp.read_map(f"outputs/map_rms_mean_{nside}.fits", verbose=False) median_rms = hp.read_map(f"outputs/map_rms_median_{nside}.fits", verbose=False) mean_error = hp.read_map(f"outputs/map_error_mean_{nside}.fits", verbose=False) median_error = hp.read_map(f"outputs/map_error_median_{nside}.fits", verbose=False) plot_lotss_map(map_n, title="Counts") plot_lotss_map(msk_pt*1.+msk_p*1.+msk_d*1., title="Low-res masks") plot_lotss_map(mean_error, title='Error mean', max=0.35, unit='mJy/beam') plot_lotss_map(median_error, title='Error median', max=0.35, unit='mJy/beam') plot_lotss_map(mean_rms, title='RMS mean', max=0.35, unit='mJy/beam') plot_lotss_map(median_rms, title='RMS median', max=0.35, unit='mJy/beam') plt.show()
npoint_good[is_good] += 1 ivar_good[is_good] += inv_noivar # Make total mask and write to file msk_all = np.zeros(npix_hi, dtype=bool) msk_all[npoint_all > 0] = 1 msk_good = np.zeros(npix_hi, dtype=bool) msk_good[npoint_good > 0] = 1 hp.write_map(pt.prefix_out + f'hp{nside_hi}_mask.fits.gz', msk_all, overwrite=True) hp.write_map(pt.prefix_out + f'hp{nside_hi}_npoint.fits.gz', npoint_all, overwrite=True) hp.write_map(pt.prefix_out + f'hp{nside_hi}_ivar.fits.gz', ivar_all, overwrite=True) hp.write_map(pt.prefix_out + f'hp{nside_hi}_mask_good.fits.gz', msk_good, overwrite=True) hp.write_map(pt.prefix_out + f'hp{nside_hi}_ivar_good.fits.gz', ivar_good, overwrite=True) hp.write_map(pt.prefix_out + f'hp{nside_hi}_npoint_good.fits.gz', npoint_good, overwrite=True) # Plot plot_lotss_map(npoint_all) plot_lotss_map(msk_all) plot_lotss_map(ivar_all) plot_lotss_map(npoint_good) plot_lotss_map(msk_good) plot_lotss_map(ivar_good) plt.show()
cl = cls[p] nl = nls[p] clth = cls_th[p] pp = get_ppair_name(p, p) err = np.sqrt(np.diag(covs[pp])) plt.errorbar(l_eff, cl, yerr=err, fmt='r.', label=r'Data') plt.plot(l_arr, clth, 'k-', label='Cov. model') if not np.all(nl == 0): plt.plot(l_eff, nl, 'g--', label='Noise bias') plt.loglog() plt.xlim([0.9 * l_eff[0], 1.1 * l_eff[-1]]) plt.xlabel(r'$\ell$', fontsize=14) plt.ylabel(r'$C_\ell^{%s}$' % p, fontsize=14) plt.legend(loc='upper right') fname = os.path.join(args.output_dir, f'cl_{p}.png') plt.savefig(fname, bbox_inches='tight') for f in fields: n = f.name k = f.kind ut.plot_lotss_map(f.mp, title=f'Map {n}') plt.savefig(os.path.join(args.output_dir, f'map_{k}.png'), bbox_inches='tight') ut.plot_lotss_map(f.msk, title=f'Mask {n}') plt.savefig(os.path.join(args.output_dir, f'mask_{k}.png'), bbox_inches='tight') plt.show() if args.verbose: print('Success!')
ll, nll, cll = np.loadtxt('data/nlkk.dat', unpack=True) ll = ll.astype(int) cl = np.zeros(ll[-1] + 1) cl[ll[0]:] = cll nl = np.zeros(ll[-1] + 1) nl[ll[0]:] = nll wl = (cl - nl) / np.maximum(cl, np.ones_like(cl) * 1E-10) alm_planck = hp.almxfl(alm_planck, wl) map_planck = hp.alm2map(alm_planck, nside, verbose=False) map_delta = f.mp #alm_delta = hp.map2alm(map_delta) #alm_delta = hp.almxfl(alm_delta, wl) #map_delta = hp.alm2map(alm_delta, nside, verbose=False) ut.plot_lotss_map(map_planck * mask_lofar * mask_planck, mask=mask_lofar * mask_planck, title=r'$\kappa$', fname='plots/kappa.pdf') ut.plot_lotss_map(p_map0p1, mask=mask_lofar, title=r'Depth, $I_{\rm cut}=0.1\,{\rm MJy}$', fname='plots/depth_0p1.pdf') ut.plot_lotss_map(p_map2, mask=mask_lofar, title=r'Depth, $I_{\rm cut}=2\,{\rm MJy}$', fname='plots/depth_2p0.pdf') ut.plot_lotss_map(temp_deproj, mask=mask_lofar, title=r'Pointing noise variations', fname='plots/ivar.pdf') ut.plot_lotss_map(f.msk, title=r'LOFAR mask', fname='plots/mask.pdf') ut.plot_lotss_map(map_delta,
flux_all = np.concatenate([flux_all, flux]) flux_signal_all = np.concatenate([flux_signal_all, flux_signal]) print(i, len(ra_all)) hdu = fits.BinTableHDU.from_columns([ fits.Column(name='RA', format='D', array=ra_all), fits.Column(name='DEC', format='D', array=dec_all), fits.Column(name='Flux_true', format='D', array=flux_signal_all), fits.Column(name='Flux', format='D', array=flux_all) ]) hdu.writeto("outputs/random.fits", overwrite=True) plt.figure() plt.hist(np.log10(flux_signal_all), bins=100, density=True, color='b', histtype='step') plt.hist(np.log10(flux_all), bins=100, density=True, color='y', histtype='step') ip_lo = hp.ang2pix(nside_lo, np.radians(90 - dec_all), np.radians(ra_all)) m = np.bincount(ip_lo, minlength=npix_lo) plot_lotss_map(map_rms) plot_lotss_map(m) plt.show()
default=2., type=float, help='Flux threshold (default: 2)') parser.add_option('--snr', dest='snr', default=5, type=int, help='S/N threshold (default: 5)') (o, args) = parser.parse_args() if o.use_median: meanmed = 'median' else: meanmed = 'mean' fname_out = "outputs/p_map_rms_" + meanmed + ("_Imin%.3lf.fits" % o.I_thr) fname_rms = "outputs/map_rms_" + meanmed + "_%d.fits" % (o.nside) # Read mask and rms map map_rms = hp.read_map(fname_rms, verbose=False) # Read and initialize PDF fpdf = FluxPDF() # Compute probability map p_map = fpdf.compute_p_map(o.snr, map_rms, o.I_thr) hp.write_map(fname_out, p_map, overwrite=True) plot_lotss_map(p_map) plt.show()