input("?") plt.savefig(plot_savename) plot_savename = osjoin( plot_folder, "{0}.pspec_wbeam_traceplot.pdf".format( filename.rstrip(".fits"))) plt.savefig(plot_savename) plt.close() # OneD spectrum by itself plt.figure(figsize=(4.2, 2.9)) phys_freqs = pspec._spatial_freq_unit_conversion( pspec.freqs, u.pc**-1).value phys_scales = 1 / phys_freqs plt.loglog(phys_scales, pspec.ps1D, 'k', zorder=-10) beam_amp = 10**(max(out[0][0], out[0][2]) - 1.) plt.loglog(phys_scales[fit_mask], fit_model(freqs, *out[0]), 'r--', linewidth=3, label='Fit') plt.loglog(phys_scales[fit_mask], beam_amp * beam_model(freqs), 'r:',
# os.system("rm -f {}".format(osjoin(data_path, 'raw', save_name))) pspec = PowerSpectrum(proj) # , distance=dist) pspec.run(verbose=False, beam_correct=False, fit_2D=False, high_cut=0.1 / u.pix, use_pyfftw=False, threads=1,) # apodize_kernel=fitinfo_dict[name]['apod_kern']) # Plot 2D spec, 1D pspec, img im0 = ax[0].imshow(np.log10(pspec.ps2D), origin='lower', cmap='viridis') fig.colorbar(im0, ax=ax[0]) # Convert to angular units xunit = u.arcsec**-1 ang_freqs = pspec._spatial_freq_unit_conversion(pspec.freqs, xunit).value ax[1].loglog(ang_freqs, pspec.ps1D) ax[1].set_xlabel("Spat freq (1/arcsec)") ax[1].set_title(name) major = fitinfo_dict[name]['beam'].major.to(u.arcsec) ax[1].axvline(1 / major.value, linestyle='--', color='k') im2 = ax[2].imshow(proj.value, origin='lower', cmap='viridis', vmax=np.nanpercentile(proj.value, 99), vmin=np.nanpercentile(proj.value, 10)) fig.colorbar(im2, ax=ax[2]) one_ax.loglog(ang_freqs, pspec.ps1D, label=name) one_ax.set_xlabel("Spat freq (1/arcsec)")
fit_pspec_model(freqs, ps1D, ps1D_stddev, beam_model=beam_model, nsamp=nsamp, fixB=fixB, noise_term=noise_term) print(out) tr_plot = pm.traceplot(trace) corn_plot = pm.pairplot(trace) fig = plt.figure(figsize=(8.4, 2.9)) phys_freqs = pspec_sat._spatial_freq_unit_conversion( pspec_sat.freqs, u.pc**-1).value phys_scales = 1 / phys_freqs # Saturated HI pspec w/fit ax = fig.add_subplot(121) ax.loglog(phys_scales, pspec_sat.ps1D, 'k', zorder=-10) beam_amp = 10**(max(out[0][0], out[0][2]) - 1.) ax.loglog(phys_scales[fit_mask], fit_model(freqs, *out[0]), 'r--', linewidth=3, label='Fit')
plot_folder, "{0}_spire500.deproj.pspec_wbeam_traceplot.png".format(gal)) plt.savefig(plot_savename) plt.close() # (2) Both power-spectra with their respective fits. plt.figure(figsize=(4.2, 2.9)) phys_freqs = pspec._spatial_freq_unit_conversion(pspec.freqs, u.pc**-1).value phys_scales = 1 / phys_freqs phys_freqs_dep = pspec_dep._spatial_freq_unit_conversion( pspec_dep.freqs, u.pc**-1).value phys_scales_dep = 1 / phys_freqs_dep plt.loglog(phys_scales, pspec.ps1D, 'k', zorder=-10, label='Original') plt.loglog(phys_scales_dep, pspec_dep.ps1D, 'k--', zorder=-10, label='Deprojected') # beam_amp = 10**(max(out[0][0], out[0][2]) - 1.) logA = fit_results['logA'][-2] ind = fit_results['ind'][-2] pars = [logA, ind]