Exemple #1
0
def infer_toycluster_ics(a):
    # Fit the concentration parameter and baryon fraction
    mle, cis = fit.total_gravitating_mass_freecbf(ObservedCluster(a.basedir,
                                                                  "cygA",
                                                                  verbose=True,
                                                                  data=a.data),
                                                  do_cut=a.do_cut)
    cygA = ObservedCluster(a.basedir,
                           "cygA",
                           cNFW=mle[0],
                           bf=mle[1],
                           RCUT_R200_RATIO=mle[2] if a.do_cut else None,
                           verbose=a.verbose,
                           data=a.data)

    mle, cis = fit.total_gravitating_mass_freecbf(ObservedCluster(
        a.basedir, "cygNW", verbose=False, data=a.data),
                                                  do_cut=a.do_cut)
    cygNW = ObservedCluster(a.basedir,
                            "cygNW",
                            cNFW=mle[0],
                            bf=mle[1],
                            RCUT_R200_RATIO=mle[2] if a.do_cut else None,
                            verbose=a.verbose,
                            data=a.data)

    write_ics(cygA, cygNW)

    return cygA, cygNW
Exemple #2
0
def check_twocluster_ics(a):
    cygA = ObservedCluster(a.basedir,
                           "cygA",
                           cNFW=12.40,
                           bf=0.07653,
                           data=a.data)
    cygNW = ObservedCluster(a.basedir,
                            "cygNW",
                            cNFW=5.17,
                            bf=0.05498,
                            data=a.data)
    sim = Simulation(a.basedir, a.timestamp, name="both")
    plot.twocluster_quiescent_parm(cygA, cygNW, sim, 0, parm="kT")
Exemple #3
0
def test_cnfw(a):
    for cNFW in range(1, 25, 2):
        cygA = ObservedCluster(a.basedir,
                               "cygA",
                               cNFW=cNFW,
                               verbose=a.verbose,
                               data=a.data)
        plot.inferred_nfw_profile(cygA)
        plot.inferred_temperature(cygA)
Exemple #4
0
def set_observed_cluster(a, data_only=False):
    if a.data == "2Msec":
        if a.clustername == "cygA":
            if a.do_cut:
                cNFW = 7.1801
                bf = 0.0701
                RCUT_R200_RATIO = 854.7 / 1830.6
            else:  # not sure how much I trust these results...
                cNFW = 13.0000
                bf = 0.2271
                RCUT_R200_RATIO = None

        if a.clustername == "cygNW":
            if a.do_cut:
                cNFW = 2.8680
                bf = 0.0735
                RCUT_R200_RATIO = 986.1 / 1606.6
            else:  # not sure how much I trust these results...
                cNFW = 5.0780
                bf = 0.1879
                RCUT_R200_RATIO = None

    else:
        if a.clustername == "cygA":
            if a.do_cut:
                cNFW = 10.8084913766
                bf = 0.0448823494125
                RCUT_R200_RATIO = 0.749826451566
            else:
                cNFW = 12.1616022474
                bf = 0.075207094556
                RCUT_R200_RATIO = None

        if a.clustername == "cygNW":
            if a.do_cut:
                cNFW = 3.69286089273
                bf = 0.0357979867269
                RCUT_R200_RATIO = 0.994860631699
            else:
                cNFW = 4.84194426883
                bf = 0.0535343411893
                RCUT_R200_RATIO = None

    obs = ObservedCluster(a.basedir,
                          a.clustername,
                          cNFW=cNFW,
                          bf=bf,
                          RCUT_R200_RATIO=RCUT_R200_RATIO,
                          verbose=a.verbose,
                          data=a.data,
                          data_only=data_only)

    return obs
Exemple #5
0
def plot_smac_snapshots(a):
    if a.clustername:
        print "Running for single cluster", a.clustername
        obs = ObservedCluster(a.basedir,
                              a.clustername,
                              verbose=a.verbose,
                              data=a.data)
        sim = Simulation(a.basedir, a.timestamp, a.clustername)
        for i in range(sim.nsnaps):
            # sim.find_cluster_centroids_psmac_dmrho(i)
            plot.simulated_quiescent_parm(obs, sim, i, parm="kT")
        os.chdir(sim.outdir)
        # os.system('ffmpeg -y -r 8 -i "xray_peakfind_%3d.png" -profile:v high444 -level 4.1 -c:v libx264 -preset slow -crf 25 -s "2000:2000" -an "xray-dmdensity.mp4"')
        os.system(
            'ffmpeg -y -r 8 -i "kT_cygA_%3d.png" -profile:v high444 -level 4.1 -c:v libx264 -preset slow -crf 25 -s "2000:2000" -an "kT_cygA.mp4"'
        )
        os.system(
            'ffmpeg -y -r 8 -i "tspec_%3d.png" -profile:v high444 -level 4.1 -c:v libx264 -preset slow -crf 25 -s "2000:2000" -an "tspec.mp4"'
        )
    else:
        sim = Simulation(a.basedir, a.timestamp)
Exemple #6
0
    def __init__(self, arguments, discard_firstbins=True):
        self.timestamp = arguments.simulationID[0]
        self.observed = ObservedCluster(
            arguments.clustername) if arguments.clustername else None
        if arguments.clustername and arguments.clustername == "cygA" and discard_firstbins:
            print "WARNING: Discarding first three CygA bins.\n"
            self.observed.radius = self.observed.radius[3:]
            self.observed.binsize = self.observed.binsize[3:]
            self.observed.density = self.observed.density[3:]
            self.observed.density_std = self.observed.density_std[3:]
            self.observed.number_density = self.observed.number_density[3:]
            self.observed.number_density_std = self.observed.number_density_std[
                3:]
        if arguments.IC_only:
            # TODO: there is something different in the Toycluster rho
            # than in the Gadget output :(
            self.IC_only = True
            self.icdir = "../runs/{0}/ICs/".format(self.timestamp)
            self.snapdir = "../runs/{0}/ICs/".format(self.timestamp)
            self.snaps = ["../runs/{0}/ICs/IC_single_0".format(self.timestamp)]
        else:
            self.IC_only = False
            self.icdir = "../runs/{0}/ICs/".format(self.timestamp)
            self.snapdir = "../runs/{0}/snaps/".format(self.timestamp)
            self.snaps = sorted(glob.glob(
                "../runs/{0}/snaps/snapshot_*".format(self.timestamp)),
                                key=os.path.getmtime)
            print self.snaps, "\n"

        self.outdir = "../runs/{0}/out/".format(self.timestamp)
        if not (os.path.isdir(self.outdir) or os.path.exists(self.outdir)):
            os.mkdir(self.outdir)

        if self.IC_only:
            self.TimeBetSnapshot = 0
        else:
            # For time counter
            gadgetparms = parse_gadget_parms(self.snapdir + "gadget2.par")
            self.TimeBetSnapshot = gadgetparms['TimeBetSnapshot']
Exemple #7
0
    # in Toycluster... for now. Hence, fix_cygA

    fix_cygA = False

    fit = True
    discard_firstbins = True
    discard_lastbins = False
    plot_fit = True
    poster_style = False
    mass_density = True
    save = True
    fit_toycluster = False

    print "Reading Chandra Observed Density Profiles"
    print 80 * "-"
    cygA_observed = ObservedCluster("cygA", oldICs=False)
    cygB_observed = ObservedCluster("cygB", oldICs=False)
    print cygA_observed
    print cygB_observed
    print 80 * "-"

    if fit:
        print "Obtaining parameters from observed density profiles"
        print 80 * "-"
        # Due to pile up in inner region (?). Also inside kernel: cannot model
        # in a stable way
        if discard_firstbins:
            cygA_observed.radius = cygA_observed.radius[3:]
            cygA_observed.binsize = cygA_observed.binsize[3:]
            cygA_observed.density = cygA_observed.density[3:]
            cygA_observed.density_std = cygA_observed.density_std[3:]
    arcsec2kpc = cygB.cc.kpc_DA
    pyplot.errorbar(cygB.radius / arcsec2kpc + cygB.binsize / 2,
                    cygB.number_density,
                    xerr=cygB.binsize / 2,
                    yerr=cygB.number_density_std,
                    marker="o",
                    ms=5 if poster_style else 3,
                    elinewidth=3 if poster_style else 1,
                    ls="",
                    c=data_colour[2],
                    label="CygB")

    pyplot.gca().set_xscale("log")
    pyplot.gca().set_yscale("log")
    pyplot.xlim(0.3, 2500)
    pyplot.yticks([1e-1, 1e-2, 1e-3, 1e-4])
    pyplot.ylabel(r"Number density [cm$^{-3}$]")
    pyplot.xlabel(r"Radius [arcsec]")

    pyplot.legend()
    pyplot.savefig("out/raw_observed_clusters{0}.pdf"\
        .format("_dark" if poster_style else ""), dpi=300)
    pyplot.show()


if __name__ == "__main__":
    cygA_observed_900ksec = ObservedCluster("cygA")
    cygB_observed_900ksec = ObservedCluster("cygB")

    plot_observation(cygA_observed_900ksec, cygB_observed_900ksec)
    world.halo1_numerical.get_gas_mass_via_density(DESNNGB=50)
    world.halo1_numerical.get_dm_mass_via_number_density()
    world.halo1_numerical.set_dm_density()

    mass0_filename = outdir + "{0}-mass-halo0-{1}.png".format(myRun, snapnr)
    density0_filename = outdir + "{0}-density-hal0-{1}.png".format(
        myRun, snapnr)
    temperature0_filename = outdir + "{0}-temperature-halo0-{1}.png".format(
        myRun, snapnr)
    mass1_filename = outdir + "{0}-mass-halo1-{1}.png".format(myRun, snapnr)
    density1_filename = outdir + "{0}-density-halo1-{1}.png".format(
        myRun, snapnr)
    temperature1_filename = outdir + "{0}-temperature-halo1-{1}.png".format(
        myRun, snapnr)

    observed_cygA = ObservedCluster("cygA")
    plot_individual_cluster_density(world.halo0_numerical,
                                    world.halo0_analytical, observed_cygA)

    if arguments.save:
        pyplot.savefig(density0_filename)
        pyplot.close()

    observed_cygB = ObservedCluster("cygB")
    plot_individual_cluster_density(world.halo1_numerical,
                                    world.halo1_analytical, observed_cygB)
    if arguments.save:
        pyplot.savefig(density1_filename)
        pyplot.close()

    plot_individual_cluster_mass(world.halo0_numerical, world.halo0_analytical)