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 test_latlon2xyp_xyp2latlon():
    '''
    latlon2xyp() -> xyp2latlon() : check consistency, repeat 1000 times
    '''
    from cs_ll import latlon2xyp, xyp2latlon


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

    for i in range(N):
        lat = pi*rand() - pi/2
        lon = 2*pi*rand()

        xyp_dict = latlon2xyp(lat, lon)

        for panel, (x,y) in xyp_dict.items():
            lat2, lon2 = xyp2latlon(x, y, panel)
            aa_equal((lat,lon), (lat2,lon2), 12)
Exemplo n.º 3
0
def test_latlon2xyp():
    '''
    latlon2xyp(): center of panel, at panel border
    '''
    from cs_ll import latlon2xyp, xyp2latlon

    R = 1
    a = R/sqrt(3)
    rlat, rlon = 0, 0

    #------------------------------------------------
    # center of panel
    #------------------------------------------------
    xyp_dict = latlon2xyp(0, 0, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [1])
    aa_equal(list(xyp_dict.values()), [(0,0)], 15)

    xyp_dict = latlon2xyp(0, pi/2, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [2])
    aa_equal(list(xyp_dict.values()), [(0,0)], 15)

    xyp_dict = latlon2xyp(0, pi, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [3])
    aa_equal(list(xyp_dict.values()), [(0,0)], 15)

    xyp_dict = latlon2xyp(0, 3*pi/2, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [4])
    aa_equal(list(xyp_dict.values()), [(0,0)], 15)

    xyp_dict = latlon2xyp(-pi/2, 0, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [5])
    aa_equal(list(xyp_dict.values()), [(0,0)], 15)

    xyp_dict = latlon2xyp(pi/2, 0, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [6])
    aa_equal(list(xyp_dict.values()), [(0,0)], 15)


    #------------------------------------------------
    # at the panel border
    #------------------------------------------------
    alpha = pi/4
    r_cos, r_sin = R*cos(alpha), R*sin(alpha)
    at = a*tan(alpha)

    xyp_dict = latlon2xyp(0, pi/4, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [1,2])
    aa_equal(list(xyp_dict.values()), [(at,0), (-at,0)], 15)

    xyp_dict = latlon2xyp(0, 3*pi/4, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [2,3])
    aa_equal(list(xyp_dict.values()), [(at,0), (-at,0)], 15)

    xyp_dict = latlon2xyp(0, 5*pi/4, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [3,4])
    aa_equal(list(xyp_dict.values()), [(at,0), (-at,0)], 15)

    xyp_dict = latlon2xyp(0, 7*pi/4, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [1,4])
    aa_equal(list(xyp_dict.values()), [(-at,0), (at,0)], 15)

    xyp_dict = latlon2xyp(-pi/4, pi/2, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [2,5])
    aa_equal(list(xyp_dict.values()), [(0,-at), (at,0)], 15)

    xyp_dict = latlon2xyp(pi/4, pi/2, rlat, rlon)
    a_equal(list(xyp_dict.keys()), [2,6])
    aa_equal(list(xyp_dict.values()), [(0,at), (at,0)], 15)