Exemplo n.º 1
0
    def test_draw_light_PJaffe(self):
        lightProfile = LightProfile(profile_list=['PJAFFE'])
        kwargs_profile = [{'sigma0': 1., 'Rs': 0.5, 'Ra': 0.2}]
        r_list = lightProfile.draw_light_2d(kwargs_profile, n=50000)
        bins = np.linspace(0, 1, 10)
        hist, bins_hist = np.histogram(r_list, bins=bins, normed=True)
        light2d = lightProfile.light_2d(R=(bins_hist[1:] + bins_hist[:-1]) /
                                        2.,
                                        kwargs_list=kwargs_profile)
        light2d *= (bins_hist[1:] + bins_hist[:-1]) / 2.
        light2d /= np.sum(light2d)
        hist /= np.sum(hist)
        #print light2d / hist
        npt.assert_almost_equal(light2d[4] / hist[4], 1, decimal=2)

        lightProfile = LightProfile(profile_list=['PJAFFE'],
                                    kwargs_numerics={
                                        'min_interpolate': 0.0001,
                                        'max_interpolate': 20.
                                    })
        kwargs_profile = [{'sigma0': 1., 'Rs': 0.04, 'Ra': 0.02}]
        r_list = lightProfile.draw_light_2d(kwargs_profile, n=50000)
        bins = np.linspace(0., 0.1, 10)
        hist, bins_hist = np.histogram(r_list, bins=bins, normed=True)
        light2d = lightProfile.light_2d(R=(bins_hist[1:] + bins_hist[:-1]) /
                                        2.,
                                        kwargs_list=kwargs_profile)
        light2d *= (bins_hist[1:] + bins_hist[:-1]) / 2.
        light2d /= np.sum(light2d)
        hist /= np.sum(hist)
        print light2d / hist
        npt.assert_almost_equal(light2d[4] / hist[4], 1, decimal=2)
Exemplo n.º 2
0
 def test_draw_light(self):
     lightProfile = LightProfile(profile_list=['HERNQUIST'])
     kwargs_profile = [{'sigma0': 1., 'Rs': 0.8}]
     r_list = lightProfile.draw_light_2d(kwargs_profile, n=100000)
     bins = np.linspace(0., 1, 20)
     hist, bins_hist = np.histogram(r_list, bins=bins, normed=True)
     light2d = lightProfile.light_2d(R=(bins_hist[1:] + bins_hist[:-1]) /
                                     2.,
                                     kwargs_list=kwargs_profile)
     light2d *= (bins_hist[1:] + bins_hist[:-1]) / 2.
     light2d /= np.sum(light2d)
     hist /= np.sum(hist)
     print light2d / hist
     for i in range(len(hist)):
         print bins_hist[i], i, light2d[i] / hist[i]
         npt.assert_almost_equal(light2d[i] / hist[i], 1, decimal=1)