Пример #1
0
def minimize_function(x, rho_nfw_target, rho_midplane_target,
                      density_conversion):
    """
    Computes the chi^2 penalty for a galactic potential for the purpose of finding an NFWPotential and MiyamotoNagaiPotential
    circular velocity normalization that yeild the desired midplane and nfw physical densities
    :param x: numpy array of proposed disk and nfw circular velocity normalizations (in that order)
    :param rho_nfw_target: desired nfw_normalization in physical M_sun / pc^2
    :param rho_midplane_target: desired midplane density in physical M_sun / pc^2
    :param density_conversion: a conversion factor between galpy internal density units and physical M_sun / pc^2
    :return: chi^2 penalty
    """

    galactic_potential = [
        PowerSphericalPotentialwCutoff(normalize=0.05, alpha=1.8, rc=1.9 / 8.),
        MiyamotoNagaiPotential(a=3. / 8., b=0.28 / 8., normalize=x[0]),
        NFWPotential(a=2., normalize=x[1])
    ]
    nfw_potential = NFWPotential(a=2., normalize=x[1])

    rho = evaluateDensities(galactic_potential, R=1.,
                            z=0.) * density_conversion
    rho_nfw = evaluateDensities(nfw_potential, R=1, z=0.) * density_conversion
    dx = (rho - rho_midplane_target)**2 / 0.000001**2 + (
        rho_nfw - rho_nfw_target)**2 / 0.000001**2

    return dx**0.5
Пример #2
0
    def setup(self):

        nfw_norm = [0.2, 0.4, 0.6]
        disk_norm = [0.15, 0.3, 0.45]
        scale_height = [0.25, 0.27, 0.29]
        pot_list = []

        for normnfw in nfw_norm:
            for normdisk in disk_norm:
                for scale_h in scale_height:
                    pot = [
                        PowerSphericalPotentialwCutoff(normalize=0.05,
                                                       alpha=1.8,
                                                       rc=1.9 / 8.),
                        MiyamotoNagaiPotential(a=3. / 8.,
                                               b=scale_h / 8.,
                                               normalize=normdisk),
                        NFWPotential(a=2., normalize=normnfw)
                    ]
                    pot_extension = PotentialExtension(
                        pot, 2, 120, 3, compute_action_angle=True)
                    pot_list.append(pot_extension)

        self.disk_norm = disk_norm
        self.nfw_norm = nfw_norm
        self.scale_height = scale_height
        self.pot_list = pot_list

        self.tabulated_potential = TabulatedPotential3D(
            self.pot_list, self.nfw_norm, self.disk_norm, self.scale_height)
Пример #3
0
    def setup(self):

        nfw_norm = [0.2, 0.4, 0.6]
        disk_norm = [0.15, 0.3, 0.45]
        pot_list = []

        for normnfw in nfw_norm:
            for normdisk in disk_norm:
                pot = [
                    PowerSphericalPotentialwCutoff(normalize=0.05,
                                                   alpha=1.8,
                                                   rc=1.9 / 8.),
                    MiyamotoNagaiPotential(a=3. / 8.,
                                           b=0.28 / 8.,
                                           normalize=normdisk),
                    NFWPotential(a=2., normalize=normnfw)
                ]
                pot_extension = PotentialExtension(pot, 2, 120, 10)
                pot_list.append(pot_extension)

        self.disk_norm = disk_norm
        self.nfw_norm = nfw_norm
        self.pot_list = pot_list

        self.tabulated_potential = TabulatedPotential(self.pot_list,
                                                      self.nfw_norm,
                                                      self.disk_norm)
Пример #4
0
def test_powerlawcutoff():
    from galpy.potential import PowerSphericalPotentialwCutoff

    M = 1.5854e10 * u.Msun
    alpha = 1.75
    gala_pot = PowerLawCutoffPotential(m=M, alpha=alpha, r_c=15*u.kpc,
                                       units=galactic)
    r_c = gala_pot.parameters['r_c']
    amp = (G*M).to_value(vo**2 * ro) * ((1/(2*np.pi) * r_c.to_value(ro)**(alpha - 3) / (gamma(3/2 - alpha/2))))
    bovy_pot = PowerSphericalPotentialwCutoff(amp,
                                              alpha=gala_pot.parameters['alpha'].value,
                                              rc=r_c.to_value(ro),
                                              ro=ro, vo=vo)

    helper(gala_pot, bovy_pot)
Пример #5
0
    def test_minimize_func(self):

        disk_norm, nfw_norm = solve_normalizations(self.rho_nfw_target,
                                                   self.rho_midplane_target,
                                                   self.density_conversion)

        pot = [
            PowerSphericalPotentialwCutoff(normalize=0.05,
                                           alpha=1.8,
                                           rc=1.9 / 8.),
            MiyamotoNagaiPotential(a=3. / 8., b=0.28 / 8.,
                                   normalize=disk_norm),
            NFWPotential(a=2., normalize=nfw_norm)
        ]
        rho = evaluateDensities(pot, R=1., z=0) * self.density_conversion
        npt.assert_almost_equal(rho, self.rho_midplane_target, 3)

        disk_norm, nfw_norm = solve_normalizations(self.rho_nfw_target,
                                                   self.rho_nfw_target * 0.5,
                                                   self.density_conversion)
        npt.assert_equal(True, disk_norm < 0)
Пример #6
0
    # 'main_colnames':None,     # list of names
    # 'error_colnames':None,
    # 'corr_colnames':None,
}

cart_colnames = {
    # 'main_colnames':None,
    # 'error_colnames':None,
    # 'corr_colnames':None,
}

from galpy.potential import PowerSphericalPotentialwCutoff,\
    MiyamotoNagaiPotential, NFWPotential, verticalfreq, MWPotential2014

scale_height_factor = 2.0
bp = PowerSphericalPotentialwCutoff(alpha=1.8, rc=1.9 / 8., normalize=0.05)
mp = MiyamotoNagaiPotential(a=3. / 8., b=scale_height_factor * 0.28 / 8.,
                            normalize=.6)
np = NFWPotential(a=16 / 8., normalize=.35)
my_mwpotential2014 = [bp, mp, np]
orbit = {
    'potential': my_mwpotential2014, # TC: varied params randomly...
}

special = {
    'component':'sphere',       # parameterisation for the origin
}

advanced = {
    'burnin_steps':500,        # emcee parameters, number of steps for each burnin iteraton
    'sampling_steps':500,