예제 #1
0
def print_low_accuracy():
    '''
    xyp -> latlon -> xyp: low accuracy
    '''
    from cs_ll import latlon2xyp, xyp2latlon
    from cart_ll import latlon2xyz, xyz2latlon
    from cart_cs import xyp2xyz, xyz2xyp


    #------------------------------------------------
    # at the panel border, low_accuracy
    #------------------------------------------------
    xyp1 = (-0.57735026918962606, -0.53747283769483301, 1)
    xyp2 = (-0.57735026918962495, -0.53747283769483301, 1)

    latlon1 = xyp2latlon(*xyp1)
    latlon2 = xyp2latlon(*xyp2)
    xyp1_dict = latlon2xyp( *xyp2latlon(*xyp1) )
    xyp2_dict = latlon2xyp( *xyp2latlon(*xyp2) )

    print('')
    print(repr(latlon1))
    print(repr(latlon2))
    print(repr(xyp1_dict[1]))
    print(repr(xyp2_dict[1]))

    #a_equal(xyp1_dict.keys(), [1,4])
    #a_equal(xyp2_dict.keys(), [1,4])


    xyz1 = xyp2xyz(*xyp1)
    xyz2 = xyp2xyz(*xyp2)
    xyp1_list = xyz2xyp(*xyz1)
    xyp2_list = xyz2xyp(*xyz2)
    print('')
    print(repr(xyz1))
    print(repr(xyz2))
    print(repr(xyp1_dict[1]), xyp1_dict.keys())
    print(repr(xyp2_dict[1]), xyp1_dict.keys())


    a = 1/np.sqrt(3)
    at1, at2 = a*np.tan(-np.pi/4), a*np.tan(np.pi/4) 
    print('')
    print(repr(at1), repr(at2))
예제 #2
0
파일: cs_ll.py 프로젝트: wbkifun/my_stuff
def latlon2xyp(lat, lon, rotate_lat=RLAT, rotate_lon=RLON, R=1):
    """
    (x,y,panel): gnomonic projection of rotated cubed-sphere coordinates
                 with (rotate_lat, rorate_lon)
    return {panel:(x,y), ...}
    """

    xyz = latlon2xyz(lat, lon, R)
    xr, yr, zr = xyz_rotate(xyz, rotate_lat, rotate_lon)
    xyp_dict = xyz2xyp(xr, yr, zr)

    return xyp_dict
예제 #3
0
def test_xyp2xyz_xyz2xyp():
    '''
    xyp2xyz() -> xyz2xyp() : check consistency, repeat 1000 times
    '''
    from cart_cs import xyp2xyz, xyz2xyp


    N = 1000
    R = 1
    a = R/sqrt(3)

    for i in xrange(N):
        panel = randint(1,7)
        alpha, beta = (pi/2)*rand(2) - pi/4
        x, y = a*tan(alpha), a*tan(beta)

        (X, Y, Z) = xyp2xyz(x, y, panel)
        xyp_dict = xyz2xyp(X,Y,Z)

        aa_equal((x,y), xyp_dict[panel], 15)
예제 #4
0
def test_xyz2xyp():
    '''
    xyz2xyp(): center of panel, at panel border
    '''
    from cart_cs import xyz2xyp

    R = 1
    a = R/sqrt(3)


    #------------------------------------------------
    # center of panel
    #------------------------------------------------
    xyp_dict = xyz2xyp(1, 0, 0)
    a_equal(xyp_dict, {1:(0.0,0)})

    xyp_dict = xyz2xyp(0, 1, 0)
    a_equal(xyp_dict, {2:(0,0)})

    xyp_dict = xyz2xyp(-1, 0, 0)
    a_equal(xyp_dict, {3:(0,0)})

    xyp_dict = xyz2xyp(0, -1, 0)
    a_equal(xyp_dict, {4:(0,0)})

    xyp_dict = xyz2xyp(0, 0, -1)
    a_equal(xyp_dict, {5:(0,0)})

    xyp_dict = xyz2xyp(0, 0, 1)
    a_equal(xyp_dict, {6:(0,0)})


    #------------------------------------------------
    # at the panel border
    #------------------------------------------------
    alpha = pi/4
    at = a*tan(alpha)

    xyp_dict = xyz2xyp(R*cos(alpha), R*sin(alpha), 0)
    a_equal(xyp_dict.keys(), [1,2])
    aa_equal(xyp_dict.values(), [(at,0), (-at,0)], 15)

    xyp_dict = xyz2xyp(-R*sin(alpha), R*cos(alpha), 0)
    a_equal(xyp_dict.keys(), [2,3])
    aa_equal(xyp_dict.values(), [(at,0), (-at,0)], 15)

    xyp_dict = xyz2xyp(-R*cos(alpha), -R*sin(alpha), 0)
    a_equal(xyp_dict.keys(), [3,4])
    aa_equal(xyp_dict.values(), [(at,0), (-at,0)], 15)

    xyp_dict = xyz2xyp(R*sin(alpha), -R*cos(alpha), 0)
    a_equal(xyp_dict.keys(), [1,4])
    aa_equal(xyp_dict.values(), [(-at,0), (at,0)], 15)

    xyp_dict = xyz2xyp(0, R*sin(alpha), -R*cos(alpha))
    a_equal(xyp_dict.keys(), [2,5])
    aa_equal(xyp_dict.values(), [(0,-at), (at,0)], 15)

    xyp_dict = xyz2xyp(0, R*sin(alpha), R*cos(alpha))
    a_equal(xyp_dict.keys(), [2,6])
    aa_equal(xyp_dict.values(), [(0,at), (at,0)], 15)