crop_topography是 gempy.core.grid_modules.topography.Topography 模块中的一个函数,用于裁剪地形数据。
crop_topography(extent: Tuple[float, float, float, float]) -> Tuple[np.ndarray, af.Quantity]
extent: 裁剪范围,是一个包含四个浮点数的元组 (xmin, ymin, xmax, ymax)。一个元组 (cropped_topo, cropped_extent):
cropped_topo: 裁剪后的地形数据(numpy array格式)。cropped_extent: 裁剪出来的范围(Quantity格式,单位是米)。import gempy as gp
model = gp.create_model('my_model')
geo_data = gp.init_data(
    extent=[0, 1000, 0, 1000, 0, 1000],
    resolution=[10, 10, 10],
)
geo_data.add_topography(
    source='random',
    elevation=-500
)
gp.map_stack_to_surfaces(geo_data, {"my_series": "basement"})
gp.set_interpolator(model)
# 获取完整地形数据
full_topo, full_extent = geo_data._get_topography(model.cs)[0][:2]
# 裁剪地形数据
extent = (100, 100, 500, 500)
cropped_topo, cropped_extent = gp.core.grid_modules.topography.Topography.crop_topography(extent)
# 显示原始和裁剪后的范围
gp.plot_2d(
    geo_data,
    extent=extent,
    plot_type=None,
    show=False
)
gp.plot_2d(
    geo_data,
    extent=cropped_extent.m,
    plot_type=None,
    show=True
)
在上面这个例子中,crop_topography函数被用于裁剪地形数据,裁剪的范围是(100, 100, 500, 500)。裁剪出来的地形数据存储在 cropped_topo 变量中,裁剪出来的范围存储在 cropped_extent 变量中。最后,分别在裁剪前和裁剪后的范围内绘制地形数据。