Skip to content

models

BlockModelCommonParams

块段模型估值通用参数基类(距离幂/克里格共用)

Source code in dimine_python_sdk\lib\prospecting\models.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class BlockModelCommonParams:
    """块段模型估值通用参数基类(距离幂/克里格共用)"""
    # 基础配置
    sample_file: str  # 样品数据文件路径
    variable: str     # 估值变量(如品位字段名)
    extra_attribute: str  # 额外属性字段(如岩性、厚度等)
    # 估值范围
    min_value: float  # 估值最小值
    max_value: float  # 估值最大值
    # 块段尺寸
    single_block_min: float  # 单块最小尺寸
    single_block_max: float  # 单块最大尺寸
    sub_block_main: float    # 子块主方向尺寸
    sub_block_second: float  # 子块次方向尺寸
    sub_block_short: float   # 子块短方向尺寸
    # 角度参数
    angle_main: float  # 主方向角度(度)
    angle_second: float  # 次方向角度(度)
    angle_short: float   # 短方向角度(度)
    # 搜索半径
    main_radius: float  # 主方向搜索半径
    second_main_rate: float  # 次方向搜索半径比例(相对于主方向)
    short_main_rate: float   # 短方向搜索半径比例(相对于主方向)
    # 搜索策略
    octant_max: int  # 每个八象限最大样品数
    project_count_min: int  # 最小投影方向数量
    single_project_sample_max: int  # 单个投影方向最大样品数

    def __init__(self, sample_file: str, variable: str, extra_attribute: str,
                 min_value: float, max_value: float,
                 single_block_min: float, single_block_max: float,
                 sub_block_main: float, sub_block_second: float, sub_block_short: float,
                 angle_main: float, angle_second: float, angle_short: float,
                 main_radius: float, second_main_rate: float, short_main_rate: float,
                 octant_max: int, project_count_min: int, single_project_sample_max: int):
        # 批量赋值通用属性
        self.sample_file = sample_file
        self.variable = variable
        self.extra_attribute = extra_attribute
        self.min_value = min_value
        self.max_value = max_value
        self.single_block_min = single_block_min
        self.single_block_max = single_block_max
        self.sub_block_main = sub_block_main
        self.sub_block_second = sub_block_second
        self.sub_block_short = sub_block_short
        self.angle_main = angle_main
        self.angle_second = angle_second
        self.angle_short = angle_short
        self.main_radius = main_radius
        self.second_main_rate = second_main_rate
        self.short_main_rate = short_main_rate
        self.octant_max = octant_max
        self.project_count_min = project_count_min
        self.single_project_sample_max = single_project_sample_max

BlockModelConstraint dataclass

块段模型约束参数结构 用于定义模型计算时的边界约束、范围过滤等条件

Source code in dimine_python_sdk\lib\prospecting\models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@dataclass
class BlockModelConstraint:
    """
    块段模型约束参数结构
    用于定义模型计算时的边界约束、范围过滤等条件
    """
    type: int  # 约束类型,0 通常表示“实体约束”
    file: str  # 约束实体文件路径(如 DMF 文件)
    range: int  # 约束范围,0 表示使用完整实体范围
    inside_level: int  # 内部精度层级(控制约束的精细度)
    boundary_level: int  # 边界精度层级(控制边界的精细度)
    bool_operate: str  # 布尔运算方式,"and" 表示与其他约束叠加

    def to_dict(self) -> Dict[str, Any]:
        """
        将参数转换为字典,用于序列化为JSON
        """
        return {
            "type": self.type,
            "file": self.file,
            "range": self.range,
            "inside_level": self.inside_level,
            "boundary_level": self.boundary_level,
            "bool_operate": self.bool_operate
        }

to_dict()

将参数转换为字典,用于序列化为JSON

Source code in dimine_python_sdk\lib\prospecting\models.py
102
103
104
105
106
107
108
109
110
111
112
113
def to_dict(self) -> Dict[str, Any]:
    """
    将参数转换为字典,用于序列化为JSON
    """
    return {
        "type": self.type,
        "file": self.file,
        "range": self.range,
        "inside_level": self.inside_level,
        "boundary_level": self.boundary_level,
        "bool_operate": self.bool_operate
    }

BlockModelDistancePowerParams

Bases: BlockModelCommonParams

距离幂估值专属参数类(继承通用参数+新增距离幂特有参数)

Source code in dimine_python_sdk\lib\prospecting\models.py
62
63
64
65
66
67
68
class BlockModelDistancePowerParams(BlockModelCommonParams):
    """距离幂估值专属参数类(继承通用参数+新增距离幂特有参数)"""
    power: int  # 距离幂次(如2.0,距离幂专属)

    def __init__(self, power: int, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.power = power

BlockModelKrigingParams

Bases: BlockModelCommonParams

克里格估值专属参数类(继承通用参数+新增克里格特有参数)

Source code in dimine_python_sdk\lib\prospecting\models.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class BlockModelKrigingParams(BlockModelCommonParams):
    """克里格估值专属参数类(继承通用参数+新增克里格特有参数)"""
    krig_type: int  # 克里格类型
    sk: int         # 克里格相关参数
    c0: int         # 块金值
    variational_function: list = [{
        "type":0,
        "range":22,
        "cc":0.162586
    }]

    def __init__(self, krig_type: int, sk: int, c0: int, variational_function:dict[str,int],*args, **kwargs):
        super().__init__(*args, **kwargs)
        self.krig_type = krig_type
        self.sk = sk
        self.c0 = c0
        self.variational_function = variational_function

HighGradeProcessParam dataclass

Source code in dimine_python_sdk\lib\prospecting\models.py
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
@dataclass
class HighGradeProcessParam:
    # 特高品位处理参数
    input_file: str      # 输入文件路径(数据文件的完整路径/相对路径)
    grade_field: str     # 品位字段名(待处理的品位数据列名)
    process_mode: int    # 处理模式(0:国内特高品位判定;1:国外特高品位判定)
    average_multiple: float  # 平均倍数(品位计算的倍数系数)
    frequency: float     # 频率阈值(0-1之间)
    replace_method: int  # 替换方式(0:剔除法,1:给定值,2:相邻样品平均值,3:矿体平均品位法,4:单一工程法,5:截止品位法)
    assign_value: float  # 给定值方法对应的值
    adjoin_average: float  # 相邻样品平均值)
    average_method: int  # 平均值计算的方式,0:算数平均,1:长度加权平均
    contain_mode: int    # 包含模式(0:包含特高品位,1:不包含特高品位)
    result_field: str    # 结果字段名(处理后品位数据的输出列名)

    def __post_init__(self) -> None:
        """
        参数合法性校验
        校验失败时抛出明确的ValueError,包含非法参数名和错误原因
        """
        # 各参数的合法取值范围
        valid_ranges = {
            "process_mode": {0, 1},
            "replace_method": {0, 1, 2, 3, 4, 5},
            "average_method": {0, 1},
            "contain_mode": {0, 1}
        }

        # 1. 校验枚举型参数(只能取指定整数值)
        for param_name, valid_vals in valid_ranges.items():
            current_val = getattr(self, param_name)
            if current_val not in valid_vals:
                raise ValueError(
                    f"参数{param_name}取值非法!合法值:{sorted(valid_vals)},当前值:{current_val}"
                )

        # 2. 校验频率阈值(必须在0-1之间,包含边界)
        if not 0 <= self.frequency <= 1:
            raise ValueError(
                f"参数frequency取值非法!必须为0-1之间的数值,当前值:{self.frequency}"
            )

    def to_dict(self) -> dict:
        """将实例的所有属性转换为键值对字典,键为属性名,值为属性当前值"""
        return {
            "input_file": self.input_file,
            "grade_field": self.grade_field,
            "process_mode": self.process_mode,
            "average_multiple": self.average_multiple,
            "frequency": self.frequency,
            "replace_method": self.replace_method,
            "assign_value": self.assign_value,
            "adjoin_average": self.adjoin_average,
            "average_method": self.average_method,
            "contain_mode": self.contain_mode,
            "result_field": self.result_field
        }

__post_init__()

参数合法性校验 校验失败时抛出明确的ValueError,包含非法参数名和错误原因

Source code in dimine_python_sdk\lib\prospecting\models.py
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
def __post_init__(self) -> None:
    """
    参数合法性校验
    校验失败时抛出明确的ValueError,包含非法参数名和错误原因
    """
    # 各参数的合法取值范围
    valid_ranges = {
        "process_mode": {0, 1},
        "replace_method": {0, 1, 2, 3, 4, 5},
        "average_method": {0, 1},
        "contain_mode": {0, 1}
    }

    # 1. 校验枚举型参数(只能取指定整数值)
    for param_name, valid_vals in valid_ranges.items():
        current_val = getattr(self, param_name)
        if current_val not in valid_vals:
            raise ValueError(
                f"参数{param_name}取值非法!合法值:{sorted(valid_vals)},当前值:{current_val}"
            )

    # 2. 校验频率阈值(必须在0-1之间,包含边界)
    if not 0 <= self.frequency <= 1:
        raise ValueError(
            f"参数frequency取值非法!必须为0-1之间的数值,当前值:{self.frequency}"
        )

to_dict()

将实例的所有属性转换为键值对字典,键为属性名,值为属性当前值

Source code in dimine_python_sdk\lib\prospecting\models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
def to_dict(self) -> dict:
    """将实例的所有属性转换为键值对字典,键为属性名,值为属性当前值"""
    return {
        "input_file": self.input_file,
        "grade_field": self.grade_field,
        "process_mode": self.process_mode,
        "average_multiple": self.average_multiple,
        "frequency": self.frequency,
        "replace_method": self.replace_method,
        "assign_value": self.assign_value,
        "adjoin_average": self.adjoin_average,
        "average_method": self.average_method,
        "contain_mode": self.contain_mode,
        "result_field": self.result_field
    }

ModelTransformParams dataclass

创建空块段模型参数

Source code in dimine_python_sdk\lib\prospecting\models.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
@dataclass
class ModelTransformParams:
    """
    创建空块段模型参数
    """

    file_name: str
    # 原点
    origin_x: float
    origin_y: float
    origin_z: float
    # 旋转角度
    rotate_x: float
    rotate_y: float
    rotate_z: float
    # 单元块尺寸
    size_x: float
    size_y: float
    size_z: float
    # 延伸长度
    length_x: float
    length_y: float
    length_z: float

    def to_dict(self) -> Dict[str, Any]:
        """
        将参数转换为字典,用于序列化为JSON
        """
        return {
            "file_name": self.file_name,
            "origin_x": self.origin_x,
            "origin_y": self.origin_y,
            "origin_z": self.origin_z,
            "rotate_x": self.rotate_x,
            "rotate_y": self.rotate_y,
            "rotate_z": self.rotate_z,
            "size_x": self.size_x,
            "size_y": self.size_y,
            "size_z": self.size_z,
            "length_x": self.length_x,
            "length_y": self.length_y,
            "length_z": self.length_z
        }

to_dict()

将参数转换为字典,用于序列化为JSON

Source code in dimine_python_sdk\lib\prospecting\models.py
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
def to_dict(self) -> Dict[str, Any]:
    """
    将参数转换为字典,用于序列化为JSON
    """
    return {
        "file_name": self.file_name,
        "origin_x": self.origin_x,
        "origin_y": self.origin_y,
        "origin_z": self.origin_z,
        "rotate_x": self.rotate_x,
        "rotate_y": self.rotate_y,
        "rotate_z": self.rotate_z,
        "size_x": self.size_x,
        "size_y": self.size_y,
        "size_z": self.size_z,
        "length_x": self.length_x,
        "length_y": self.length_y,
        "length_z": self.length_z
    }

ReservesCalculateParam dataclass

估值算量参数

Source code in dimine_python_sdk\lib\prospecting\models.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@dataclass
class ReservesCalculateParam:
    """估值算量参数"""
    weight_field:str#体重字段
    default_weight:float#默认体重
    main_field:str#主统计字段
    other_field:str#其他统计字段

    def to_dict(self) -> Dict[str, Any]:
        """
        将参数转换为字典,用于序列化为JSON
        """
        return {
            "weight_field":self.weight_field,
            "default_weight": self.default_weight,
            "main_field": self.main_field,
            "other_field": self.other_field
        }

to_dict()

将参数转换为字典,用于序列化为JSON

Source code in dimine_python_sdk\lib\prospecting\models.py
123
124
125
126
127
128
129
130
131
132
def to_dict(self) -> Dict[str, Any]:
    """
    将参数转换为字典,用于序列化为JSON
    """
    return {
        "weight_field":self.weight_field,
        "default_weight": self.default_weight,
        "main_field": self.main_field,
        "other_field": self.other_field
    }

SampleLengthCombineParam dataclass

Source code in dimine_python_sdk\lib\prospecting\models.py
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
@dataclass
class SampleLengthCombineParam:#样长组合参数
    input_file:str#输入文件
    combine_length:float#组合长度
    combine_percent:float#组合百分比
    output_file:str#输出文件

    def to_dict(self) -> Dict[str, Any]:
        """
        将参数转换为字典,用于序列化为JSON
        """
        return {
            "input_file": self.input_file,
            "combine_length": self.combine_length,
            "combine_percent": self.combine_percent,
            "output_file": self.output_file
        }

to_dict()

将参数转换为字典,用于序列化为JSON

Source code in dimine_python_sdk\lib\prospecting\models.py
185
186
187
188
189
190
191
192
193
194
def to_dict(self) -> Dict[str, Any]:
    """
    将参数转换为字典,用于序列化为JSON
    """
    return {
        "input_file": self.input_file,
        "combine_length": self.combine_length,
        "combine_percent": self.combine_percent,
        "output_file": self.output_file
    }

StepCombineParam dataclass

Source code in dimine_python_sdk\lib\prospecting\models.py
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@dataclass
class StepCombineParam:#台阶组合参数
    input_file:str#输入文件
    step_height:float#台阶高度
    start_height:float#开始高程
    end_height:float#结束高程
    calculate_model:int#计算方式
    low_dip:float#忽略的最小倾角
    output_file:str#输出文件

    def to_dict(self) -> Dict[str, Any]:
        """
        将参数转换为字典,用于序列化为JSON
        """
        return {
            "input_file": self.input_file,
            "step_height": self.step_height,
            "start_height": self.start_height,
            "end_height": self.end_height,
            "calculate_model": self.calculate_model,
            "low_dip": self.low_dip,
            "output_file": self.output_file
        }

to_dict()

将参数转换为字典,用于序列化为JSON

Source code in dimine_python_sdk\lib\prospecting\models.py
206
207
208
209
210
211
212
213
214
215
216
217
218
def to_dict(self) -> Dict[str, Any]:
    """
    将参数转换为字典,用于序列化为JSON
    """
    return {
        "input_file": self.input_file,
        "step_height": self.step_height,
        "start_height": self.start_height,
        "end_height": self.end_height,
        "calculate_model": self.calculate_model,
        "low_dip": self.low_dip,
        "output_file": self.output_file
    }