def test_latlon2pix_internals(pix_size_single, origin_point, is_flipped,
num_chunks, chunk_position):
img = make_image(pix_size_single, origin_point, is_flipped,
num_chunks, chunk_position)
chunk_idx = img.chunk_idx
res_x = img._full_res[0]
res_y = img._full_res[1]
pix_size = (img.pixsize_x, img.pixsize_y)
origin = (img._start_lon, img._start_lat)
# +0.5 for centre of pixels
lons = (np.arange(res_x) + 0.5) * pix_size[0] + origin[0]
all_lats = (np.arange(res_y) + 0.5) * pix_size[1] + origin[1]
lats = np.array_split(all_lats, num_chunks)[chunk_idx]
pix_x = np.arange(res_x)
pix_y = np.arange(lats.shape[0])
d = np.array([[a, b] for a in lons for b in lats])
xy = img.lonlat2pix(d)
true_xy = np.array([[a, b] for a in pix_x for b in pix_y])
assert np.all(xy == true_xy)
评论列表
文章目录