### Apply Color to Numerical Data Source: https://opengeostat.github.io/pygslib/API.html This example shows how to use the apply_colour method of a Leyend_num object to map numerical data points to corresponding colors based on a defined color scale. This is useful for visualizing continuous numerical data within tables. ```python >>> cc = my_leyend_num.apply_colour([77, 87.9, 77]) ``` -------------------------------- ### Example Usage of block_covariance Source: https://opengeostat.github.io/pygslib/API.html Demonstrates how to call the `block_covariance` function with a defined parameters dictionary and print the result. ```python print (pygslib.gslib.block_covariance(parameters_blk)) ``` -------------------------------- ### Apply Color to Categorical Data Source: https://opengeostat.github.io/pygslib/API.html This example demonstrates how to apply a color scale defined by a Leyend_cat object to an array of categorical data. It shows how to get the corresponding color for each category, including handling undefined or out-of-range values. ```python >>> cc = my_leyend_num.apply_colour(['granite', 'basalt', 'NA']) ``` -------------------------------- ### Install PyGSLIB using Conda Source: https://opengeostat.github.io/pygslib/index.html Install PyGSLIB in your Anaconda root environment by running this command in a terminal. Paraview is also recommended for visualization. ```bash conda install -c opengeostat pygslib ``` -------------------------------- ### Importing Python Libraries Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt Imports necessary third-party Python libraries for data analysis and plotting. Ensure these libraries are installed before running. ```python # import third party python libraries import pandas as pd import matplotlib.pylab as plt import numpy as np # make plots inline in Ipython Notebooks/QT terminal # %matplotlib inline ``` -------------------------------- ### Print KT3D function documentation Source: https://opengeostat.github.io/pygslib/Tutorial.html This snippet shows how to print the documentation for the pygslib.gslib.kt3d function to understand its input parameters. ```python >>> print (pygslib.gslib.kt3d.__doc__) ``` -------------------------------- ### Create KT3D Parameter Dictionary for Block Estimation Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt This snippet demonstrates how to construct the parameter dictionary required for the pygslib.gslib.kt3d function. It includes input data filtering, output block definition, search parameters, kriging settings, and variogram model parameters. ```Python kt3d_Parameters = { # Input Data (Only using intervals in the mineralized domain) # ---------- 'x' : mydholedb.table["CMP"]['xm'][mydholedb.table["CMP"]['Domain']==1].values, 'y' : mydholedb.table["CMP"]['ym'][mydholedb.table["CMP"]['Domain']==1].values, 'z' : mydholedb.table["CMP"]['zm'][mydholedb.table["CMP"]['Domain']==1].values, 'vr' : mydholedb.table["CMP"]['CU'][mydholedb.table["CMP"]['Domain']==1].values, 'bhidint' : mydholedb.table["CMP"]['BHIDint'][mydholedb.table["CMP"]['Domain']==1].values, # an interger BHID # Output (Target) # ---------- 'nx' : nx, 'ny' : ny, 'nz' : nz, 'xmn' : xorg, 'ymn' : yorg, 'zmn' : zorg, 'xsiz' : dx, 'ysiz' : dy, 'zsiz' : dz, 'nxdis' : 5, 'nydis' : 5, 'nzdis' : 3, 'outx' : mymodel.bmtable['XC'][mymodel.bmtable['IJK']==1149229].values, # filter to estimate only on block with IJK 1149229 'outy' : mymodel.bmtable['YC'][mymodel.bmtable['IJK']==1149229].values, 'outz' : mymodel.bmtable['ZC'][mymodel.bmtable['IJK']==1149229].values, # Search parameters # ---------- 'radius' : 850, 'radius1' : 850, 'radius2' : 250, 'sang1' : -28, 'sang2' : 34, 'sang3' : 7, 'ndmax' : 12, 'ndmin' : 4, 'noct' : 0, 'nbhid' : 3, # Kriging parameters and options # ---------- 'ktype' : 1, # 1 Ordinary kriging 'idbg' : 1, # 0 no debug # Variogram parameters # ---------- 'c0' : 0.35 * 0.109758094158, # we require not normalized variance for GCOS, fix... multiply for actual variance 'it' : [2,2], 'cc' : [0.41*0.109758094158,0.23*0.109758094158], 'aa' : [96,1117], 'aa1' : [96,1117], 'aa2' : [96,300], 'ang1' : [-28,-28], 'ang2' : [ 34, 34], 'ang3' : [ 7, 7]} ``` -------------------------------- ### Create Drillhole Object Source: https://opengeostat.github.io/pygslib/Tutorial.html Initialize a Drillhole object with collar and survey data. Add interval tables like assays or lithology. Be aware of potential warnings for missing fields like 'LENGTH'. ```python #creating a drillhole object >>> mydholedb=pygslib.drillhole.Drillhole(collar=collar, survey=survey) >>> # now you can add as many interval tables as you want, for example, assays, lithology and RQD. >>> mydholedb.addtable(assay, 'assay', overwrite = False) ``` -------------------------------- ### Execute KT3D Estimation and Retrieve Results Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt This snippet shows how to call the pygslib.gslib.kt3d function with the prepared parameter dictionary and how to capture the estimation results, debug information, and summary statistics. ```Python # estimating in one block estimate, debug, summary = pygslib.gslib.kt3d(kt3d_Parameters) ``` -------------------------------- ### Desurvey Interval Table Source: https://opengeostat.github.io/pygslib/Tutorial.html Calculate the 3D coordinates (xm, ym, zm) and directions (azm, dipm) for composite intervals using the `desurvey` method. Set `endpoints=True` to include start and end coordinates for export. ```python # desurveying an interval table >>> mydholedb.desurvey('CMP',warns=False, endpoints=True) ``` -------------------------------- ### Initialize Drillhole Object Source: https://opengeostat.github.io/pygslib/API.html Create a Drillhole object using collar and survey data. Interval tables like assay data can be added subsequently. ```python >>> >>> mydrillhole = pygslib.drillhole.Drillhole(collar, survey) >>> mydrillhole.addtable(assay, 'assay' ,overwrite = False) >>> ``` -------------------------------- ### fillwireframe Source: https://opengeostat.github.io/pygslib/API.html Creates a full block model given a VTK surface (polydata). Results in blocks with parameter 'in' between 0 and 1. ```APIDOC ## fillwireframe ### Description Creates a full block model given a VTK surface (polydata) using vtkPolyDataToImageStencil. The results consist of blocks with parameter `in` with value between 0 and 1. `in = 0` represents blocks completely outside the wireframe, `in = 1` represents blocks completely inside the wireframe, and `1 > in > 0` represents blocks cut by the wireframe. The parameter `in` is calculated as the sum of corners of the block, each corner is equal to 1 if it is inside the block or equal to 0 if it is outside. The parameter `in` can be used as a percentage of inclusion in the block with an error proportional to the size of the block and the resolution/complexity of the wireframe. The method may fail if the wireframe is narrower than a block. In this case, you can set a tolerance value (1 >= toll >= 0). The output may not be used as volume, only as a selection of blocks within a wireframe (with `in > 0`). ### Parameters * **surface** (VTK polydata) - This may work with any 3D object, not necessarily triangles. * **tol** (float, default 0.0) - Number in interval [0. , 1.]. You may use tol>0 if the blocks are large and the wireframe is narrower than the block size. * **overwrite** (boolean) - Overwrite flag, if true the entire block model will be overwritten. ### Example ```python myblockmodel.fillwireframe(surface, toll=0, overwrite=False) ``` ### Note The tolerance only works on the x, y plane, not in z. ``` -------------------------------- ### Load Wireframe for Domain Tagging Source: https://opengeostat.github.io/pygslib/Tutorial.html Imports a wireframe from an STL file. This is the first step in labeling drillhole samples based on their location within a defined domain. ```python >>> # importing the wireframe >>> domain=pygslib.vtktools.loadSTL('domain.stl') ``` -------------------------------- ### Drillhole Object Initialization Source: https://opengeostat.github.io/pygslib/API.html Initializes a Drillhole object with collar and survey data. Interval tables can be added subsequently. ```APIDOC ## Drillhole Object Initialization ### Description Initializes a Drillhole object with collar and survey data. Interval tables can be added subsequently. ### Parameters #### Collar Table - **collar** (Pandas DataFrame) - Required - The collar table containing fields like BHID, XCOLLAR, YCOLLAR, ZCOLLAR, and optionally LENGTH. #### Survey Table - **survey** (Pandas DataFrame) - Required - The survey table containing fields like BHID, AT, AZ, and DIP. ### Example ```python >>> import pygslib >>> mydrillhole = pygslib.drillhole.Drillhole(collar, survey) ``` ``` -------------------------------- ### Create parameter dictionary for estimation Source: https://opengeostat.github.io/pygslib/Tutorial.html This code defines the 'kt3d_Parameters' dictionary required for the pygslib.gslib.kt3d function. It includes input data, output block definition, search parameters, kriging parameters, and variogram parameters. Ensure that variables like 'mydholedb', 'mymodel', 'nx', 'ny', 'nz', 'xorg', 'yorg', 'zorg', 'dx', 'dy', and 'dz' are defined prior to this. ```python >>> # creating parameter dictionary for estimation in one block >>> kt3d_Parameters = { # Input Data (Only using intervals in the mineralized domain) # ---------- 'x' : mydholedb.table["CMP"]['xm'][mydholedb.table["CMP"]['Domain']==1].values, 'y' : mydholedb.table["CMP"]['ym'][mydholedb.table["CMP"]['Domain']==1].values, 'z' : mydholedb.table["CMP"]['zm'][mydholedb.table["CMP"]['Domain']==1].values, 'vr' : mydholedb.table["CMP"]['CU'][mydholedb.table["CMP"]['Domain']==1].values, 'bhidint' : mydholedb.table["CMP"]['BHIDint'][mydholedb.table["CMP"]['Domain']==1].values, # an interger BHID # Output (Target) # ---------- 'nx' : nx, 'ny' : ny, 'nz' : nz, 'xmn' : xorg, 'ymn' : yorg, 'zmn' : zorg, 'xsiz' : dx, 'ysiz' : dy, 'zsiz' : dz, 'nxdis' : 5, 'nydis' : 5, 'nzdis' : 3, 'outx' : mymodel.bmtable['XC'][mymodel.bmtable['IJK']==1149229].values, # filter to estimate only on block with IJK 1149229 'outy' : mymodel.bmtable['YC'][mymodel.bmtable['IJK']==1149229].values, 'outz' : mymodel.bmtable['ZC'][mymodel.bmtable['IJK']==1149229].values, # Search parameters # ---------- 'radius' : 850, 'radius1' : 850, 'radius2' : 250, 'sang1' : -28, 'sang2' : 34, 'sang3' : 7, 'ndmax' : 12, 'ndmin' : 4, 'noct' : 0, 'nbhid' : 3, # Kriging parameters and options # ---------- 'ktype' : 1, # 1 Ordinary kriging 'idbg' : 1, # 0 no debug # Variogram parameters # ---------- 'c0' : 0.35 * 0.109758094158, # we require not normalized variance for GCOS, fix... multiply for actual variance 'it' : [2,2], 'cc' : [0.41*0.109758094158,0.23*0.109758094158], 'aa' : [96,1117], 'aa1' : [96,1117], 'aa2' : [96,300], 'ang1' : [-28,-28], 'ang2' : [ 34, 34], 'ang3' : [ 7, 7]} ``` -------------------------------- ### Load Wireframe for Domain Tagging Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt Imports a wireframe model from an STL file. This is the first step before tagging drillhole samples with domain information. ```python >>> # importing the wireframe >>> domain=pygslib.vtktools.loadSTL('domain.stl') ``` -------------------------------- ### Blockmodel Class Initialization Source: https://opengeostat.github.io/pygslib/API.html Initializes a Blockmodel object with grid dimensions, origin coordinates, and block sizes. ```APIDOC ## Blockmodel Class ### Description Represents a blockmodel object. ### Parameters * **nx, ny, nz** (integer) – Number of rows, columns, and levels. * **xorg, yorg, zorg** (float) – Coordinates of the lower left corner (not centroid). * **dx, dy, dz** (float) – Size of the parent block. ### Attributes * **nx, ny, nz** (int) – number of rows, columns, levels. * **xorg, yorg, zorg** (float) – coordinates of the left lower corner of the first block. * **dx, dy, dz** (float) – sizes of the blocks. * **bmtable** (Pandas DataFrame) – Table with blocks. * **gridtable** (Pandas Dataframe) ``` -------------------------------- ### Create and Add Table to Drillhole Object Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt Instantiate a Drillhole object and add interval tables like assays. Overwrite existing tables if needed. ```python >>> #creating a drillhole object >>> mydholedb=pygslib.drillhole.Drillhole(collar=collar, survey=survey) >>> # now you can add as many interval tables as you want, for example, assays, lithology and RQD. >>> mydholedb.addtable(assay, 'assay', overwrite = False) ``` -------------------------------- ### Create IJK Indices Table Source: https://opengeostat.github.io/pygslib/API.html Creates a new block model table with IJK indices. Can overwrite existing blocks. ```python >>> create_IJK(overwrite=True) ``` -------------------------------- ### Display First 3 Rows of Collar Data Source: https://opengeostat.github.io/pygslib/Tutorial.html Prints the first three rows of the collar DataFrame to inspect the loaded collar information. ```python print (collar.head(3)) ``` -------------------------------- ### pygslib.vtktools.loadSTL Source: https://opengeostat.github.io/pygslib/API.html Loads data from an STL file. ```APIDOC ## pygslib.vtktools.loadSTL ### Description Loads data from an STL file. ### Parameters #### Parameters - **filenameSTL** (str) - The path to the STL file. ``` -------------------------------- ### Create 3D Grid/Block Model Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 3D grid. The entire grid can be overwritten. ```python >>> mymodel.create_3Dgrid(overwrite=False) ``` -------------------------------- ### loadVTP Source: https://opengeostat.github.io/pygslib/API.html Loads an XML VTK Polydata file into a VTK Polydata object. ```APIDOC ## loadVTP ### Description Loads an XML VTK Polydata file. ### Parameters * **filenameVTP** (file path) - The path to the VTP file. ### Returns * **polydata** (VTK Polydata object) - The loaded polydata. ``` -------------------------------- ### create_gridxy Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 2D grid in the XY direction, based on the block model definition in X and Y. Overwrites the entire grid if overwrite is True. ```APIDOC ## create_gridxy ### Description Creates a full block 2D grid in defined in the XY direction. The grid definition is taken from the block model definition in the X, and Y directions. ### Parameters * **overwrite** (boolean, default False) - Overwrite flag, if true the entire grid will be overwritten. ### Example ```python myblockmodel.create_gridxy(overwrite=False) ``` ``` -------------------------------- ### Generate and Display Histogram Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt This snippet shows how to prepare parameters and calculate a histogram using `pygslib.plothtml.histgplt`. It then prints key statistics and displays the generated plot. ```Python # prepare parameters dictionary >>> parameters = { 'hmin' : None, #in/output rank-0 array(float,'d') 'hmax' : None, #in/output rank-0 array(float,'d') 'ncl' : 30, #int, number of bins 'iwt' : 1, #int, 1 use declustering weight 'ilog' : 1, #int, 1 use logscale 'icum' : 0, #int, 1 use cumulative 'va' : mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'CU'], # array('d') with bounds (nd) 'wt' : mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'declustwt'], # array('d') with bounds (nd), wight variable (obtained with declust?) 'figure' : None , # a bokeh figure object (Optional: new figure created if None). Set none or undefined if creating a new figure. 'title' : 'Hist Cu', # string. Figure title 'xlabel' : 'Cu (%)', # string. X axis label 'ylabel' : 'f(%)', # string. Y axis label # visual parameter for the histogram 'color' : 'red', # string with valid CSS colour (https://www.w3schools.com/colors/colors_names.asp), or an RGB(A) hex value, or tuple of integers (r,g,b), or tuple of (r,g,b,a) 'legend': 'Non - Declustered', # string (Optional, default "NA") 'alpha' : 0.5, # float [0-1]. Transparency of the fill colour 'lwidth': 1, # float. Line width # legend 'legendloc': 'top_left'} >>> >>> # calculate histogram >>> stats, fig = pygslib.plothtml.histgplt(parameters) >>> print ('CV', stats['xcvr']) >>> print ('Mean', stats['xmen']) >>> print ('Min', stats['xmin']) >>> print ('Max', stats['xmax']) # show the figure pygslib.plothtml.show(fig) ``` -------------------------------- ### Fill Wireframe with Blocks Source: https://opengeostat.github.io/pygslib/API.html Creates a block model from a VTK surface, indicating block inclusion (0 to 1). Tolerance can be applied for narrow wireframes. The output is for selection, not volume. ```python >>> mymodel.fillwireframe(surface, toll=0, overwrite=False) ``` -------------------------------- ### create_gridxz Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 2D grid in the XZ direction, based on the block model definition in X and Z. Overwrites the entire grid if overwrite is True. ```APIDOC ## create_gridxz ### Description Creates a full block 2D grid in defined in the XZ direction. The grid definition is taken from the block model definition in the X, and Z directions. ### Parameters * **overwrite** (boolean, default False) - Overwrite flag, if true the entire grid will be overwritten. ### Example ```python myblockmodel.create_gridxz(overwrite=False) ``` ``` -------------------------------- ### loadSTL Source: https://opengeostat.github.io/pygslib/API.html Loads a STL wireframe file into a VTK Polydata object. ```APIDOC ## loadSTL ### Description Loads a STL wireframe file. ### Parameters * **filenameSTL** (file path) - The path to the STL file. ### Returns * **polydata** (VTK Polydata object) - The loaded polydata. ``` -------------------------------- ### create_3Dgrid Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 3D grid/block model. Overwrites the entire grid if overwrite is True. ```APIDOC ## create_3Dgrid ### Description Creates a full block 3D grid/block model. ### Parameters * **overwrite** (boolean) - Overwrite flag, if true the entire grid will be overwritten. ### Example ```python myblockmodel.create_3Dgrid(overwrite=False) ``` ``` -------------------------------- ### Generate and Display Probability Plot Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt This snippet demonstrates how to create a probability plot using `pygslib.plothtml.probplt`. It configures parameters for data selection, weighting, and visual styling, then displays the plot. ```Python # plot CDF >>> parameters_probplt = { # gslib parameters for histogram calculation 'iwt' : 1, # input boolean (Optional: set True). Use weight variable? 'va' : mydholedb.table["CMP"].loc[(mydholedb.table['CMP']['Domain']==1) & (mydholedb.table['CMP']['CU']>0), 'CU'], # array('d') with bounds (nd) 'wt' : mydholedb.table["CMP"].loc[(mydholedb.table['CMP']['Domain']==1) & (mydholedb.table['CMP']['CU']>0), 'declustwt'], # array('d') with bounds (nd), wight variable (obtained with declust?) # visual parameters for figure (if a new figure is created) 'figure' : None, # a bokeh figure object (Optional: new figure created if None). Set none or undefined if creating a new figure. 'title' : 'Prob blot', # string (Optional, "Histogram"). Figure title 'xlabel' : 'Cu', # string (Optional, default "Z"). X axis label 'ylabel' : 'P[Cu>> >>> results, fig2 = pygslib.plothtml.probplt(parameters_probplt) >>> # show the plot >>> pygslib.plothtml.show(fig2) ``` -------------------------------- ### pygslib.vtktools.delaunay2D Source: https://opengeostat.github.io/pygslib/API.html Creates a triangulated Surface. ```APIDOC ## pygslib.vtktools.delaunay2D ### Description Creates a triangulated Surface. ### Parameters #### Parameters - **x,y,z** (np.ndarray [double, ndim=1]) - Coordinates of the input points - **Alpha** (double, default: 0.0) - For a non-zero alpha value, only edges or triangles contained within a sphere centered at mesh vertices will be output. Otherwise, only triangles will be output. - **Tolerance** (double, default: 0.001) - Specify a tolerance to control discarding of closely spaced points. This tolerance is specified as a fraction of the diagonal length of the bounding box of the points. - **constraints** (vtkPolydata or None) - constraint polygons, lines or polylines ### Returns - **surface** (vtkPolyData with wireframe) - vtkPolyData with wireframe ``` -------------------------------- ### create_IJK Source: https://opengeostat.github.io/pygslib/API.html Creates a new block model table with IJK indices. If blocks exist and overwrite is True, they will be removed first. ```APIDOC ## create_IJK ### Description Creates a new block model table with IJK indices. A new set of blocks will be created if there is no block defined. If there are blocks in the model and overwrite==True, the blocks will be removed first. ### Parameters * **overwrite** (boolean, default False) - Overwrite flag. ### Example ```python create_IJK(overwrite=True) ``` ``` -------------------------------- ### Create Empty Block Model Source: https://opengeostat.github.io/pygslib/Tutorial.html Initializes an empty block model object using the defined parameters. This object will store the block data. ```python mymodel=pygslib.blockmodel.Blockmodel(nx,ny,nz,xorg,yorg,zorg,dx,dy,dz) ``` -------------------------------- ### points2vtkfile Source: https://opengeostat.github.io/pygslib/API.html Saves points in a VTK file. ```APIDOC ## points2vtkfile ### Description Save points in vtk file. ### Parameters * **path** (str) - file path (relative or absolute) and name * **x, y, z** (np.ndarray) - coordinates of the points * **data** (array like) - array with variable values. ``` -------------------------------- ### Fit Hermite Coefficients (PCI) Source: https://opengeostat.github.io/pygslib/API.html Fits the Hermite coefficients (PCI) using raw and Gaussian values. The mean of z can be provided or will be calculated. ```python fit_PCI(z, y, H, meanz=np.nan) ``` -------------------------------- ### Declustering with Selected Cell Size and Weight Assignment Source: https://opengeostat.github.io/pygslib/Tutorial.html Sets up declustering parameters with a specific cell size and then assigns the calculated declustering weights to the drillhole interval table. ```python # parameters for declustering with the cell size selected parameters_declus = { 'x' : mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'xm'], 'y' : mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'ym'], 'z' : mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'zm'], 'vr' : mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'CU'], 'anisy' : 1., # y == x 'anisz' : 0.1, # z = x/20 'minmax' : 0, 'ncell' : 1, 'cmin' : 1000., 'cmax' : 1000., 'noff' : 8, 'maxcel' : -1} # declustering wtopt,vrop,wtmin,wtmax,error, \ xinc,yinc,zinc,rxcs,rycs,rzcs,rvrcr = pygslib.gslib.declus(parameters_declus) # Adding declustering weight to a drillhole interval table mydholedb.table["CMP"]['declustwt'] = 1 mydholedb.table["CMP"].loc[mydholedb.table['CMP']['Domain']==1, 'declustwt'] = wtopt # calculating declustered mean decl_mean = rvrcr[0] ``` -------------------------------- ### Calculate IX, IY, IZ from IJK Source: https://opengeostat.github.io/pygslib/API.html Calculates the IX, IY, IZ fields from IJK index. Existing values can be overwritten. ```python >>> myblockmodel.calc_ixyz_fromijk() >>> myblockmodel.calc_ixyz_fromijk(overwrite=True) ``` -------------------------------- ### Create Transformation Table Source: https://opengeostat.github.io/pygslib/API.html Creates a transformation table used for normal score transformations. Requires the variable 'z' and corresponding declustering weights 'w'. ```python pygslib.nonlinear.ttable(z, w) ``` -------------------------------- ### Compare Mean Grades Source: https://opengeostat.github.io/pygslib/Tutorial.html Calculate and print the mean grades for different estimation methods within the model and compare them to the mean grade of the original data. ```python >>> print ("Mean in model OK :", mymodel.bmtable['CU_OK'].mean()) >>> print ("Mean in model ID2 :", mymodel.bmtable['CU_ID2'].mean()) >>> print ("Mean in model NN :", mymodel.bmtable['CU_NN'].mean()) >>> print ("Mean in data :", mydholedb.table["CMP"]['CU'][mydholedb.table["CMP"]['Domain']==1].mean()) >>> print ("Declustered mean:", decl_mean) ('Mean in model OK :', 0.21166003) ('Mean in model ID2 :', 0.20810474) ('Mean in model NN :', 0.20687895) ('Mean in data :', 0.24149141734342264) ('Declustered mean:', 0.2251903672467954) ``` -------------------------------- ### create_gridyz Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 2D grid in the YZ direction, based on the block model definition in Y and Z. Overwrites the entire grid if overwrite is True. ```APIDOC ## create_gridyz ### Description Creates a full block 2D grid in defined in the YZ direction. The grid definition is taken from the block model definition in the Y, and Z directions. ### Parameters * **overwrite** (boolean, default False) - Overwrite flag, if true the entire grid will be overwritten. ### Example ```python myblockmodel.create_gridyz(overwrite=False) ``` ``` -------------------------------- ### Create 2D Grid in XZ Direction Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 2D grid in the XZ direction. The grid definition is taken from the block model definition. The entire grid can be overwritten. ```python >>> mymodel.create_gridxz(overwrite=False) ``` -------------------------------- ### Export Drillhole Core to VTK Line Source: https://opengeostat.github.io/pygslib/API.html Exports drillhole core data to a VTK line file. Ensure the table_name exists in the drillhole object. ```python >>> mydrillhole.export_core_vtk_line(table_name = 'assay', filename = 'assay_line.vtk') >>> ``` -------------------------------- ### Create Partial Model and Export to VTK Source: https://opengeostat.github.io/pygslib/Tutorial.html Filters the block model to include only blocks with a proportion greater than zero within the wireframe and exports the resulting partial model to a VTK unstructured grid file. ```python mymodel.set_blocks(mymodel.bmtable[mymodel.bmtable['D1']> 0]) mymodel.blocks2vtkUnstructuredGrid(path='model.vtu') ``` -------------------------------- ### Perform kriging estimation Source: https://opengeostat.github.io/pygslib/Tutorial.html This snippet executes the kriging estimation using the defined 'kt3d_Parameters'. It returns the estimation results, debug information, and a summary. ```python >>> # estimating in one block >>> estimate, debug, summary = pygslib.gslib.kt3d(kt3d_Parameters) ``` -------------------------------- ### Loading Drillhole Data with Pandas Source: https://opengeostat.github.io/pygslib/_sources/Tutorial.md.txt Loads drillhole collar, survey, and assay data from CSV files into Pandas DataFrames. These DataFrames are required by PyGSLIB. ```python # importing data from file collar = pd.read_csv('collar_BABBITT.csv') survey = pd.read_csv('survey_BABBITT.csv') assay = pd.read_csv('assay_BABBITT.csv') ``` -------------------------------- ### Import PyGSLIB Library Source: https://opengeostat.github.io/pygslib/Tutorial.html Imports the PyGSLIB library, which is central to performing geostatistical operations. ```python # import pygslib import pygslib ``` -------------------------------- ### Create Blocks Based on Surface Geometry Source: https://opengeostat.github.io/pygslib/API.html Generates blocks based on a VTK surface, with options to define the test criteria (inside, above, below, or inside open surfaces) and whether to overwrite existing fields. This function can be slow for large models. ```python fillblocks(surface, azm, dip, test, overwrite=False) ``` -------------------------------- ### blocks2vtkRectilinearGrid Source: https://opengeostat.github.io/pygslib/API.html Exports blocks of a full grid to a VTK RectilinearGrid file (.vtr). Requires all blocks (nx*ny*nz) to be defined. ```APIDOC ## blocks2vtkRectilinearGrid ### Description Exports blocks of a full grid to a vtkRectilinearGrid file. ### Parameters * **path** (string) – File name and path, without extension. The file extension (*.vtr) will be added automatically. ### Notes This will only work for full grids (all nx*ny*nz defined). All fields in the block model will be exported. ### Example ```python blocks2vtkRectilinearGrid('myfile') ``` ``` -------------------------------- ### Create 2D Grid in XY Direction Source: https://opengeostat.github.io/pygslib/API.html Creates a full block 2D grid in the XY direction. The grid definition is taken from the block model definition. The entire grid can be overwritten. ```python >>> mymodel.create_gridxy(overwrite=False) ``` -------------------------------- ### pygslib.vtktools.grid2vtkfile Source: https://opengeostat.github.io/pygslib/API.html Saves data in a Vtk Rectilinear Grid file. ```APIDOC ## pygslib.vtktools.grid2vtkfile ### Description Saves data in a Vtk Rectilinear Grid file. ### Parameters #### Parameters - **path** (str) - file path (relative or absolute) and name - **x,y,z** (np.ndarray) - coordinates of the points - **data** (array like) - array with variable values. ``` -------------------------------- ### Calculate Support Effect Coefficient (r) Source: https://opengeostat.github.io/pygslib/API.html Deduces the support effect coefficient 'r' by finding the root of the f_var_Zv equation using Brent's method. Requires Hermite coefficients (PCI) and block variance (Var_Zv). ```python pygslib.nonlinear.get_r(Var_Zv, PCI) ``` -------------------------------- ### Interactive Gaussian Anamorphosis Fitting Source: https://opengeostat.github.io/pygslib/API.html Fits a Gaussian anamorphosis interactively by creating experimental [z,y] pairs, back-transforming to [Z,Y] pairs, and calculating Hermite coefficients. Allows adjustment of parameters to approximate the declustered experimental variance. ```python pygslib.nonlinear.anamor(z, w, ltail=1, utail=1, ltpar=1, utpar=1, K=30, zmin=None, zmax=None, ymin=None, ymax=None, zamin=None, zamax=None, zpmin=None, zpmax=None, ndisc = 1000, **kwargs) ``` -------------------------------- ### Display First 3 Rows of Survey Data Source: https://opengeostat.github.io/pygslib/Tutorial.html Prints the first three rows of the survey DataFrame to inspect the loaded survey information. ```python print (survey.head(3)) ``` -------------------------------- ### pygslib.nonlinear.ttable Source: https://opengeostat.github.io/pygslib/API.html Creates a transformation table. ```APIDOC ## pygslib.nonlinear.ttable ### Description Creates a transformation table. ### Parameters * **z**, **w** (1D numpy arrays of floats) – Variable and declustering weight. ``` -------------------------------- ### Working with Shared Memory DataFrames Source: https://opengeostat.github.io/pygslib/API.html Demonstrates how to access and potentially modify the collar data stored in shared memory within a Drillhole object. ```python >>> shared_collar = mydrillholeDB.collar >>> ``` -------------------------------- ### PyGSLIB gslib postik Parameters Source: https://opengeostat.github.io/pygslib/API.html Parameters dictionary for the 'postik' function, used to post-process indicator kriging output (cdf). It includes options for output type, tail interpolation, and global distribution. ```python { # output option, output parameter 'iout' : , # int. 1 E-type,2 P and means outpar,3 p-quantile for outpar=p, and 4 conditional variance 'outpar' : , # float. Parameter for iout # the thresholds 'ccut1' : , # 1D array of floats. Cutoff used in MIK # volume support?, type, varred 'ivol' : , # int. If 1 the support correction is applied 'ivtyp' : , # int. 1 for affine correction and indirect lognormal correction 'varred' : , # float. Volumen correction, ussually r~ Block variance/Point variance # minimum and maximum Z value 'zmin' : , # float. Minimum value in local CDF 'zmax' : , # float. Maximum value in local CDF # lower,middle and upper tail: option, parameter 'ltail' : , # int. Lower tail interpolation function, 1 linear, 2 power model, 3 tabulated quantiles 'ltpar' : , # float. Lower tail function parameter 'middle' : , # int. Middle CDF interpolation function 1 linear, 2 power model, 3 tabulated quantiles 'mpar' : , # float. Middle CDF segment function parameter 'utail' : , # int. Upper tail interpolation function, 1 linear, 2 power model, 3 tabulated quantiles, 4 hyperbolic 'utpar' : , # float. Uper tail function parameter # maximum discretization 'maxdis' : , # int. Discretization of the local CDF. # 1D arrays with global distribution 'vr' : , # 1D array of floats for table look-up if tabulated quantiles are used as interpolation function } ``` -------------------------------- ### Export Block Model to VTK and CSV Source: https://opengeostat.github.io/pygslib/Tutorial.html Save the block model data in VTK unstructured grid format for visualization and export non-null estimates to a CSV file. ```python >>> # exporting block model to VTK (unstructured grid) >>> mymodel.blocks2vtkUnstructuredGrid(path='model.vtu') >>> # exporting to csv using Pandas >>> mymodel.bmtable['Domain']= 1 >>> mymodel.bmtable[mymodel.bmtable['CU_OK'].notnull()].to_csv('model.csv', index = False) ``` -------------------------------- ### GSLIB gamv3D Parameters Source: https://opengeostat.github.io/pygslib/API.html Dictionary structure for parameters used in the gamv3D function for 3D variogram calculations. ```python parameters = { ‘x’ : input rank-1 array(‘d’) with bounds (nd) ‘y’ : input rank-1 array(‘d’) with bounds (nd) ‘z’ : input rank-1 array(‘d’) with bounds (nd) ‘bhid’ : input rank-1 array(‘i’) with bounds (nd) ‘vr’ : input rank-2 array(‘d’) with bounds (nd,nv) ‘tminv : input float ‘tmax’ : input float ‘nlag’ : input int ‘xlag’ : input float ‘ndir’ : input int ‘ndip’ : input int ‘isill’ : input int ‘sills’ : input rank-1 array(‘d’) with bounds (nv) ‘ivtail’ : input rank-1 array(‘i’) with bounds (nvarg) ‘ivhead’ : input rank-1 array(‘i’) with bounds (nvarg) ‘ivtype’ : input rank-1 array(‘i’) with bounds (nvarg) } ``` -------------------------------- ### Display First 3 Rows of Assay Data Source: https://opengeostat.github.io/pygslib/Tutorial.html Prints the first three rows of the assay DataFrame to inspect the loaded assay information. ```python print (assay.head(3)) ``` -------------------------------- ### pygslib.vtktools.dmtable2wireframe Source: https://opengeostat.github.io/pygslib/API.html Takes a wireframe defined by two tables and creates a VTK polydata wireframe object. ```APIDOC ## pygslib.vtktools.dmtable2wireframe ### Description Takes a wireframe defined by two tables and creates a VTK polydata wireframe object. The input tables are as follow: * x, y, z : This is the points table * pid1,pid2,pid3: This is another table defining triangles with three point IDs. ### Parameters #### Parameters - **x,y,z** (1D array of floats) - coordinates of the points to be tested - **pid1,pid2,pid3** (1D array of integers) - triangles defined by three existing point IDs - **indexone** (boolean, Default False) - If false pid index start at zero, otherwise pid index start at one - **filename** (Str, Default None) - file name and path. If provided the file wireframe is saved to this file. ### Returns - **surface** (VTK polydata) - wireframe imported ``` -------------------------------- ### txt2intID Source: https://opengeostat.github.io/pygslib/API.html Creates an alternative integer BHID for a given table, which can be useful for functions compiled in Fortran. ```APIDOC ## txt2intID ### Description Creates an alternative BHID of type integer A new `BHIDint` will be created on the `table[table_name]` and in collar. `BHIDint` is just and ordered list of integers. BHIDint may be required in some functions compiles in Fortran, for example `pyslib.gslib.gamv` and `pyslib.gslib.kt3d`. ### Parameters: * **table_name** (_str_) – ### Examples ```python >>> >>> mydrillhole.collar.sort(['BHID'], inplace=True) >>> mydrillhole.table['assay'].sort(['BHID', 'FROM'], inplace=True) >>> mydrillhole.txt2intID('assay') >>> ``` ### Note The Collar and the table may be sorted. ```