fix: 加快竞对信号和采样点生成

This commit is contained in:
nixevol
2026-10-15 16:03:29 +08:00
parent 6227cef264
commit 609b1e39b8
5 changed files with 52 additions and 30 deletions
+9
View File
@@ -176,6 +176,15 @@ def pixel_center_mask_for_geometry(geometry, window, minx, maxy, pixel_width, pi
return np.asarray(shapely.contains_xy(geometry, x_grid, y_grid), dtype=bool)
def pixel_center_mask_for_bounds(bounds, window, minx, maxy, pixel_width, pixel_height):
"""轴对齐矩形的像元中心判断。边界上的中心点不算在内,和多边形 contains 一致。"""
row_start, row_stop, col_start, col_stop = window
geom_minx, geom_miny, geom_maxx, geom_maxy = bounds
cols = minx + (np.arange(col_start, col_stop, dtype=np.float64) + 0.5) * pixel_width
rows = maxy - (np.arange(row_start, row_stop, dtype=np.float64) + 0.5) * pixel_height
return ((rows > geom_miny) & (rows < geom_maxy))[:, None] & ((cols > geom_minx) & (cols < geom_maxx))[None, :]
def pixel_window_from_point(x, y, minx, maxy, pixel_width, pixel_height, width, height):
col = int((x - minx) / pixel_width)
row = int((maxy - y) / pixel_height)