maptek.vulcan.drillholes module

An interface to create and edit data within drillhole tables.

This includes classes for managing the database itself, the holes within the database, as well as tables, fields and intervals associated with individual drillholes.

class collar_scheme(db_table_name: str, holeid_field: str, easting_field: str, northing_field: str, elevation_field: str, total_depth_field: str | None = None)

Bases: object

Class containing information about the collar scheme, including the database table name of the collar table, as well as the names of the HoleId, Easting, Northing, Elevation and Total Depth fields.

__init__(db_table_name: str, holeid_field: str, easting_field: str, northing_field: str, elevation_field: str, total_depth_field: str | None = None)

Class containing information about the collar scheme, including the database table name of the collar table, as well as the names of the HoleId, Easting, Northing, Elevation and Total Depth fields.

Parameters:
  • db_table_name (str) – The name for the collar table in the database.

  • holeid_field (str) – The name for the hole ID field in the collar table.

  • easting_field (str) – The name for the Easting (X) field in the collar table.

  • northing_field – The name for the Northing (Y) field in the collar table.

  • elevation_field – The name for the elevation (Z) field in the collar table.

  • total_depth_field (str, optional) – The name for the table depth field in the collar table.

property db_table_name
property holeid_field
property easting_field
property northing_field
property elevation_field
property total_depth_field
class survey_scheme(db_table_name: str, bearing_field: str, inclination_field: str, depth_field: str)

Bases: object

Class containing information about the survey scheme, including the database table name of the survey table, as well as the names of the Bearing, Inclination, and Depth fields.

__init__(db_table_name: str, bearing_field: str, inclination_field: str, depth_field: str)

Class containing information about the survey scheme, including the database table name of the survey table, as well as the names of the HoleId, Easting, Northing, Elevation and Total Depth fields.

Parameters:
  • db_table_name (str) – The name for the survey table in the database.

  • bearing_field (str) – The name for the bearing field in the survey table.

  • inclination_field (str) – The name for the inclination field in the survey table.

  • depth_field – The name for the depth field in the survey table.

property db_table_name
property bearing_field
property inclination_field
property depth_field
class interval_scheme(bearing_field: str, inclination_field: str, depth_field: str)

Bases: object

Class containing information about a basic interval scheme, including the names of the From, To, and Thickness fields.

__init__(bearing_field: str, inclination_field: str, depth_field: str)

Class containing information about a basic interval scheme, including the names of the From, To, and Thickness fields.

Parameters:
  • from_field (str) – The name for the from field in the survey table.

  • to_field (str) – The name for the to field in the survey table.

  • thickness_field – The name for the thickness field in the survey table.

property from_field
property to_field
property thickness_field
class drillhole_database(other)

Bases: object

An interface to create and edit data within drillhole databases.

__init__(other)

Exposes an interface to edit data within drillhole databases.

classmethod read(filename: str | PathLike) Self

Loads an existing drillhole database from file in read-only mode.

Parameters:

filename (str or os.PathLike) – The filename of the database to load.

Returns:

The loaded database.

Return type:

drillhole_database

Raises:

OSError – If the database fails to load.

classmethod edit(filename: str | PathLike) Self

Loads an existing drillhole database from file in edit mode.

Parameters:

filename (str or os.PathLike) – The filename of the database to load.

Returns:

The loaded database.

Return type:

drillhole_database

Raises:

OSError – If the database fails to load.

classmethod create(filename: str | PathLike, design: isis_design | str | PathLike | None = None, *, collar_name: str = 'COLLAR', survey_name: str = 'SURVEY') Self

Creates a new drillhole database.

Optionally uses an existing Isis design (.dsf).

If no design is given, the database is created with collar, survey and geological tables.

Parameters:
  • filename (str or os.PathLike) – The filename for the new database.

  • design (isis_design or str or os.PathLike, optional) – The design to construct the database from. This can be either an isis_design object or a filepath to a .dsf file.

Returns:

The newly created database.

Return type:

drillhole_database

Raises:

TypeError – If design is not an isis_design or the path to the design.

is_read_only() bool

Checks whether the database is open in read-only mode.

Returns:

True if the database is open in read-only mode, False otherwise.

Return type:

bool

new_hole(hole_name: str, ignore_no_interval_tables: bool = False) Iterator[drillhole]

Adds a new drillhole to the database, using the existing scheme.

Parameters:
  • hole_name (str) – The name (HoleId) to assign to the hole.

  • ignore_no_interval_tables (bool (optional)) – Flag to ignore errors when only no interval tables exist except survey.

Returns:

The newly created drillhole.

Return type:

drillhole

delete_hole(hole_name: str) bool

Removes a drillhole from the database.

Parameters:

hole_name (str) – The name (HoleId) of the drillhole to delete.

Returns:

True if successful; false otherwise.

Return type:

bool

copy_hole(hole_to_clone: str, new_hole_name: str, ignore_no_interval_tables: bool = False) Iterator[drillhole]

Create a copy of a drillhole under a different name.

This function is intended for use with a context manager; where the drillhole will automatically save when exiting context.

Parameters:
  • hole_to_clone (str) – The name of the hole to make a copy of.

  • new_hole_name (str) – The name to assign to the copy.

  • ignore_no_interval_tables (bool (optional)) – Flag to ignore errors when only no interval tables exist except survey.

Returns:

The newly created drillhole.

Return type:

drillhole

hole_ids() list[str]

Gets the list of drillholes in the database.

Returns:

The names (HoleIds) of all the drillholes in the database.

Return type:

list[str]

read_holes()
edit_holes()
read_hole(hole_name: str, ignore_no_interval_tables: bool = False) Iterator[drillhole]

Gets a read-only drillhole.

Intended for use in a ‘with’ block:

>>>  with database.read_drillhole("HoleName") as hole:
>>>      hole.raw_collar
(27562.1, 2391.6, 875.4)
Parameters:
  • hole_name (str) – The name (HoleId) of the hole to get.

  • ignore_no_interval_tables (bool (optional)) – Flag to ignore errors when only no interval tables exist except survey.

Yields:

drillhole – The requested drillhole.

edit_hole(hole_name: str) Iterator[drillhole]

Gets an editable drillhole.

Intended for use in a ‘with’ block:

>>>  with database.edit_drillhole("HoleName") as hole:
>>>      hole.raw_collar = (1, 2, 3)

The hole will automatically save changes when exiting scope, unless an error is raised.

Parameters:

hole_name – The name (HoleId) of the hole to get.

Yields:

drillhole – The requested drillhole.

Raises:

PermissionError – If the database is open in read-only mode.

property database_table_names: list[str]

The names of all tables in the database.

list_fields(table_name) list[str]

Gets the list of fields in a table.

Parameters:

table_name (str) – The name of the table to retrieve the fields from.

Returns:

The names of the fields.

Return type:

list[str]

property interval_table_names: list[str]

The names of all interval tables in the database.

property tables: list[table_information]

The list of tables in the database and their associated fields.

get_table_interval_scheme(table_name: str) interval_scheme

Gets the interval scheme information for a table (interval table only). result will be empty if not valid.

Parameters:

table_name (str) – The name of the interval table.

Returns:

  • interval_scheme object with the from/to/thickness fields if set.

  • All fields will be blank in invalid tables.

set_table_for_interval_reading(table_name: str, from_field: str | None, to_field: str, thickness_field: str | None = None) bool

Sets up a non-interval table for reading as an interval table by defining at least the ‘TO’ field for depth calculations.

Parameters:
  • table_name (str) – The name of the non-interval table.

  • from_field (str|None) – The field that defines the FROM or top of interval. None if not applicable.

  • to_field (str) – The field that defines the TO or bottom of the interval

  • thickness_field (str|None (Optional)) – The thickness field, describing the total thickness for the interval.

Return type:

True if successfully set.

See also

database_table_names

The list of all tables in the database.

interval_table_names

The list of all interval tables in the database.

add_assay_table(table_name: str)

Adds an Assay table to a newly created database.

This table initially contains only ‘FROM’ and ‘TO’ fields.

This is only callable on a database which has not yet been populated with drillholes.

Parameters:

table_name (str) – The name to assign to the table.

See also

add_text_field_to_table

Add a new text field to the table.

add_float_field_to_table

Add a new float field to the table.

add_int_field_to_table

Add a new integer field to the table.

add_geology_table(table_name: str)

Adds a Geology table to a newly created database.

This table initially contains only ‘FROM’ and ‘TO’ fields.

This is only callable on a database which has not yet been populated with drillholes.

Parameters:

table_name (str) – The name to assign to the table.

See also

add_text_field_to_table

Add a new text field to the table.

add_float_field_to_table

Add a new float field to the table.

add_int_field_to_table

Add a new integer field to the table.

add_analytical_table(table_name: str)

Adds an Analytical table to a newly created database.

This table initially contains only ‘FROM’ and ‘TO’ fields.

This is only callable on a database which has not yet been populated with drillholes.

Parameters:

table_name (str) – The name to assign to the table.

See also

add_text_field_to_table

Add a new text field to the table.

add_float_field_to_table

Add a new float field to the table.

add_int_field_to_table

Add a new integer field to the table.

add_table(table_name: str, from_field: str | None, to_field: str, description: str | None)

Adds an interval table to a newly created database.

This table requires at least the TO field to be assigned.

This is only callable on a database which has not yet been populated with drillholes.

Parameters:
  • table_name (str) – The name to assign to the table.

  • from_field (str|None) – The field that defines the FROM or top of interval

  • to_field (str) – The field that defines the TO or bottom of the interval

  • description (str|None) – The description for the table

See also

add_text_field_to_table

Add a new text field to the table.

add_float_field_to_table

Add a new float field to the table.

add_int_field_to_table

Add a new integer field to the table.

add_text_field_to_table(table_name: str, field_name: str, field_length: int = 10, description: str = 'Created via Python script.')

Adds a new text field to an existing interval table.

Parameters:
  • table_name (str) – The name of the table to add the field to.

  • field_name (str) – The name to assign to the field.

  • field_length (int, optional) – The number of characters to allow in the field.

  • description (str, optional) – The description to assign to the field.

add_float_field_to_table(table_name: str, field_name: str, field_length: int = 10, decimals: int = 3, description: str = 'Created via Python script.')

Adds a new float field to an existing interval table.

Parameters:
  • table_name (str) – The name of the table to add the field to.

  • field_name (str) – The name to assign to the field.

  • field_length (int, optional) – The number of characters to allow in the field.

  • decimals (int, optional) – The number of decimal places to display in the field.

  • description (str, optional) – The description to assign to the field.

add_int_field_to_table(table_name: str, field_name: str, field_length: int = 10, description: str = 'Created via Python script.')

Adds a new integer field to an existing interval table.

Parameters:
  • table_name (str) – The name of the table to add the field to.

  • field_name (str) – The name to assign to the field.

  • field_length (int, optional) – The number of characters to allow in the field.

  • description (str, optional) – The description to assign to the field.

save_hole(drillhole: drillhole) bool

Saves a drillhole after any data changes have been made. Any changes will NOT be saved back to the database unless either this is called.

Note this is called automatically when exiting drillhole context managers if no exceptions are raised.

Parameters:

drillhole (drillhole) – The drillhole with changes to save.

Returns:

True if the drillhole is successfully saved; false otherwise.

Return type:

bool

property collar_fields: list[str]

Returns a list of the collar fields in the database.

property collar_scheme: collar_scheme

Returns the scheme of the collar table.

property survey_scheme: survey_scheme

Returns the scheme of the survey table.

property hole_count: int

Returns the number of drillholes in the database.

class table_information(database, name)

Bases: object

Class representing the mapping of fields to tables in the database.

property fields: list[str]

Names of the fields in the table.

property name: str

Name of the table.

class drillhole(drillhole)

Bases: object

Class representing a single drillhole object within a database.

All drillholes that originate from the same database will have the same tables and fields, but have no restrictions on containing the same intervals.

get_interval_table(table_name: str) drillhole_table

Get an interval table from the drillhole.

Parameters:

table_name – The name of the table to get.

Raises:

IndexError – If table_name is not an existing table.

property raw_collar: point

The raw collar of the drillhole.

Note that this value is not adjusted for any coordinate systems applied to the hole.

point_at_depth(depth: float) tuple[float, float, float]

Gets the coordinates of the drillhole at a given depth.

Parameters:

depth (float) – The depth at which to query the coordinates.

Returns:

  • Northing (float) – The northing value at the given depth.

  • Easting (float) – The easting value at the given depth.

  • Elevation (float) – The elevation value at the given depth.

property total_depth: float

The total depth of the drillhole.

interval_count(table_name: str) int

Gets the number of intervals in an interval table.

Parameters:

table_name (str) – The name of the interval table.

Returns:

The number of intervals in the table.

Return type:

int

set_collar_field(field_name: str, value: str | float) bool

Sets the value in a field in the collar table.

Parameters:
  • field_name (str) – The name of the field to set the value in.

  • value (str or float) – The value to assign to the field.

Returns:

True if successful; false otherwise.

Return type:

bool

get_collar_field(field_name: str) str | float

Gets the value of a field in the collar table.

get_interval_value(table_name: str, field_name: str, interval: int) str | float

Gets the value of a field at a given interval.

class drillhole_table(other)

Bases: object

Class representing a table in a drillhole_database which contains interval data.

property name: str

The name of the interval table.

get_interval(index: int) interval

Gets an interval from the table.

Parameters:

index (int) – The index of the interval to get.

Returns:

The interval.

Return type:

interval

Raises:

IndexError – If the index is less than 0 or greater than the number of intervals.

append_interval() interval

Adds a new interval with the appropriate empty fields to the interval table.

Returns:

The newly added interval.

Return type:

interval

remove_interval(index: int)

Removes an interval from the table. Note that this dynamically updates the indexes of all other intervals in the table.

Therefore it is not possible to do something like

>>> for i in range(0, table.interval_count):
...     table.remove_interval(i)

Instead, this can be achieved by doing

>>> for _ in range(0, table.interval_count):
...     table.remove_interval(0)
Parameters:

index (int) – The index of the interval to remove.

Raises:

IndexError – If the given index is not a valid interval index.

get_field_values(field_name: str) list[str] | list[float]

Gets the list of values in a field for all intervals.

Parameters:

field_name (str) – The name of the field to get values from.

Returns:

The values in the field for all intervals.

Return type:

list[str] or list[float]

property intervals: Iterator[interval]

Returns the intervals in the table.

It is not safe to add or remove intervals during iteration, this should be done outside of any iteration.

Yields:

interval – The next interval in the the table.

property field_names: list[str]

Returns the list of fields in the table.

property interval_count: int
class interval

Bases: object

Class representing a region between two depths in a drillhole.

has_field(field_name: str) bool

Queries whether a field exists for the interval.

Parameters:

field_name (str) – The name of the field to check exists.

Returns:

True if the field exists; false otherwise.

Return type:

bool

is_field_numeric(field_name: str) bool

Queries whether a field is numeric for the interval.

Parameters:

field_name (str) – The name of the field to check exists.

Returns:

True if the field is numeric; false otherwise.

Return type:

bool

is_field_empty(field_name: str) bool

Queries whether a field has a value for the interval.

Parameters:

field_name (str) – The name of the field to check has a value.

Returns:

True if the field is empty; false otherwise.

Return type:

bool

set_field(field_name: str, value: float | str) bool

Sets the value of a field for the interval.

Parameters:
  • field_name (str) – The name of the field to set the value in.

  • value (float or str) – The value to set in the field.

Returns:

True if the field value was successfully set; False otherwise.

Return type:

bool

set_name(interval_name)
__getitem__(field_name)

Accesses interval field values using the index operator.

>>> from_value = interval["FROM"]
__setitem__(field_name, value)

Sets interval field values using the index operator.

>>> interval["FROM"] = 34.67
get_field(field_name: str) str | float

Gets the value of a field for the interval.

Parameters:

field_name (str) – The name of the field to get the value of.

Returns:

  • str – The value of the field.

  • float – The value of the field.

property from_depth: float

Returns the value of the ‘FROM’ field.

property to_depth: float

Returns the value of the ‘TO’ field.