예제 #1
0
def test_displace_eccentricity():
    #x, y = np.array([1, 0]), np.array([0, 1])
    x, y = util.make_grid(numPix=10, deltapix=1)
    e1 = 0.1  #.1
    e2 = -0  #.1
    center_x, center_y = 0, 0
    x_, y_ = param_util.transform_e1e2_product_average(x,
                                                       y,
                                                       e1,
                                                       e2,
                                                       center_x=center_x,
                                                       center_y=center_y)

    phi_G, q = param_util.ellipticity2phi_q(e1, e2)
    x_shift = x - center_x
    y_shift = y - center_y

    cos_phi = np.cos(phi_G)
    sin_phi = np.sin(phi_G)
    print(cos_phi, sin_phi)

    xt1 = cos_phi * x_shift + sin_phi * y_shift
    xt2 = -sin_phi * x_shift + cos_phi * y_shift
    xt1 *= np.sqrt(q)
    xt2 /= np.sqrt(q)
    npt.assert_almost_equal(x_, xt1, decimal=8)
    npt.assert_almost_equal(y_, xt2, decimal=8)

    x, y = np.array([1, 0]), np.array([0, 1])
    e1 = 0.1  #.1#.1
    e2 = 0
    center_x, center_y = 0, 0
    x_, y_ = param_util.transform_e1e2_product_average(x,
                                                       y,
                                                       e1,
                                                       e2,
                                                       center_x=center_x,
                                                       center_y=center_y)

    phi_G, q = param_util.ellipticity2phi_q(e1, e2)
    x_shift = x - center_x
    y_shift = y - center_y

    cos_phi = np.cos(phi_G)
    sin_phi = np.sin(phi_G)
    print(cos_phi, sin_phi)

    xt1 = cos_phi * x_shift + sin_phi * y_shift
    xt2 = -sin_phi * x_shift + cos_phi * y_shift
    xt1 *= np.sqrt(q)
    xt2 /= np.sqrt(q)
    npt.assert_almost_equal(x_, xt1, decimal=8)
    npt.assert_almost_equal(y_, xt2, decimal=8)
예제 #2
0
    def function_split(self, x, y, amp, sigma, e1, e2, center_x=0, center_y=0):
        """
        split surface brightness in individual components

        :param x: coordinate on the sky
        :param y: coordinate on the sky
        :param amp: list of amplitudes of individual Gaussian profiles
        :param sigma: list of widths of individual Gaussian profiles
        :param e1: eccentricity modulus
        :param e2: eccentricity modulus
        :param center_x: center of profile
        :param center_y: center of profile
        :return: list of arrays of surface brightness
        """
        x_, y_ = param_util.transform_e1e2_product_average(
            x, y, e1, e2, center_x, center_y)
        f_list = []
        for i in range(len(amp)):
            f_list.append(
                self.gaussian.function(x_,
                                       y_,
                                       amp[i],
                                       sigma[i],
                                       center_x=0,
                                       center_y=0))
        return f_list
예제 #3
0
    def function(self, x, y, amp, sigma, e1, e2, center_x=0, center_y=0):
        """
        surface brightness per angular unit

        :param x: coordinate on the sky
        :param y: coordinate on the sky
        :param amp: list of amplitudes of individual Gaussian profiles
        :param sigma: list of widths of individual Gaussian profiles
        :param e1: eccentricity modulus
        :param e2: eccentricity modulus
        :param center_x: center of profile
        :param center_y: center of profile
        :return: surface brightness at (x, y)
        """
        x_, y_ = param_util.transform_e1e2_product_average(
            x, y, e1, e2, center_x, center_y)

        f_ = np.zeros_like(x)
        for i in range(len(amp)):
            f_ += self.gaussian.function(x_,
                                         y_,
                                         amp[i],
                                         sigma[i],
                                         center_x=0,
                                         center_y=0)
        return f_
예제 #4
0
    def function(self, x, y, amp, gamma, e1, e2, center_x=0, center_y=0):
        """

        :param x: ra-coordinate
        :param y: dec-coordinate
        :param amp: amplitude of flux
        :param gamma: projected power-law slope
        :param e1: ellipticity
        :param e2: ellipticity
        :param center_x: center
        :param center_y: center
        :return: projected flux
        """
        x_, y_ = param_util.transform_e1e2_product_average(x, y, e1, e2, center_x, center_y)
        P2 = x_ ** 2 + y_ ** 2
        if isinstance(P2, int) or isinstance(P2, float):
            a = max(0.00000001, P2)
        else:
            a = np.empty_like(P2)
            p2 = P2[P2 > 0]  # in the SIS regime
            a[P2 == 0] = 0.00000001
            a[P2 > 0] = p2

        sigma = amp * a ** ((1. - gamma)/2.)
        return sigma
예제 #5
0
    def get_distance_from_center(self, x, y, e1, e2, center_x, center_y):
        """
        Get the distance from the center of Sersic, accounting for orientation and axis ratio
        :param x:
        :param y:
        :param e1: eccentricity
        :param e2: eccentricity
        :param center_x: center x of sersic
        :param center_y: center y of sersic
        """

        if self._sersic_major_axis:
            phi_G, q = param_util.ellipticity2phi_q(e1, e2)
            x_shift = x - center_x
            y_shift = y - center_y
            cos_phi = np.cos(phi_G)
            sin_phi = np.sin(phi_G)
            xt1 = cos_phi * x_shift + sin_phi * y_shift
            xt2 = -sin_phi * x_shift + cos_phi * y_shift
            xt2difq2 = xt2 / (q * q)
            r = np.sqrt(xt1 * xt1 + xt2 * xt2difq2)
        else:
            x_, y_ = param_util.transform_e1e2_product_average(
                x, y, e1, e2, center_x, center_y)
            r = np.sqrt(x_**2 + y_**2)
        return r
예제 #6
0
    def function(self, x, y, amp, sigma, e1, e2, center_x=0, center_y=0):
        """

        :param x:
        :param y:
        :param sigma0:
        :param a:
        :param s:
        :param center_x:
        :param center_y:
        :return:
        """
        x_, y_ = param_util.transform_e1e2_product_average(x, y, e1, e2, center_x, center_y)
        return self.gaussian.function(x_, y_, amp, sigma, center_x=0, center_y=0)
예제 #7
0
    def function(self, x, y, amp, sigma, e1, e2, center_x=0, center_y=0):
        """

        :param x: coordinate on the sky
        :param y: coordinate on the sky
        :param amp: amplitude, such that 2D integral leads to this value
        :param sigma: sigma of Gaussian in each direction
        :param e1: eccentricity modulus
        :param e2: eccentricity modulus
        :param center_x: center of profile
        :param center_y: center of profile
        :return: surface brightness at (x, y)
        """
        x_, y_ = param_util.transform_e1e2_product_average(x, y, e1, e2, center_x, center_y)
        return self.gaussian.function(x_, y_, amp, sigma, center_x=0, center_y=0)
예제 #8
0
def test_transform_e1e2():
    e1 = 0.01
    e2 = 0.
    x = 0.
    y = 1.
    x_, y_ = param_util.transform_e1e2_product_average(x,
                                                       y,
                                                       e1,
                                                       e2,
                                                       center_x=0,
                                                       center_y=0)
    x_new = (1 - e1) * x - e2 * y
    y_new = -e2 * x + (1 + e1) * y
    det = np.sqrt((1 - e1) * (1 + e1) + e2**2)
    npt.assert_almost_equal(x_, x_new / det, decimal=5)
    npt.assert_almost_equal(y_, y_new / det, decimal=5)
예제 #9
0
    def function(self, x, y, amp, sigma, e1, e2, center_x=0, center_y=0):
        """

        :param x:
        :param y:
        :param sigma0:
        :param a:
        :param s:
        :param center_x:
        :param center_y:
        :return:
        """
        x_, y_ = param_util.transform_e1e2_product_average(x, y, e1, e2, center_x, center_y)

        f_ = np.zeros_like(x)
        for i in range(len(amp)):
            f_ += self.gaussian.function(x_, y_, amp[i], sigma[i], center_x=0, center_y=0)
        return f_
예제 #10
0
    def function(self, x, y, amp, e1, e2, s_scale, center_x=0, center_y=0):
        """

        :param x: x-coordinate
        :param y: y-coordinate
        :param amp: surface brightness normalization
        :param e1: eccentricity component
        :param e2: eccentricity component
        :param s_scale: smoothing scale (square averaged of minor and major axis)
        :param center_x: center of profile
        :param center_y: center of profile
        :return: surface brightness of NIE profile
        """
        # phi_G, q = param_util.ellipticity2phi_q(e1, e2)
        # s = s_scale * np.sqrt((1 + q ** 2) / (2 * q ** 2))
        x__, y__ = param_util.transform_e1e2_product_average(
            x, y, e1, e2, center_x, center_y)
        f_ = amp / 2. * (s_scale**2 + x__**2 + y__**2)**(-1. / 2)
        return f_
예제 #11
0
    def function(self, x, y, amp, radius, e1, e2, center_x, center_y):
        """

        :param x:
        :param y:
        :param amp:
        :param radius:
        :param e1:
        :param e2:
        :param center_x:
        :param center_y:
        :return:
        """
        x_, y_ = param_util.transform_e1e2_product_average(
            x, y, e1, e2, center_x, center_y)
        r2 = x_**2 + y_**2
        flux = np.zeros_like(x)
        flux[r2 <= radius**2] = 1
        A = np.pi * radius**2
        return amp / A * flux
예제 #12
0
    def function(self, x, y, amp, radius, e1, e2, center_x, center_y):
        """

        :param x:
        :param y:
        :param amp: surface brightness within the ellipsoid
        :param radius: radius (product average of semi-major and semi-minor axis) of the ellipsoid
        :param e1: eccentricity
        :param e2: eccentricity
        :param center_x: center
        :param center_y: center
        :return: surface brightness
        """
        x_, y_ = param_util.transform_e1e2_product_average(
            x, y, e1, e2, center_x, center_y)
        r2 = x_**2 + y_**2
        flux = np.zeros_like(x)
        flux[r2 <= radius**2] = 1
        area = np.pi * radius**2
        return amp / area * flux
예제 #13
0
 def function_split(self, x, y, amp, sigma, e1, e2, center_x=0, center_y=0):
     x_, y_ = param_util.transform_e1e2_product_average(x, y, e1, e2, center_x, center_y)
     f_list = []
     for i in range(len(amp)):
         f_list.append(self.gaussian.function(x_, y_, amp[i], sigma[i], center_x=0, center_y=0))
     return f_list