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
def test_latlon2xyz_xyz2latlon(): """ latlon2xyz() -> xyz2latlon() : check consistency, repeat 1000 times """ from cart_ll import latlon2xyz, xyz2latlon N = 1000 for i in range(N): lat = pi * rand() - pi / 2 lon = 2 * pi * rand() X, Y, Z = latlon2xyz(lat, lon) lat2, lon2 = xyz2latlon(X, Y, Z) aa_equal((lat, lon), (lat2, lon2), 15)
def test_xyp_rotate_reverse(): ''' xyp_rotate() -> xyz_reverse_rotate() : check consistency, repeat 1000 times ''' from cart_rotate import xyz_rotate, xyz_rotate_reverse from cart_ll import latlon2xyz N = 1000 for i in xrange(N): lat = pi*rand() - pi/2 lon = 2*pi*rand() x, y, z = latlon2xyz(lat, lon) rlat = pi*rand() - pi/2 rlon = 2*pi*rand() xr, yr, zr = xyz_rotate((x, y, z), rlat, rlon) x2, y2, z2 = xyz_rotate_reverse((xr, yr, zr), rlat, rlon) aa_equal((x,y,z), (x2,y2,z2), 15)
def test_latlon2xyz(): """ latlon2xyz(): center of panel, at panel border """ from cart_ll import latlon2xyz lat, lon = 0, 0 aa_equal(latlon2xyz(lat, lon), (1, 0, 0), 15) lat, lon = -pi / 2, 0 aa_equal(latlon2xyz(lat, lon), (0, 0, -1), 15) lat, lon = pi / 2, 0 aa_equal(latlon2xyz(lat, lon), (0, 0, 1), 15) lat, lon = 0, pi / 2 aa_equal(latlon2xyz(lat, lon), (0, 1, 0), 15) lat, lon = 0, pi aa_equal(latlon2xyz(lat, lon), (-1, 0, 0), 15) lat, lon = 0, 3 * pi / 2 aa_equal(latlon2xyz(lat, lon), (0, -1, 0), 15)