Пример #1
0
    def __init__(self, filename):
        self.filename = filename
        self.model = ModelParams(filename)
        self.particles = numpy.loadtxt(filename)[:, 0:6]
        if vel_error != 0:
            print "Assumed error of", vel_error, "km/s in velocity"
        if phase_space_info_mode <= 5:
            self.particles[:, 2] *= numpy.nan  # remove z-coordinate
        if phase_space_info_mode <= 3:
            self.particles[:, 3:5] *= numpy.nan  # remove vx and vy
        if phase_space_info_mode != 6 or vel_error != 0:
            self.samples, self.weights = sampleMissingData(
                numpy.hstack(
                    (self.particles, numpy.ones(
                        (self.particles.shape[0], 3)) * vel_error)),
                num_subsamples)

        # check if we may restart the search from already existing parameters
        try:
            self.values = numpy.loadtxt(self.filename + ".best")
            if self.values.ndim == 1:  # only one set of parameters - this occurs after the deterministic search
                self.values = self.values[:
                                          -1]  # the last column is the likelihood, strip it
            else:  # a number of MCMC walkers, each with its own set of parameters
                self.values = self.values[:, :-1]
            print "Loaded from saved file: (nwalkers,nparams)=", self.values.shape
        except:
            self.values = None
            return
Пример #2
0
    def __init__(self, filename):
        self.filename  = filename
        self.model     = ModelParams(filename)
        try:
            self.particles = numpy.loadtxt(filename)[:,0:6]
        except Exception as ex:
            print(str(ex)+"\nYou need to run this script from a directory containing files "\
                "from the Gaia Challenge spherical/triaxial mock data.")
            exit()
        if vel_error!=0:
            print("Assumed error of %f km/s in velocity" % vel_error)
        if phase_space_info_mode <= 5:
            self.particles[:,2] *= numpy.nan    # remove z-coordinate
        if phase_space_info_mode <= 3:
            self.particles[:,3:5] *= numpy.nan  # remove vx and vy
        if phase_space_info_mode != 6 or vel_error != 0:
            self.samples, self.weights = sampleMissingData(
                numpy.hstack((self.particles, numpy.ones((self.particles.shape[0], 3)) * vel_error)),
                num_subsamples )

        # check if we may restart the search from already existing parameters
        try:
            self.values = numpy.loadtxt(self.filename+".best")
            if self.values.ndim==1:   # only one set of parameters - this occurs after the deterministic search
                self.values = self.values[:-1]  # the last column is the likelihood, strip it
            else:  # a number of MCMC walkers, each with its own set of parameters
                self.values = self.values[:,:-1]
            print("Loaded from saved file: (nwalkers,nparams)=" + str(self.values.shape))
        except:
            self.values = None
            return
Пример #3
0
    #axes[1,indx].legend(loc='lower left')
    axes[1,indx].set_xlim(rmin, rmax)
    axes[1,indx].set_ylim(densmin, densmax)
    axes[1,indx].set_xlabel('$r$')
    axes[1,indx].set_ylabel(r'$\rho$')
    axes[1,indx].text( (rmin*rmax)**0.5, densmin*2, label, ha='center')


################  MAIN PROGRAM  ##################
#base     = "gs010_bs050_rcrs100_rarcinf_core_0400mpc3_df"
if len(sys.argv)<=1:
    print("Provide the data file name as the command-line argument")
    exit()
agama.setUnits(mass=1, length=1, velocity=1)
base     = sys.argv[1]
model    = ModelParams(base)
rmin     = 0.01
rmax     = 100.
velmin   = 0.
velmax   = 40.
radii    = numpy.logspace(numpy.log10(rmin), numpy.log10(rmax), 25)
midradii = (radii[1:] * radii[:-1])**0.5
xyz      = numpy.vstack((radii, numpy.zeros_like(radii), numpy.zeros_like(radii))).T

# plot the inferred density of dark matter and its log-slope as functions of radius
fig,axes = pyplot.subplots(2, 3, figsize=(12,8))
plot_profiles("6"+base+"/"+base+"_1000_0.dat",     0,  '6d, no errors')
plot_profiles("5"+base+"/"+base+"_1000_0_err.dat", 1, r'5d, $\delta v$=2 km/s')
plot_profiles("3"+base+"/"+base+"_1000_0_err.dat", 2, r'3d, $\delta v$=2 km/s')
fig.tight_layout()
pyplot.savefig(base+"_darkmatter.png")