Skip to content

Commit 0a4db94

Browse files
committed
update grid_size
1 parent 25178d8 commit 0a4db94

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ ds = reader.read("sur_refl_b01")
6565

6666
# 进行切片操作
6767
# 假设单景大小为 1200*1200
68+
6869
# 这个切片跨越了中心图幅的右边界和下边界
6970
# mtmhdf 会自动从右侧、下方和右下方的文件中读取对应数据并拼接
7071
subset = ds[1000:1500, 1000:1500]
7172

7273
print(subset.shape)
7374
# 输出: (500, 500)
75+
76+
# 这个切片会获取中心图幅的全部数据,不会从周边数据拼接
77+
subset = ds[:]
78+
79+
print(subset.shape)
80+
# 输出: (1200, 1200)
7481
```
7582

7683
## 高级用法

src/mtmhdf/grid2dreader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __getitem__(self, item) -> np.ma.MaskedArray | np.ndarray:
8282
return res_data if res_data is not None else np.array([]).reshape(target_shape)
8383

8484
class Grid2DReader:
85-
def __init__(self, path:str, grid_format:str=None, do_grid_surround:bool=True, **kwargs):
85+
def __init__(self, path:str, grid_format:str=None, grid_size:int=1200, do_grid_surround:bool=True, **kwargs):
8686
self.path = path
8787
self.grid_format = grid_format if grid_format is not None else "modis_sin"
8888
self.file_format = inferrence_format(path)
@@ -97,7 +97,12 @@ def __init__(self, path:str, grid_format:str=None, do_grid_surround:bool=True, *
9797

9898
match self.grid_format:
9999
case "modis_sin" | "MODIS_SIN":
100-
self.tile_grid = TileGridModisSin(gcenter=self.hv, fcenter=path, do_grid_surround=do_grid_surround)
100+
self.tile_grid = TileGridModisSin(
101+
gcenter=self.hv,
102+
fcenter=path,
103+
gsize=grid_size,
104+
do_grid_surround=do_grid_surround
105+
)
101106
case _:
102107
raise ValueError(f"Unsupported grid format: {self.grid_format}")
103108

0 commit comments

Comments
 (0)