该函数用于修改Surface实例对象的属性值。
参数:
surfaces: Surface实例或Surface实例组成的列表,需修改其属性值。property_name: 字符串,要修改的属性名称。可选值包括 values、points、orientations、series、color。new_values: 根据 property_name 指定属性的新值。若为修改 values 属性,则为numpy.ndarray类型;若为修改 points、orientations 属性,则为包含numpy.ndarray数组的列表;若为修改 series、color 属性,则为python对象或字符串类型。返回值:
没有返回值。
使用示例:
# 导入相关库,创建Surface对象并初始化
import gempy as gp
import numpy as np
geo_model = gp.create_model('Modify_surface_values')
gp.init_data(geo_model, [0, 10., 0, 10., 0, 10.], [50, 50, 50])
# 创建Surface对象
surfaces = gp.create_surfaces([1, 5])
# 修改values属性
new_values = np.array([2, 4])
gp.modify_surface_values(surfaces, 'values', new_values)
# 修改points属性
new_points = [np.array([[1,1,1], [1,1,2]]), np.array([[2,2,2], [2,2,3]])]
gp.modify_surface_values(surfaces, 'points', new_points)
# 修改orientations属性
new_orientations = [np.array([[1,1,1], [1,0,0]]), np.array([[0,0,1], [1,1,1]])]
gp.modify_surface_values(surfaces, 'orientations', new_orientations)
# 修改series属性
new_series = 'New Series'
gp.modify_surface_values(surfaces, 'series', new_series)
# 修改color属性
new_color = 'red'
gp.modify_surface_values(surfaces, 'color', new_color)
注意事项:
surfaces 与 property_name 的长度要一致,否则将抛出异常。new_values 的长度与 surfaces 的长度不同时,将使用 broadcast 自动拓展,确保两者长度一致。但需确保两者可拓展,否则将抛出异常。color 属性修改时支持的字符串包括 "red"、"blue"、"green"、"purple"、"orange"、"yellow"。或使用RGBA格式,如 "(255, 0, 0, 1)" 表示红色。