示例#1
0
  def test_hubble_parameter_1s( self ):

    expected = 75.71*3.24078e-20

    actual = astro.hubble_parameter( 0.16946, .702, 0.272, 0.728, units='1/s' )

    npt.assert_allclose( expected, actual, rtol=1e-4 )
示例#2
0
  def test_hubble_parameter( self ):

    expected = 75.71

    actual = astro.hubble_parameter( 0.16946, .702, 0.272, 0.728 )

    npt.assert_allclose( expected, actual, rtol=1e-4 )
示例#3
0
    def test_hubble_z(self):

        self.t_data.redshift = np.array([0., 0.0698467, 0.16946])

        expected = np.array([
            astro.hubble_parameter(redshift, units='km/s/kpc')
            for redshift in self.t_data.redshift
        ])
        actual = self.t_data.hubble_z
        npt.assert_allclose(expected, actual)
示例#4
0
    def get_radial_velocity( self ):
        '''Get the radial velocity of particles, relative to the main galaxy.

        Returns:
            v_r ( [n_particle, n_snap] np.ndarray ) : The radial velocity of
            each particle at that redshift, relative to the main galaxy.
        '''

        # Get the position and velocity of the main galaxy
        main_mt_halo_p = self.ahf_reader.get_pos_or_vel(
            'pos', self.ptrack_attrs[ 'main_mt_halo_id' ], self.ptrack[ 'snum' ]
        )
        main_mt_halo_v = self.ahf_reader.get_pos_or_vel(
            'vel', self.ptrack_attrs[ 'main_mt_halo_id' ], self.ptrack[ 'snum' ]
        )

        # Apply cosmological corrections to the position of the main galaxy
        main_mt_halo_p *= 1. / \
            ( 1. + self.ptrack['redshift'][:, np.newaxis] ) / \
            self.ptrack_attrs['hubble']

        # Loop over each redshift
        v_r = []
        for i in range(self.n_snap):

            v = self.ptrack['V'][:, i] - main_mt_halo_v[i][np.newaxis]
            p = self.ptrack['P'][:, i] - main_mt_halo_p[i][np.newaxis]

            r_i = np.sqrt( ( p**2. ).sum( axis=1 ) )

            v_r_i = ( v * p ).sum( axis=1 )/r_i

            # Add the hubble flow.
            hubble_factor = astro_tools.hubble_parameter(
                self.ptrack['redshift'][i],
                h=self.ptrack_attrs['hubble'],
                omega_matter=self.ptrack_attrs['omega_matter'],
                omega_lambda=self.ptrack_attrs['omega_lambda'],
                units='1/s'
            )
            v_r_i += hubble_factor * r_i * constants.UNITLENGTH_IN_CM / \
                constants.UNITVELOCITY_IN_CM_PER_S

            v_r.append( v_r_i )

        # Format the output
        v_r = np.array( v_r ).transpose()

        return v_r