Exemplo n.º 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))
Exemplo n.º 2
0
def xyp2latlon(x, y, panel, rotate_lat=RLAT, rotate_lon=RLON, R=1):
    xyz = xyp2xyz(x, y, panel)
    xr, yr, zr = xyz_rotate_reverse(xyz, rotate_lat, rotate_lon)
    lat, lon = xyz2latlon(xr, yr, zr, R)

    """
    print 'x=%.18f, y=%.18f'%(x,y)
    print 'x=%.18f, y=%.18f, z=%.18f'%xyz
    print 'xr=%.18f, yr=%.18f, zr=%.18f'%(xr,yr,zr)
    print 'lat=%.18f, lon=%.18f'%(lat,lon)
    """

    return (lat, lon)
Exemplo n.º 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)
Exemplo n.º 4
0
def test_xyp2xyz():
    '''
    xyp2xyz(): center of panel, at panel border
    '''
    from cart_cs import xyp2xyz

    R = 1
    a = R/sqrt(3)


    #------------------------------------------------
    # center of panel
    #------------------------------------------------
    x, y, panel = 0, 0, 1
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (1,0,0))

    x, y, panel = 0, 0, 2
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (0,1,0))

    x, y, panel = 0, 0, 3
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (-1,0,0))

    x, y, panel = 0, 0, 4
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (0,-1,0))

    x, y, panel = 0, 0, 5
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (0,0,-1))

    x, y, panel = 0, 0, 6
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (0,0,1))


    #------------------------------------------------
    # at the panel border
    #------------------------------------------------
    alpha = pi/4

    x, y, panel = a*tan(alpha), 0, 1
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (R*cos(alpha), R*sin(alpha), 0))

    x, y, panel = a*tan(alpha), 0, 2
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (-R*sin(alpha), R*cos(alpha), 0))

    x, y, panel = 0, -a*tan(alpha), 2
    (X, Y, Z) = xyp2xyz(x, y, panel)
    aa_equal((X,Y,Z), (0, R*sin(alpha), -R*cos(alpha)), 15)


    x, y, panel = a*tan(alpha), 0, 3
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (-R*cos(alpha), -R*sin(alpha), 0))

    x, y, panel = a*tan(alpha), 0, 4
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (R*sin(alpha), -R*cos(alpha), 0))

    x, y, panel = a*tan(alpha), 0, 5
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (0, R*sin(alpha), -R*cos(alpha)))

    x, y, panel = a*tan(alpha), 0, 6
    (X, Y, Z) = xyp2xyz(x, y, panel)
    a_equal((X,Y,Z), (0, R*sin(alpha), R*cos(alpha)))