def test_xyz_rotate(): ''' xyz_rotate() ''' from cart_rotate import xyz_rotate x, y, z = xyz_rotate((1,0,0), rlat=0, rlon=pi/2) aa_equal((x,y,z), (0,-1,0), 15) x, y, z = xyz_rotate((1,0,0), rlat=0, rlon=pi) aa_equal((x,y,z), (-1,0,0), 15) x, y, z = xyz_rotate((1,0,0), rlat=0, rlon=3*pi/2) aa_equal((x,y,z), (0,1,0), 15) x, y, z = xyz_rotate((1,0,0), rlat=pi/2, rlon=0) aa_equal((x,y,z), (0,0,-1), 15) x, y, z = xyz_rotate((1,0,0), rlat=-pi/2, rlon=0) aa_equal((x,y,z), (0,0,1), 15)
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_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)