Example #1
0
 def test_1d_freeze(self):
     """
     Simple test of 1d freezing.
     """
     # This case is easy, phi should just not change.
     xx = dadi.Numerics.default_grid(30)
     phi_orig = dadi.PhiManip.phi_1D(xx)
     phi_frozen = one_pop(phi_orig, xx, T=0.1, nu=0.1, gamma=0.2, 
                          frozen=True)
     self.assert_(numpy.allclose(phi_frozen, phi_orig, rtol=1e-6))
 def test_1d_freeze(self):
     """
     Simple test of 1d freezing.
     """
     # This case is easy, phi should just not change.
     xx = dadi.Numerics.default_grid(30)
     phi_orig = dadi.PhiManip.phi_1D(xx)
     phi_frozen = one_pop(phi_orig,
                          xx,
                          T=0.1,
                          nu=0.1,
                          gamma=0.2,
                          frozen=True)
     self.assert_(numpy.allclose(phi_frozen, phi_orig, rtol=1e-6))
Example #3
0
    def test_2d_freeze_marginal(self):
        """
        Test marginal spectra from 2d freezing
        """
        xx = dadi.Numerics.default_grid(30)
        phi = dadi.PhiManip.phi_1D(xx)
        phi = one_pop(phi, xx, T=0.2, nu=0.1)
        phi_orig = dadi.PhiManip.phi_1D_to_2D(xx, phi)
        phi_frozen1 = two_pops(phi_orig, xx, T=0.1, nu2=0.3, gamma2=0.5,
                               frozen1=True)
        phi_frozen2 = two_pops(phi_orig, xx, T=0.1, nu1=0.2, gamma1=0.3, 
                               frozen2=True)
        phi_decouple = two_pops(phi_orig, xx, T=0.1, nu1=0.2, gamma1=0.3, 
                                nu2=0.3, gamma2=0.5)
        
        phi_orig_just1 = dadi.PhiManip.remove_pop(phi_orig, xx, 2)
        phi_orig_just2 = dadi.PhiManip.remove_pop(phi_orig, xx, 1)
        phi_frozen1_just1 = dadi.PhiManip.remove_pop(phi_frozen1, xx, 2)
        phi_frozen1_just2 = dadi.PhiManip.remove_pop(phi_frozen1, xx, 1)
        phi_frozen2_just1 = dadi.PhiManip.remove_pop(phi_frozen2, xx, 2)
        phi_frozen2_just2 = dadi.PhiManip.remove_pop(phi_frozen2, xx, 1)
        phi_decouple_just1 = dadi.PhiManip.remove_pop(phi_decouple, xx, 2)
        phi_decouple_just2 = dadi.PhiManip.remove_pop(phi_decouple, xx, 1)

        # Checks that if I freeze a population, the marginal spectrum
        # for that population does not change during integration.
        self.assert_(numpy.allclose(phi_orig_just1[1:-1], 
                                    phi_frozen1_just1[1:-1], 
                                    rtol=1e-4))
        self.assert_(numpy.allclose(phi_orig_just2[1:-1], 
                                    phi_frozen2_just2[1:-1], 
                                    rtol=1e-4))

        # Checks that if I freeze a population, the other population
        # continues to evolve as if decoupled from frozen population.
        # These tests are much less precise than those above, becaue
        # my integration scheme doesn't explicitly decouple the populations.
        self.assert_(numpy.allclose(phi_frozen2_just1[1:-1], 
                                    phi_decouple_just1[1:-1], 
                                    rtol=5e-2))
        self.assert_(numpy.allclose(phi_frozen1_just2[1:-1], 
                                    phi_decouple_just2[1:-1], 
                                    rtol=5e-2))