コード例 #1
0
        # We also want to account for the shape of the masked data
        # (mostly for M31)
        # norm_mask = np.isfinite(proj_coldens).astype(np.float) / \
        #     np.isfinite(proj_coldens).sum()
        # pspec_mask = PowerSpectrum(fits.PrimaryHDU(norm_mask, proj_coldens.header),
        #                            distance=fitinfo_dict[gal]['distance'])
        # pspec_mask.run(verbose=False, beam_correct=False, fit_2D=False,
        #                high_cut=0.1 / u.pix,
        #                use_pyfftw=True, threads=ncores,
        #                apodize_kernel=fitinfo_dict[gal]['apod_kern'])

        pspec = PowerSpectrum(proj_coldens,
                              distance=fitinfo_dict[gal]['distance'])
        pspec.compute_pspec(use_pyfftw=True,
                            threads=ncores,
                            apodize_kernel=fitinfo_dict[gal]['apod_kern'])
        # Divide out the normalized mask pspec
        # pspec._ps2D /= pspec_mask.ps2D
        pspec.compute_radial_pspec()
        # pspec.fit_pspec()  # high_cut=0.1 / u.pix,)
        # pspec.run(verbose=False, beam_correct=False, fit_2D=False,
        #           high_cut=0.1 / u.pix,
        #           use_pyfftw=True, threads=ncores,
        #           apodize_kernel=fitinfo_dict[gal]['apod_kern'])

        if make_interactive:
            print(pspec.slope)
            pspec.plot_fit(show_residual=False, show_2D=True)
            plt.draw()
            input(gal)
コード例 #2
0
                continue

            # Check to see if the pspec file already exists:
            save_pspec_name = osjoin(
                pspec_posn_folder,
                f"{fitinfo_dict[gal]['filename'].rstrip('fits')}_y_{y}_x_{x}_pspec.pkl"
            )

            if not os.path.exists(save_pspec_name):

                pspec = PowerSpectrum(mom0_cutout.hdu,
                                      beam=mom0.beam,
                                      distance=fitinfo_dict[gal]['distance'])
                pspec.compute_pspec(
                    use_pyfftw=False,
                    threads=ncores,
                    apodize_kernel=fitinfo_dict[gal]['apod_kern'],
                    alpha=alpha)
                pspec.compute_radial_pspec()

                pspec.save_results(save_pspec_name)

            else:

                pspec = PowerSpectrum.load_results(save_pspec_name)
                pspec.load_beam()

            # pspec.run(high_cut=10**-1.29 / u.pix, low_cut=10**-2. / u.pix,
            #           fit_2D=True,
            #           verbose=False,
            #           # save_name=os.path.join(perposn_figfolder, "{}.png".format(out_name)),