api
lib.prospecting — 勘探/储量模块
BlockDataError
Bases: RuntimeError
块段模型操作异常基类
Source code in dimine_python_sdk\lib\prospecting\block_model.py
45 46 47 | |
BlockModelCommonParams
Bases: ParamModel
块段模型估值通用参数基类(距离幂/克里格共用)
Source code in dimine_python_sdk\lib\prospecting\models.py
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 | |
BlockModelCreateError
Bases: BlockDataError
创建块段模型失败
Source code in dimine_python_sdk\lib\prospecting\block_model.py
55 56 57 | |
BlockModelDistancePowerParams
Bases: BlockModelCommonParams
距离幂估值专属参数类(继承通用参数+新增距离幂特有参数)
Source code in dimine_python_sdk\lib\prospecting\models.py
40 41 42 43 | |
BlockModelEvaluator
块段模型估值与储量计算器
所有方法接受块段模型文件路径,失败时抛出自定义异常(不返回 tuple):
evaluator = BlockModelEvaluator()
result = evaluator.distance_power_evaluation(
"model.dmb", constraint, idw_params
)
# result -> {"success": True, "message": "..."}
Raises:
| Type | Description |
|---|---|
BlockModelEvaluationError
|
估值失败 |
ReservesCalculateError
|
储量计算失败 |
Source code in dimine_python_sdk\lib\prospecting\block_model.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
calculate_reserves(block_model_file, constraint_params, reserve_params)
staticmethod
储量计算
Source code in dimine_python_sdk\lib\prospecting\block_model.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
distance_power_evaluation(block_model_file, constraint_params, evaluation_params, overwrite_result=True)
staticmethod
距离幂估值计算
Source code in dimine_python_sdk\lib\prospecting\block_model.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
kriging_evaluation(block_model_file, constraint_params, evaluation_params, overwrite_result=True)
staticmethod
克里格估值计算
Source code in dimine_python_sdk\lib\prospecting\block_model.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
BlockModelKrigingParams
Bases: BlockModelCommonParams
克里格估值专属参数类(继承通用参数+新增克里格特有参数)
Source code in dimine_python_sdk\lib\prospecting\models.py
46 47 48 49 50 51 52 53 54 55 | |
BlockModelLoadError
Bases: BlockDataError
加载块段模型失败
Source code in dimine_python_sdk\lib\prospecting\block_model.py
50 51 52 | |
CreateBlockModelParams
Bases: ParamModel
创建空块段模型参数,即 注意:为什么没有输入文件,因为这只是创建空块段模型,只需要矿体包围盒范围即可
Source code in dimine_python_sdk\lib\prospecting\models.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
DTMConstraint
Bases: ParamModel
DTM 约束 (type=1):基于 DTM 模型的上部/下部空间约束
Source code in dimine_python_sdk\lib\prospecting\models.py
76 77 78 79 80 81 82 83 84 85 86 | |
DmBlockData
块段模型管理器
管理单个块段模型的加载与属性访问。所有几何数据属性直接返回, 无需 getter 前缀:
block = DmBlockData("model.dmb")
origin = block.origin # np.ndarray
xyz_len = block.xyz_length # list[float]
max_level = block.max_level # int
fc = block.field_definitions # list[dict]
total = block.total_block_count # int
# 遍历块段数据
for data in block.iter_blocks("品位"):
print(data)
静态方法(无需实例化): result = DmBlockData.create_block_model(params) DmBlockData.block_constrain_to_dmc_file(block_file, constraint, output)
Source code in dimine_python_sdk\lib\prospecting\block_model.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 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 | |
field_definitions
property
字段定义列表
max_level
property
模型最大精度层级
min_size
property
最小块段尺寸
origin
property
模型原点坐标
rotation
property
模型旋转角度
total_block_count
property
块段总数量
xyz_length
property
模型 X/Y/Z 方向总长度
__init__(file_path=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | None
|
块段模型文件路径。为 None 时需手动调用 open() |
None
|
Source code in dimine_python_sdk\lib\prospecting\block_model.py
114 115 116 117 118 119 120 121 | |
block_constrain_to_dmc_file(block_model_file, constrain_params, constrain_result_file)
staticmethod
块约束保存到约束结果 dmc 文件
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_model_file
|
str
|
块段模型文件路径 |
required |
constrain_params
|
list[BlockModelConstraintItem] | BlockModelConstraintItem
|
约束参数 |
required |
constrain_result_file
|
str
|
约束结果文件路径 |
required |
Returns:
| Type | Description |
|---|---|
bool
|
bool |
Source code in dimine_python_sdk\lib\prospecting\block_model.py
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 | |
create_block_model(params)
staticmethod
创建空块段模型
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
CreateBlockModelParams
|
CreateBlockModelParams 参数实例 |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
创建结果 {"state": "ok", ...} |
Raises:
| Type | Description |
|---|---|
BlockModelCreateError
|
创建失败时抛出 |
Source code in dimine_python_sdk\lib\prospecting\block_model.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
iter_blocks(field_name)
遍历块段模型的所有块段数据
Source code in dimine_python_sdk\lib\prospecting\block_model.py
188 189 190 191 | |
open(file_path)
加载块段模型文件
Raises:
| Type | Description |
|---|---|
BlockModelLoadError
|
加载失败时抛出 |
Source code in dimine_python_sdk\lib\prospecting\block_model.py
123 124 125 126 127 128 129 130 131 132 133 | |
DrillDBError
Bases: RuntimeError
钻孔数据库操作异常基类
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
62 63 64 | |
DrillDBLoadError
Bases: DrillDBError
加载钻孔数据库失败
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
67 68 69 | |
DrillDBManager
钻孔数据库管理器(业务层新版)
管理单个钻孔数据库的加载和操作。 所有表访问返回 pandas DataFrame,列名为中文标准格式:
db = DrillDBManager("钻孔数据.dmd")
db.collar['工程号'] # 取整列(Series)
db.collar.iloc[0] # 取单行
len(db.collar) # 记录数
db.collar.columns # 字段名列表(中文)
df = db.collar # 直接获得 pd.DataFrame
标准输入格式: COLLAR_COLUMN_MAP — 孔口表中文→英文列名映射 SURVEY_COLUMN_MAP — 测斜表中文→英文列名映射 LITHOLOGY_COLUMN_MAP — 岩性表中文→英文列名映射 SAMPLE_COLUMN_MAP — 样品表中文→英文列名映射
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | |
collar
property
writable
钻孔孔口表(pd.DataFrame)
lithology
property
writable
钻孔岩性表(pd.DataFrame)
sample
property
writable
钻孔样品表(pd.DataFrame)
survey
property
writable
钻孔测斜表(pd.DataFrame)
__getitem__(table_name)
统一表访问:db['collar'] / db['survey'] / db['lithology'] / db['sample']
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
596 597 598 599 600 601 602 603 604 605 606 607 608 | |
__init__(file_path=None, base_path=None)
初始化钻孔数据库管理器
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Optional[str]
|
dmd 文件路径(可以是相对路径)。为 None 时创建空对象, 需通过 setter 赋值 DataFrame 后再 save。 |
None
|
base_path
|
Optional[str]
|
基础路径,用于相对路径解析 |
None
|
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
close()
释放资源
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
533 534 535 536 537 | |
composite_samples(composite_length=2.0, grade_fields=None, combine_percent=0.75, start_mode='first_sample', discard_low_coverage=False, include_3d_coords=True, auto_detect_grade_fields=True)
样长组合(纯 Python/pandas 实现,不依赖 C++ 接口)
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |
load(file_path, base_path=None)
从文件加载钻孔数据库
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
process_and_composite(grade_fields, group_mode='by_hole', average_multiple=None, use_frequency=False, frequency=0.95, replace_method=2, max_depth_gap=0.5, keep_raw_grades=True, composite_length=2.0, combine_percent=0.75, start_mode='first_sample', discard_low_coverage=False, include_3d_coords=True)
特高品位处理 → 样长组合 串联调用
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | |
process_high_grade(params)
处理特高品位(调用 C++ extra_high_grade_process 接口)
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
621 622 623 | |
process_high_grade_samples(grade_fields, group_mode='by_hole', average_multiple=None, use_frequency=False, frequency=0.95, replace_method=2, max_depth_gap=0.5, keep_raw_grades=True)
特高品位处理(纯 Python/pandas 实现,不依赖 C++ 接口)
对多个品位字段依次执行特高品位识别与替换,返回处理后的完整样品表。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grade_fields
|
List[str]
|
品位字段列表,如 ["TFe", "TiO2"] |
required |
group_mode
|
str
|
分组模式 ("by_hole" / "by_section" / "global") |
'by_hole'
|
average_multiple
|
Optional[int]
|
平均值倍数,None=按CV自动判定6/7/8 |
None
|
use_frequency
|
bool
|
启用累积频率法 |
False
|
frequency
|
float
|
累积频率阈值 (0.95 / 0.975) |
0.95
|
replace_method
|
int
|
替换方式 (0=剔除 1=给定值 2=相邻平均 3=矿体平均 4=单一工程 5=截止品位) |
2
|
max_depth_gap
|
float
|
深度连续性容差(m) |
0.5
|
keep_raw_grades
|
bool
|
是否保留原始品位为 {field}_raw 列 |
True
|
Returns:
| Type | Description |
|---|---|
|
(processed_df, summary) 元组: processed_df — 处理后的 DataFrame(每字段有 {field}_processed 列) summary — {"特高样品总数": N, "TFe": {...}, "TiO2": {...}, "分组模式": ..., "品位字段": [...]} |
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
process_samples(params)
处理样长组合(C++ 接口)
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
613 614 615 | |
process_steps(params)
处理台阶组合(C++ 接口)
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
617 618 619 | |
reload()
重新加载文件
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
456 457 458 459 460 461 462 463 464 465 | |
save(output_path=None, extend_tables=None)
保存钻孔数据库
完全走 Python 层,不调用 C++ geo_drill_save: 1. 孔口表 -> {stem}_collar.dmt 2. 斜测表 -> {stem}_survey.dmt 3. 岩性表 -> {stem}_lithology.dmt 4. 样品表 -> {stem}_sample.dmt(可选) 5. 扩展表 -> {ext.dmt_filename}(可选,用于隐式建模等) 6. 引用关系 -> {stem}.dmd
Parameters
output_path : str, optional 保存路径 extend_tables : List[Dict], optional 扩展表列表,每个 dict 含 df / dmt_filename / field_list
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
save_as_dmg(output_path)
将钻孔数据库保存为 .dmg 可视化格式。
先将内存中四个缓存表同步回 native session,再调用 native save_as_dmg。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
Union[str, Path]
|
目标 .dmg 文件路径(无扩展名时自动补全) |
required |
Raises:
| Type | Description |
|---|---|
DrillDBSaveError
|
保存失败时抛出 |
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
DrillDBProcessError
Bases: DrillDBError
钻孔数据处理失败
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
72 73 74 75 76 | |
DrillDBSaveError
Bases: DrillDBError
保存钻孔数据库失败
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
79 80 81 | |
DrillFunctionWrapper
钻孔相关功能的封装器,提供更简洁的接口
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
extra_high_grade_process(params)
staticmethod
特高品位处理
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
364 365 366 367 368 369 | |
sample_length_combine(params)
staticmethod
样长组合
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
344 345 346 347 348 349 350 351 352 353 354 | |
step_combine(params)
staticmethod
台阶组合
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
356 357 358 359 360 361 362 | |
EntityConstraint
Bases: ParamModel
实体约束 (type=0):基于实体模型的内部/外部空间约束
Source code in dimine_python_sdk\lib\prospecting\models.py
63 64 65 66 67 68 69 70 71 72 73 | |
FieldDefinition
Bases: ParamModel
块段模型属性字段定义
Source code in dimine_python_sdk\lib\prospecting\models.py
197 198 199 200 201 202 203 204 | |
HighGradeParams
dataclass
特高品位处理参数
Attributes:
| Name | Type | Description |
|---|---|---|
grade_field |
str
|
品位字段名(如 "CU"、"TFe") |
group_mode |
GroupMode
|
分组维度 - "by_hole": 按工程号分组 - "by_section": 按勘探线分组(需传入 collar_df) - "global": 全矿区统一计算(默认) |
use_average_multiple |
bool
|
启用平均值倍数法 |
average_multiple |
Optional[int]
|
倍数系数。设为 None(默认)时按品位变化系数(CV)自动判定: CV<0.5→6倍, 0.5≤CV<1.0→7倍, CV≥1.0→8倍。 也可手动指定 6/7/8。 |
use_frequency |
bool
|
启用累积频率法 |
frequency |
float
|
累积频率阈值(常用 0.95 / 0.975 / 0.977) |
replace_method |
ReplaceMethod
|
替换方式 0 - 剔除法(设为 NaN) 1 - 给定值法 2 - 相邻样品平均值法(默认,长度加权) 3 - 矿体平均品位法 4 - 单一工程法 5 - 截止品位法(cap 到阈值) |
assign_value |
float
|
方法 1 的给定值 |
max_adjacent_search |
int
|
方法 2 相邻搜索最大扩展步数(默认 3) |
max_depth_gap |
float
|
方法 2 深度连续性容差(m)。候选样品与当前样品的 FROM/TO 间隙超过此值则视为不连续,跳过该候选。 默认 0.5m;设为 0 表示要求严格连续。 |
average_method |
AverageMethod
|
均值计算方式 - "arithmetic": 算术平均 - "length_weighted": 长度加权平均(默认) |
result_field |
Optional[str]
|
结果字段名(None 时默认为 {grade_field}_processed) |
Source code in dimine_python_sdk\lib\prospecting\high_grade.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 114 | |
HighGradeProcessParam
Bases: ParamModel
特高品位处理参数
Source code in dimine_python_sdk\lib\prospecting\models.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
HighGradeProcessor
特高品位处理器
对样品表 DataFrame 执行特高品位识别与替换,支持: - 平均值倍数法 / 累积频率法双阈值策略 - 六种替换方法(剔除、给定值、相邻平均、矿体平均、单一工程、截止品位) - 单次处理,不做迭代收敛
Source code in dimine_python_sdk\lib\prospecting\high_grade.py
122 123 124 125 126 127 128 129 130 131 132 133 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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
process(sample_df, collar_df=None)
执行特高品位处理(单次处理,不迭代)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_df
|
DataFrame
|
样品表 DataFrame,需包含 [工程号, 样本编号, 起始, 结束] 及品位列。 |
required |
collar_df
|
Optional[DataFrame]
|
孔口表 DataFrame(group_mode="by_section" 时必需)。 |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
(processed_df, summary) 元组: processed_df — 处理后的完整样品 DataFrame(新增 result_field 列) summary — 汇总统计 dict |
Source code in dimine_python_sdk\lib\prospecting\high_grade.py
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 177 178 179 180 181 182 183 184 185 | |
ParamModel
Bases: BaseModel
参数模型基类,提供 model_dump 的 to_dict 别名以兼容旧代码
Source code in dimine_python_sdk\lib\_base.py
15 16 17 18 19 20 21 | |
PlaneConstraint
Bases: ParamModel
平面约束 (type=4):由平面方程 ax+by+cz+d=0 定义的上部/下部约束
Source code in dimine_python_sdk\lib\prospecting\models.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
PolylineConstraint
Bases: ParamModel
闭合多段线约束 (type=3):基于闭合多段线 + 坐标轴范围的约束
Source code in dimine_python_sdk\lib\prospecting\models.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
ReservesCalculateError
Bases: BlockDataError
储量计算失败
Source code in dimine_python_sdk\lib\prospecting\block_model.py
67 68 69 70 71 | |
ReservesCalculateParam
Bases: ParamModel
估值算量参数
Source code in dimine_python_sdk\lib\prospecting\models.py
188 189 190 191 192 193 194 | |
SampleCompositingParams
dataclass
样长组合参数
Attributes:
| Name | Type | Description |
|---|---|---|
composite_length |
float
|
组合样长度(米),必须 > 0。 建议取值为块体尺寸的 1/4 到 1/3。 |
grade_fields |
List[str]
|
需要做长度加权平均的品位字段名列表。 字段必须存在于样品表中,且为数值类型。 |
combine_percent |
float
|
最小覆盖率(0-1),组合区间内实际样品覆盖长度 低于此比例时标记为低质量组合样。 默认 0.75(与 DIMINE C++ 接口默认值一致)。 |
start_mode |
str
|
组合起始模式。 - 'first_sample': 从每个钻孔第一个样品起始深度开始(默认) - 'collar': 从孔口(深度0)开始 - 数字: 从指定的绝对深度开始(如 5.0) |
discard_low_coverage |
bool
|
尾部截断模式。 为 True 时,从孔口方向找到最后一个满足覆盖率要求的区间, 丢弃其之后的所有区间(即"尾部截断")。 注意:截断点之前的中间低覆盖率区间仍会被保留。 为 False 时保留所有区间,通过 "低覆盖率" 列标记。 |
include_3d_coords |
bool
|
是否计算组合样段中点的三维坐标。 需要提供 survey 和 collar 表。 |
min_samples_per_composite |
int
|
每个组合样最少包含的原始样品数(警告阈值)。 |
auto_detect_grade_fields |
bool
|
是否自动检测样品表中的数值型品位字段。 为 True 时,grade_fields 中未列出的数值列也会被组合。 自动排除标准列(工程号、样本编号、坐标等)。 |
Source code in dimine_python_sdk\lib\prospecting\compositing.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 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 | |
SampleCompositingProcessor
样长组合处理器
对钻孔样品表执行样长组合操作。核心流程:
1. 数据预处理(NaN 清理、类型转换、数据校验)
2. 按钻孔(工程号)分组
3. 对每个钻孔独立执行长度加权组合
4. 汇总所有钻孔的组合结果
5. 生成统计报告
Usage
params = SampleCompositingParams( composite_length=2.0, grade_fields=['TFe', 'TiO2'], ) processor = SampleCompositingProcessor(params) result = processor.process(sample_df, survey_df, collar_df)
Source code in dimine_python_sdk\lib\prospecting\compositing.py
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |
__init__(params=None, **kwargs)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Optional[SampleCompositingParams]
|
SampleCompositingParams 参数对象。 为 None 时从 **kwargs 构建。 |
None
|
**kwargs
|
直接传入 SampleCompositingParams 的参数。 |
{}
|
Source code in dimine_python_sdk\lib\prospecting\compositing.py
654 655 656 657 658 659 660 661 662 663 | |
process(sample_df, survey_df=None, collar_df=None)
执行样长组合。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_df
|
DataFrame
|
样品表 DataFrame(中文标准列名:工程号, 起始, 结束, ...) |
required |
survey_df
|
Optional[DataFrame]
|
测斜表 DataFrame(可选,用于计算3D坐标) |
None
|
collar_df
|
Optional[DataFrame]
|
孔口表 DataFrame(可选,用于计算3D坐标) |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
(composited_df, summary) 元组: composited_df — 组合后的样品 DataFrame summary — 汇总统计 dict |
Source code in dimine_python_sdk\lib\prospecting\compositing.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |
SampleLengthCombineParam
Bases: ParamModel
样长组合参数
Source code in dimine_python_sdk\lib\prospecting\models.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
SearchEllipsoidParams
Bases: ParamModel
搜索椭球体参数,可直接映射到 BlockModelDistancePowerParams。
三个角度依次为 Z-Y-X 欧拉角序列: R = Rz(π/2 − angle_main) × Ry(angle_second) × Rx(angle_short)
其中 R 的列向量为 [PC1, PC2, PC3]。
Source code in dimine_python_sdk\lib\prospecting\ellipsoid.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
angle_main
instance-attribute
方位角(°),主轴水平投影方向,0°=正北,90°=正东
angle_second
instance-attribute
倾伏角(°),主轴与水平面夹角,正值=向下,0°=水平,90°=垂直
angle_short
instance-attribute
倾角(°),椭球体绕主轴旋转角,控制短轴(厚度方向)的侧倾
center
instance-attribute
椭球体中心坐标 (x, y, z)
main_radius
instance-attribute
主轴半径(m),椭球体最长半轴
pc1_direction
instance-attribute
主轴方向单位向量(走向方向)
pc2_direction
instance-attribute
次轴方向单位向量(倾向方向)
pc3_direction
instance-attribute
短轴方向单位向量(厚度方向)
second_main_rate
instance-attribute
次轴/主轴比例
second_radius
instance-attribute
次轴半径(m),椭球体中等半轴
short_main_rate
instance-attribute
短轴/主轴比例
short_radius
instance-attribute
短轴半径(m),椭球体最短半轴
to_block_model_params()
提取 BlockModelDistancePowerParams 所需的 6 个字段。
Returns:
| Type | Description |
|---|---|
dict
|
dict,包含 main_radius、second_main_rate、short_main_rate、 |
dict
|
angle_main、angle_second、angle_short |
Source code in dimine_python_sdk\lib\prospecting\ellipsoid.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
StepCombineParam
Bases: ParamModel
台阶组合参数
Source code in dimine_python_sdk\lib\prospecting\models.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
ThresholdConstraint
Bases: ParamModel
阈值约束 (type=2):基于属性值比较的约束
Source code in dimine_python_sdk\lib\prospecting\models.py
89 90 91 92 93 94 95 96 97 98 99 | |
XPlaneConstraint
Bases: ParamModel
X 平面约束 (type=5):基于 X 坐标值的上部/下部约束,一种特殊的平面约束
Source code in dimine_python_sdk\lib\prospecting\models.py
136 137 138 139 140 141 142 143 144 145 146 | |
YPlaneConstraint
Bases: ParamModel
Y 平面约束 (type=6):基于 Y 坐标值的上部/下部约束,一种特殊的平面约束
Source code in dimine_python_sdk\lib\prospecting\models.py
149 150 151 152 153 154 155 156 157 158 159 | |
ZPlaneConstraint
Bases: ParamModel
Z 平面约束 (type=7):基于 Z 坐标值(高程)的上部/下部约束,一种特殊的平面约束
Source code in dimine_python_sdk\lib\prospecting\models.py
162 163 164 165 166 167 168 169 170 171 172 | |
composite_samples(db_or_samples, composite_length=2.0, grade_fields=None, combine_percent=0.75, discard_low_coverage=False, start_mode='first_sample', include_3d_coords=True, auto_detect_grade_fields=True, survey_df=None, collar_df=None)
样长组合便捷函数。
支持两种输入模式: 1. 从 DrillDBManager 直接传入: result = composite_samples(db, composite_length=2.0, grade_fields=['TFe']) 2. 从独立的 DataFrame 传入: result = composite_samples( sample_df, composite_length=2.0, grade_fields=['TFe', 'TiO2'], survey_df=survey_df, collar_df=collar_df )
discard_low_coverage 策略: - False(默认):保留所有组合区间,通过 "低覆盖率" 列标记 - True:尾部截断——找到最后一个合格区间,丢弃其之后的所有区间。 如需丢弃所有不合格区间(包括中间的),请在结果上执行: df = df[~df['低覆盖率']]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_or_samples
|
DrillDBManager 实例 或 样品表 pd.DataFrame |
required | |
composite_length
|
float
|
组合样长度(米),默认 2.0 |
2.0
|
grade_fields
|
Optional[List[str]]
|
品位字段列表。为 None 时自动检测数值列 |
None
|
combine_percent
|
float
|
最小覆盖率(0-1),默认 0.75 |
0.75
|
discard_low_coverage
|
bool
|
尾部截断模式,默认 False |
False
|
start_mode
|
str
|
起始模式,默认 'first_sample' |
'first_sample'
|
include_3d_coords
|
bool
|
是否计算3D坐标 |
True
|
auto_detect_grade_fields
|
bool
|
是否自动检测品位字段 |
True
|
survey_df
|
Optional[DataFrame]
|
测斜表(仅当 db_or_samples 为 DataFrame 时需要) |
None
|
collar_df
|
Optional[DataFrame]
|
孔口表(仅当 db_or_samples 为 DataFrame 时需要) |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
(composited_df, summary) 元组 |
Source code in dimine_python_sdk\lib\prospecting\compositing.py
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 | |
compute_search_ellipsoid(points, voxel_size=5.0)
从点云计算搜索椭球体参数。
流程:体素降采样 → MVEE → 角度分解。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
点云坐标,shape=(N, 3),(x=东, y=北, z=高程) |
required |
voxel_size
|
Optional[float]
|
体素降采样尺寸(米),设为 None 或 0 则跳过降采样。 推荐 5.0 m,可有效消除三角网密度不均的影响。 |
5.0
|
Returns:
| Type | Description |
|---|---|
SearchEllipsoidParams
|
SearchEllipsoidParams,包含 6 个核心参数及辅助信息 |
Raises:
| Type | Description |
|---|---|
ValueError
|
点云数量不足(< 4) |
Example::
params = compute_search_ellipsoid(points, voxel_size=5.0)
# 直接用于距离幂估值
eval_params = BlockModelDistancePowerParams(
**params.to_block_model_params(),
sample_file="样品.dmg",
variables="CU",
extra_attributes="样品点数目",
)
Source code in dimine_python_sdk\lib\prospecting\ellipsoid.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
compute_search_ellipsoid_from_dmf(dmf_path, voxel_size=5.0)
从 DMF 矿体模型文件直接计算搜索椭球体参数。
自动提取所有 Shell 实体的顶点,执行体素降采样与 MVEE 计算。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dmf_path
|
str
|
DMF 矿体模型文件路径 |
required |
voxel_size
|
float
|
体素降采样尺寸(米),推荐 5.0 m |
5.0
|
Returns:
| Type | Description |
|---|---|
SearchEllipsoidParams
|
SearchEllipsoidParams |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
DMF 文件不存在 |
ValueError
|
DMF 中无 Shell 实体 |
Source code in dimine_python_sdk\lib\prospecting\ellipsoid.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
convert_dmd_to_dmg(input_path, output_path)
将 .dmd 钻孔数据库直接转换为 .dmg 格式。
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
Union[str, Path]
|
源 .dmd 文件路径 |
required |
output_path
|
Union[str, Path]
|
目标 .dmg 文件路径(无扩展名时自动补全) |
required |
Raises:
| Type | Description |
|---|---|
DrillDBLoadError
|
加载 .dmd 失败 |
DrillDBSaveError
|
保存 .dmg 失败 |
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
drill_conn(file_path=None, base_path=None)
钻孔数据库连接上下文管理器
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Optional[str]
|
dmd 文件路径。为 None 时创建空对象,可赋值 DataFrame 后 save。 |
None
|
base_path
|
Optional[str]
|
基础路径,用于相对路径解析 |
None
|
Usage
with drill_conn("database.dmd") as db: print(db.collar.iloc[0]) df = db.collar
with drill_conn() as db: db.collar = df_collar db.save("output.dmd")
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
save_drill_database(collar_df, survey_df, lithology_df, save_path, sample_df=None, extend_tables=None)
保存钻孔数据库:子表 .dmt + .dmd 引用文件。
完全走 Python 层,不调用 C++ geo_drill_save;直接通过
NativeDataTableHandle 与底层 CDataTable 交互。
Parameters
extend_tables : List[Dict], optional 扩展表列表,每个元素为 dict: - df: pd.DataFrame 扩展表数据 - dmt_filename: str .dmt 文件名(如 "分层表.dmt") - field_list: str 字段列表(如 "钻孔编号,从,至,地层") 用于隐式地层建模等场景,最终写入 ExtendTableCount / ExtendTable{N}Path 等引用字段。
Source code in dimine_python_sdk\lib\prospecting\drill_db.py
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 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 | |
钻孔数据库 DMD 转 DMG
除上述应用层 API 外,lib.prospecting 还提供独立的 convert_dmd_to_dmg() 函数,用于将数据表形式存储的钻孔数据库(.dmd)打包为三维模型 + 数据形式(.dmg),无需实例化 DrillDBManager。
from dimine_python_sdk.lib.prospecting import convert_dmd_to_dmg
convert_dmd_to_dmg("input.dmd", "output.dmg")