Variography#

import geolime as geo
from pyproj import CRS
import numpy as np
import pyvista as pv

pv.set_jupyter_backend('html')
geo.Project().set_crs(CRS("EPSG:20350"))
dh = geo.read_file("../data/dh_pop_classif.geo")
dh.user_properties()
['X_COLLAR',
 'Y_COLLAR',
 'Z_COLLAR',
 'X_M',
 'Y_M',
 'Z_M',
 'X_B',
 'Y_B',
 'Z_B',
 'X_E',
 'Y_E',
 'Z_E',
 'Fe_pct',
 'Al2O3',
 'SiO2_pct',
 'K2O_pct',
 'CaO_pct',
 'MgO_pct',
 'TiO2_pct',
 'P_pct',
 'S_pct',
 'Mn_pct',
 'Fe_ox_ai',
 'hem_over_goe',
 'kaolin_abundance',
 'kaolin_composition',
 'wmAlsmai',
 'wmAlsmci',
 'carbai3pfit',
 'carbci3pfit',
 'Sample_ID',
 'Fe',
 'Fe2o3',
 'P',
 'S',
 'SiO2',
 'MnO',
 'Mn',
 'CaO',
 'K2O',
 'MgO',
 'Na2O',
 'TiO2',
 'LOI_100',
 'Depth',
 'ellipsoidal_distance',
 'OreZone',
 'domain_code',
 'domain',
 'manual_classif_code',
 'manual_classif',
 'sk_classif_code',
 'sk_classif']

Data Selection#

domain_solid = geo.datasets.load("rocklea_dome/domain_mesh.dxf")
domain_solid.name
'OreZone'
domain_solid.contains(dh)
domain_solid_pv = domain_solid.to_pyvista()
dh_pv = dh.to_pyvista('in_OreZone')
plotter = pv.Plotter()

plotter.add_mesh(domain_solid_pv, style="wireframe")
plotter.add_mesh(dh_pv.tube(radius=20))

plotter.set_scale(zscale=10)
plotter.show()
geo.histogram_plot(data=[{"object":dh, "property":"Fe_pct", "region":"in_OreZone"}])
dh.set_region_condition("HighGrade", "in_OreZone and (Fe_pct == Fe_pct)")

VarioMap#

lags, tol = geo.generate_lags(lag=200, plag=50, nlags=15)
geo.vario_map(
    geo_object=dh,
    attribute="Fe_pct",
    region="HighGrade",
    lags=lags,
    tol=tol,
    n_az=15,
    atol=35
)
geo.vario_contour(
    geo_object=dh,
    attribute="Fe_pct",
    region="HighGrade",
    lags=lags,
    tol=tol,
    n_az=15,
    atol=35
)
../_images/8698966c72e4e308f1514f18f927beefe93b567b1cb2d223a015dee92851e26c.png

VarioMap suggets major and minor preferential direction are N00 and N90.

major_direction = 0.
minor_direction = 90.

Fitting a Covariance Model#

Model the Nugget Effect#

Experimental Downhole Variogram#

lags_bh, tol_bh = geo.generate_lags(lag=1., plag=50, nlags=10.)
tol_bh
0.5
vario_exp_bh = geo.variogram(
    object=dh,
    attribute="Fe_pct",
    region="HighGrade",
    geographic_azimuth=0,
    dip=90,
    pitch=90,
    lags=lags_bh,
    tol=tol_bh,
    atol=10
)

geo.plot_semivariogram(
    variograms=[vario_exp_bh],
    display_npairs=True
)
vario_exp_bh
lag npairs avgdist vario
0 1.0 1601.0 1.0 38.453467
1 2.0 1530.0 2.0 60.226471
2 3.0 1460.0 3.0 71.746233
3 4.0 1394.0 4.0 80.208393
4 5.0 1324.0 5.0 83.884819
5 6.0 1256.0 6.0 83.457803
6 7.0 1192.0 7.0 84.465604
7 8.0 1124.0 8.0 82.919039
8 9.0 1057.0 9.0 83.146168

Automatic Fitting#

nugget_model = geo.Nugget() + geo.Spherical()
geo.model_fit(
    variograms=[vario_exp_bh], 
    cov=nugget_model
)
geo.plot_semivariogram(
    variograms=[vario_exp_bh],
    model=nugget_model,
    model_angles=[{"azi":0, "dip":90, "pitch":90}],
    display_npairs=True
)
print(nugget_model)
Model with 2 components 
 
Component 1 : 
Sill : 16.16132215461451 
Covariance type : Nugget 

Component 2 : 
Sill : 65.82115850541842 
Covariance type : Spherical 
Scales : (8.955, 2.2544740683925633, 4.283361665984049) 
Angles : (176.84303590280922, 6.895859166774057e-11, -26.717258117579377) 

Total sill = 81.98248066003293 
nugget_value = nugget_model.cov_elem_list[0].sill

Model the Sphericals#

Experimental Variograms along the XY plane#

lags, tol = geo.generate_lags(lag=50, plag=50, nlags=10)
vario_exp_major = geo.variogram(
    object=dh,
    attribute="Fe_pct",
    region="HighGrade",
    geographic_azimuth=major_direction,
    dip=0,
    pitch=0,
    lags=lags,
    tol=tol,
    atol=40
)
vario_exp_minor = geo.variogram(
    object=dh,
    attribute="Fe_pct",
    region="HighGrade",
    geographic_azimuth=minor_direction,
    dip=0,
    pitch=0,
    lags=lags,
    tol=tol,
    atol=30
)

geo.plot_semivariogram(
    variograms=[vario_exp_major, vario_exp_minor],
    display_npairs=True
)

Automatic Fitting#

model =  geo.Nugget() + geo.Spherical() + geo.Spherical()
short_range_spherical_ratio = 0.7
long_range_spherical_ratio = 0.3
geo.model_fit(
    variograms=[
        vario_exp_major, 
        vario_exp_minor, 
        vario_exp_bh
    ], 
    cov=model,
    constraints=[
        {"sill_fixed":nugget_value},
        {
            "sill_max": short_range_spherical_ratio * (vario_exp_major.attrs["variable_var"] - nugget_value),
            "angle_fixed_0": major_direction,
            "angle_fixed_1": 0,
            "angle_fixed_2": 0
        },
        {
            "sill_max": long_range_spherical_ratio * (vario_exp_major.attrs["variable_var"] - nugget_value),
            "angle_fixed_0": major_direction,
            "angle_fixed_1": 0,
            "angle_fixed_2": 0,
        }
    ]
)
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/lmfit/minimizer.py:859: RuntimeWarning:

invalid value encountered in sqrt

/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/lmfit/minimizer.py:866: RuntimeWarning:

invalid value encountered in sqrt
geo.plot_semivariogram(
    variograms=[
        vario_exp_major, 
        vario_exp_minor, 
        vario_exp_bh
    ],
    model=model,
    model_angles=[{"azi":major_direction, "dip":0, "pitch":0}, {"azi":minor_direction, "dip":0, "pitch":0}, {"azi":0, "dip":90, "pitch":90}],
    display_npairs=True,
    variogram_colors=['green', 'blue', 'orange']
)
print(model)
Model with 3 components 
 
Component 1 : 
Sill : 16.16132215461451 
Covariance type : Nugget 

Component 2 : 
Sill : 53.17653188333166 
Covariance type : Spherical 
Scales : (140.63424620765352, 65.96967864152745, 3.822068670215313) 
Angles : (0.0, 0.0, 0.0) 

Component 3 : 
Sill : 22.789942097546433 
Covariance type : Spherical 
Scales : (207.20680943969853, 86.08297491363567, 14.112154800938049) 
Angles : (0.0, 0.0, 0.0) 

Total sill = 92.1277961354926