geosoft.gxpy.gdb submodule

Geosoft databases for line-oriented spatial data.

Classes:
Geosoft_gdb:Geosoft line database
Line:line handling
Channel:channel handling
Constants:
LINE_TYPE_NORMAL:
 geosoft.gxapi.DB_LINE_TYPE_NORMAL
LINE_TYPE_BASE:geosoft.gxapi.DB_LINE_TYPE_BASE
LINE_TYPE_TIE:geosoft.gxapi.DB_LINE_TYPE_TIE
LINE_TYPE_TEST:geosoft.gxapi.DB_LINE_TYPE_TEST
LINE_TYPE_TREND:
 geosoft.gxapi.DB_LINE_TYPE_TREND
LINE_TYPE_SPECIAL:
 geosoft.gxapi.DB_LINE_TYPE_SPECIAL
LINE_TYPE_RANDOM:
 geosoft.gxapi.DB_LINE_TYPE_RANDOM
LINE_CATEGORY_FLIGHT:
 geosoft.gxapi.DB_CATEGORY_LINE_FLIGHT
LINE_CATEGORY_GROUP:
 geosoft.gxapi.DB_CATEGORY_LINE_GROUP
LINE_CATEGORY_NORMAL:
 geosoft.gxapi.DB_CATEGORY_LINE_NORMAL
FORMAT_NORMAL:geosoft.gxapi.DB_CHAN_FORMAT_NORMAL
FORMAT_EXP:geosoft.gxapi.DB_CHAN_FORMAT_EXP
FORMAT_TIME:geosoft.gxapi.DB_CHAN_FORMAT_TIME
FORMAT_DATE:geosoft.gxapi.DB_CHAN_FORMAT_DATE
FORMAT_GEOGR:geosoft.gxapi.DB_CHAN_FORMAT_GEOGR
FORMAT_SIGDIG:geosoft.gxapi.DB_CHAN_FORMAT_SIGDIG
FORMAT_HEX:geosoft.gxapi.DB_CHAN_FORMAT_HEX
CHAN_ALL:None
CHAN_NORMAL:0
CHAN_ARRAY:1
CHAN_DISPLAYED:2
SYMB_LINE_NORMAL:
 geosoft.gxapi.DB_CATEGORY_LINE_NORMAL
SYMB_LINE_FLIGHT:
 geosoft.gxapi.DB_CATEGORY_LINE_FLIGHT
SYMB_LINE_GROUP:
 geosoft.gxapi.DB_CATEGORY_LINE_GROUP
SELECT_INCLUDE:geosoft.gxapi.DB_LINE_SELECT_INCLUDE
SELECT_EXCLUDE:geosoft.gxapi.DB_LINE_SELECT_EXCLUDE
COMP_NONE:geosoft.gxapi.DB_COMP_NONE
COMP_SPEED:geosoft.gxapi.DB_COMP_SPEED
COMP_SIZE:geosoft.gxapi.DB_COMP_SIZE
READ_REMOVE_DUMMYROWS:
 1
READ_REMOVE_DUMMYCOLUMNS:
 2
SYMBOL_LOCK_NONE:
 geosoft.gxapi.DB_LOCK_NONE
SYMBOL_LOCK_READ:
 geosoft.gxapi.DB_LOCK_READONLY
SYMBOL_LOCK_WRITE:
 geosoft.gxapi.DB_LOCK_READWRITE
DRAW_AS_POINTS:0
DRAW_AS_LINES:1

Note

Regression tests provide usage examples: Tests

class Channel(gdb, name)

Bases: object

Class to work with database channels. Use constructor Channel.new to create a new channel. Use instance properties to work with channel properties.

Parameters:
  • gdb – database instance
  • name – channel name string, must exist - see new() to create a new channel

New in version 9.3.

array

Array channel width, 1 for non-array channels

New in version 9.3.

class_

Class name to which this channel is associated. Can be set.

New in version 9.3.

decimal

Number of displayed decimal places, can be set.

New in version 9.3.

delete()

Delete the channel and all associated data. After calling this method this channel instance is no longer valid.

New in version 9.3.

format

Channel display format:

FORMAT_NORMAL normal decimal or integer format
FORMAT_EXP exponential
FORMAT_TIME geosoft time (HH:MM:SS.ssss)
FORMAT_DATE date (YYYY/MM/DD)
FORMAT_GEOGR geographic (deg.mm.ss.ssss)
FORMAT_SIGDIG decimals is number of significant digits
FORMAT_HEX hexadecimal

New in version 9.3.

is_array

True if this is an array channel

New in version 9.3.

label

Channel label used in display graphics, normally the same as the channel name. Can be set.

New in version 9.3.

lock

Lock setting:

-1 unlocked (SYMBOL_LOCK_NONE)
0 read-locked (SYMBOL_LOCK_READ)
1 write-locked (SYMBOL_LOCK_WRITE)

Can be set.

lock_set_(fn, v)
locked

True if symbol is locked. Use property lock to determine if read or write lock, or to set the lock.

Setting to False unlocks the symbol.

New in version 9.3.

name

Channel name.

New in version 9.3.

classmethod new(gdb, name, dtype=<class 'numpy.float64'>, array=1, dup=None, details=None, replace=False, unit_of_measure=None)

Create a new channel.

Parameters:
  • gdb – Geosoft_gdb instance
  • name – channel name
  • dtype – numpy data type, defaule np.float64
  • array – array size, default 1
  • dup – duplicate properties of this channal (name, symbol or Channel)
  • details – dictionary of other channel properties - see Geosoft_gdb.set_channel_details
  • replaceTrue to replace existing channel. Existing channel information and data is lost. default is False.
  • unit_of_measure – unit of measurement of the data
Returns:

Channel instance

protect

True if this channel is protected from modification. Can be set.

New in version 9.3.

symbol

Channel symbol

New in version 9.3.

type

Geosoft data type.

New in version 9.3.

unit_of_measure

Unit of measure, can be set.

New in version 9.3.

width

Display window width in characters. Can be set.

New in version 9.3.

exception GdbException(message)

Bases: geosoft.GXRuntimeError

Exceptions from geosoft.gxpy.gdb.

New in version 9.1.

class Geosoft_gdb(name=None, db=None)

Bases: geosoft.gxpy.geometry.Geometry

Class to work with Geosoft databases. This class wraps many of the functions found in geosoft.gxapi.GXDB.

Constructors:
open open an existing file, or if not specified open/lock the current database
new create a new database

Some typical programming patterns

Python Oasis extension opens and reads through all data in the current database:

import os,sys
import numpy as np
import gxpy.gx as gxp
import gxpy.gdb as gxdb

# open the current database in the open project
gdb = gxdb.Geosoft_gdb.open()
for line in gdb.list_lines():

    npd,ch,fid = gdb.read_line(line)
    # npd is a 2D numpy array to all data in this line.
    # ch is a list of the channels, one channel for each column in npd.
    # Array channels are expanded with channel names "name[0]", "name[1]" ...
    # fid is a tuple (start,increment) fiducial, which will be the minimum start and smallest increment.

    # ... do something with the data in npd ...

External Python program to open and read through all data in a database:

import os,sys
import numpy as np
import gxpy.gx as gx
import gxpy.gdb as gxdb

# initalize the gx environment - required for external programs.
gxp = gx.GXpy()

# open a database
gdb = gxdb.Geosoft_gdb.open('test.gdb')
for line in gdb.list_lines():

    npd,ch,fid = gdb.read_line(line)
    # npd is a 2D numpy array to all data in this line.
    # ch is a list of the channels, one channel for each column in npd.
    # Array channels are expanded with channel names "name[0]", "name[1]" ...
    # fid is a tuple (start,increment) fiducial, which will be the minimum start and smallest increment.

    # ... do something with the data in npd ...

The following creates a new channel that is the distance from the origin to the X,Y,Z location of every point.

...
gdb = gxdb.Geosoft_gdb.open('test.gdb')
for line in gdb.list_lines():

    npd,ch,fid = gdb.read_line(line, channels=['X','Y','Z'])

    npd = np.square(npd)
    distance_from_origin = np.sqrt(npd[0] + npd[1] + npd[2])

    gdb.write_channel(line, 'distance', distance_from_origin, fid)

New in version 9.1.

Changed in version 9.3: float numpy arrays use np.nan for dummies so dummy filtering no longer necessary.

Changed in version 9.3.1: inherits from geosoft.gxpy.geometry.Geometry

channel_details(channel)

Return dictionary of channel details

Parameters:channel – channel name or symbol
Returns:dictionary:
Key Meaning
name channel name
symbol channel symbol
class class name
format format, one of gxapi.DB_CHAN_FORMAT constants
width display width in characters
decimal decimal places to display
unit measurement unit
label channel label, which can be different from the channel name
protect protection: 0 can be modified; 1 protected from modification
columns number data columns, 1 for normal channels, n for VA channels
type data type, one of gxapi.DB_CATEGORY_CHAN constants

New in version 9.1.

channel_dtype(channel)

Returns channel numpy dtype

Parameters:channel – channel name or symbol
Returns:numpy dtype

New in version 9.1.

channel_fid(line, channel)

Return the fiducial of a line, channel

Parameters:
  • line – line name, symbol or Line
  • channel – channel name, symbol or channel
Returns:

(start,increment)

channel_name_symb(chan)

Return channel name, symbol

Parameters:chan – channel name, or symbol number or Channel instance
Returns:line name, symbol, returns (‘’,-1) if invalid
Raises:GdbException if channel does not exist

New in version 9.1.

channel_width(channel)

Channel array width, 1 for normal channels, >1 for VA channels.

Parameters:channel – channel symbol or name
Returns:array dimension, 1 for non-array channels

New in version 9.1.

clear_extent()

Clear the extent cache.

New in version 9.3.1.

close(discard=False)

Close the database and free resources

Parameters:discard – True to discard the database files(s) after closing.

New in version 9.4.

commit()

Commit database changes.

New in version 9.1.

compression

database compression setting

coordinate_system

Coordinate system of the current xyz_channels. Can be set from any geosoft.gxpy.coordinate_system.Coordinate_system constructor.

Changed in version 9.3: added setter

data_has_changed

True if data has changed

db_size_kb

database size in kb

delete_channel(channels)

Delete channel(s) by name or symbol.

Parameters:channels – channel name or symbol, or a list of channel names or symbols

New in version 9.1.

delete_line(lines)

Delete line(s) by name or symbol.

Parameters:lines – line name/symbol, or a list of names/symbols

New in version 9.1.

discard()

Discard database changes.

New in version 9.1.

exist_symb_(symb, symb_type)

Check if a symbol exists of the required type.

Parameters:
  • symb – symbol name, number or instance
  • symb_type – one of DB_SYMB_TYPE
Returns:

True if the symbol exists and is the expected symbol type, False otherwise

New in version 9.1.

extent

Return the spatial extent of all selected data in the database as a geosoft.gxpy.geometry.Point2.

Returns:geosoft.gxpy.geometry.Point2 of minimum, maximum, or None if no spatial information.

New in version 9.2.

figure_map(file_name=None, overwrite=False, title=None, draw=0, features=None, **kwargs)

Create a figure map file from selected lines in the database.

Parameters:
  • file_name – the name of the map, if None a temporary default map is created.
  • overwriteTrue to overwrite map file should it exist
  • title – Title added to the image
  • drawDRAW_AS_POINTS to draw a dot at each point (default). Long lines are decimated. DRAW_AS_LINES to draw lines with a line label at each end.
  • features

    list of features to place on the map, default is (‘SCALE’, ‘NEATLINE’)

    ’ALL’ include all features. This is the default.
    ’SCALE’ show a scale bar
    ’NEATLINE’ draw a neat-line around the image
    ’ANNOT_XY’ annotate map coordinates
    ’ANNOT_LL’ annotate map Latitude, Longitude
  • kwargs – passed to geosoft.gxpy.map.Map.new

New in version 9.3.

file_name

Database file name.

free_blocks

number of free blocks

get_gx_metadata()

Return the database Geosoft metadata as a Geosoft geosoft.gxpy.metadata.Metadata instance.

The internal database metadata is used to store various database properties that are not intended to be part of the exposed dataset metadata exposed by the :attr:metadata property.

If you wish to add your own metadata to the internal properties you can use the geosoft.gxpy.metadata module to add metadata and save it to the database using geosoft.gxapi.GXDB.set_meta.

New in version 9.3.

gxdb

The geosoft.gxapi.GXDB instance handle

index_size_kb

index size in kb

is_channel(chan, raise_err=False)

Returns True if the channel name exists in the database.

Parameters:
  • chan – channel name
  • raise_err – True to raise an error if it does not exist

New in version 9.1.

is_line(line, raise_err=False)

Returns True if the named line exists in the database.

Parameters:
  • line – line name
  • raise_err – True to raise an error if it does not exist

New in version 9.1.

line_details(line)

Return dictionary of line details

Parameters:line – channel name or symbol
Returns:dictionary:
Key Meaning
name line name
symbol line symbol
type line type, one of gxapi.DB_LINE_TYPE
category one of SYMB_LINE
date date of the line
number numeric line number
flight flight number
version line version number
groupclass class name for grouped lines, None if not a grouped line

New in version 9.1.

line_name_symb(line, create=False)

Return line name, symbol

Parameters:
  • line – line name, or symbol number
  • createTrue to create a line if one does not exist
Returns:

line name, symbol

Raises:

GdbException if line not found or cannot be created

New in version 9.1.

lines(select=True)

Deprecated since version 9.2: use list_lines()

list_channels(chan=None)

Return a dict of channels in the database.

Parameters:chan

channel filter, default CHAN_ALL:

CHAN_ALL all channels, normal and VA
CHAN_NORMAL normal channels only
CHAN_ARRAY VA channels only
Returns:dictionary {channel_names: channel_symbols}

New in version 9.1.

list_lines(select=True)

List of lines in the database, returned as a {name: symbol} dictionary

Parameters:selectTrue to return selected lines, False to return all lines
Returns:dictionary (line name: symbol)

New in version 9.1.

list_values(chan, umax=1000, selected=True, dupl=50, progress=None, stop=None)

Build a list of unique values in a channel. Uniqueness depends on the current display format for the field.

Parameters:
  • chan – channel to scan
  • umax – maximum values allowed, once this maximum is reached scanning stops, default 1000
  • selectedTrue to scan only selected lines
  • dupl – Stop growing list after this many lines fail to grow the list, 0 scans all lines
  • progress – progress reporting function
  • stop – stop check function
Returns:

list of values, represented as a string

New in version 9.1.

lock_read_(s)

internal function to lock a symbol for read

lock_set_(s, fn, v)
lock_write_(s)

internal function to lock a symbol for write

lost_blocks

lost blocks that might be freed

max_blobs

maximum blobs allowed

max_block_size_bytes

maximum block size in bytes

max_channels

maximum number of channels allowed

max_compressed_channel_bytes

maximum compressed data per channel per line in bytes

max_lines

maximum number of lines allowed

metadata

Return the database XML metadata as a dictionary. Can be set, in which case the dictionary items passed will be added to, or replace existing XML metadata.

New in version 9.2.

classmethod new(name=None, max_lines=500, max_channels=200, max_blobs=0, page_size=1024, comp=None, overwrite=False)

Create a new database.

Parameters:
  • name – database name, if None a temporary database is created
  • max_lines – maximum number of lines, default 500
  • max_channels – maximum number of channels, default 200
  • max_blobs – maximum number of blobs, default lines*channels+20
  • comp

    compression:

    COMP_NONE
    COMP_SPEED (default)
    COMP_SIZE
  • overwriteTrue to overwrite existing database. Default is False, GdbException if file exists.
  • page_size – page size (default is 1024), which limits the amount of compressed data that can be stored in a single channel on a line. The maximum compressed data size for a channel will be this number * 65534 (default 1024 * 65534 = 64 MB of compressed data). This will be forced to a power of 2 between 64 and 4096, which would allow for a maximum of 256 MB compressed data per channel per line.
Returns:

Geosoft_gdb instance

New in version 9.1.

Changed in version 9.3: added parameter overwrite=False

Changed in version 9.4: name=None creates a temporary database

new_channel(name, dtype=<class 'numpy.float64'>, array=1, dup=None, details=None)

Return a channel symbol, create if it does not exist.

Parameters:
  • name – channel name
  • dtype – numpy dtype (ie. np.int64)
  • array – array columns (default is 1)
  • dup – duplicate properties of this channel (name, symbol, channel)
  • details – dictionary containing channel details, see channel_details()
Returns:

channel symbol

Examples:

symb = gdb.newChan('X')
symb = gdb.newChan('X', dtype=np.float64, details={'decimal':4})

New in version 9.1.

Changed in version 9.3: added support for duplication an existing channel via dup=

new_line(line, linetype=None, group=None, dup=None)

Create a new line symbol. If line exists an error is raised.

Parameters:
  • line – line name
  • linetype

    line type for creating a new line, ignored if group defines

    SYMB_LINE_NORMAL normal lines, name is a string
    SYMB_LINE_FLIGHT flight lines, first letter is line type
  • group – group name for a grouped class
  • dup – duplicate from an existing line (name, symbol of Line)
Returns:

line symbol

See also

function create_line_name to create a valid line name.

New in version 9.1.

number_of_blocks

number of blocks

classmethod open(name=None)

Open an existing database.

Parameters:name – name of the database, default is the current project database
Returns:Geosoft_gdb instance

New in version 9.1.

pages_for_blobs

pages consumed by blobs

readLine(*args, **kwargs)

Deprecated since version 9.2: use read_line()

read_channel(line, channel, dtype=None)

Read data from a single channel.

Parameters:
  • line – line name or symbol
  • channel – channel name or symbol
  • dtype – type wanted, default same as the channel data
Returns:

numpy data, fid (start, increment)

For dtype=np.float, dummy values will be np.nan. For integer types dummy values will be the Geosoft dummy values.

New in version 9.1.

read_channel_va(line, channel, dtype=None)

Read VA data from a single channel, return in a va.

Parameters:
  • line – line name or symbol
  • channel – channel name or symbol
  • dtype – type wanted, default same as the channel data
Returns:

va

New in version 9.2.

read_channel_vv(line, channel, dtype=None)

Read data from a single channel, return in a vv.

Parameters:
  • line – line name or symbol
  • channel – channel name or symbol
  • dtype – type wanted, default same as the channel data
Returns:

vv

New in version 9.2.

read_line(line, channels=None, dtype=None, fid=None, dummy=None)

Read a line of data into a numpy array.

Parameters:
  • line – line to read, string or symbol number
  • channels – list of channels, strings or symbol number. If empty, read all channels
  • dtype – numpy data type for the array, default np.float64 for multi-channel data, data type for single channel data. Use “<Unnn” for string type.
  • fid – required fiducial as tuple (start,incr), default smallest in data
  • dummy

    dummy_handling for multi-channel read, default leaves dummies in place.:

    READ_REMOVE_DUMMYROWS remove rows with dummies, fiducials lose meaning
    READ_REMOVE_DUMMYCOLUMNS remove columns with dummies
Returns:

2D numpy array shape(records,channels), list of channel names, (fidStart,fidIncr)

Raises:

GdbException if first channel requested is empty

VA channels are expanded by element with channel names name[0], name[1], etc.

This method is intended for relatively simple databases in relatively simple applications. If your database has a lot of channels, or wide array channels it will be more efficient to read and work with just the channels you need. See read_channel, read_channel_vv and read_channel_va.

Examples:

# npd - returned numpy array shape (n, number of channels)
# ch  - list of returned channels names, array channels expanded to array[0], array[1], ...
# fid - tuple (fidStart,fidIncrement), channels resampled as necessary

npd,ch,fid = gdb.read_line('L100')                           # read all channels in line "L100"
npd,ch,fid = gdb.read_line(681)                              # read all channels in line symbol 681
npd,ch,fid = gdb.read_line('L100','X')                       # read channel 'X' from line 'L100'
npd,ch,fid = gdb.read_line('L100',2135)                      # read channel symbol 2135 from 'L100"
npd,ch,fid = gdb.read_line('L100',channels=['X','Y','Z'])    # read a list of channels to (n,3) array
npd,ch,fid = gdb.read_line('L100','X',np.int32)              # read channel 'X' into integer array

New in version 9.1.

read_line_dataframe(line, channels=None, fid=None)

Read a line of data into a Pandas DataFrame

Parameters:
  • line – line to read, string or symbol number
  • channels – list of channels, strings or symbol number. If empty, read all channels
  • fid – required fiducial as tuple (start,incr), default smallest in data
Returns:

Pandas DataFrame, list of channel names, (fidStart,fidIncr)

Raises:

GdbException if first channel requested is empty

VA channels are expanded by element with channel names name[0], name[1], etc.

This method can be used to conveniently get a table structure of all data corresponding to the native types of the channels. It is however not necessarily the most efficient way to get at the data. If your database has a lot of channels, or wide array channels it will be more efficient to read and work with just the channels you need. See read_channel, read_channel_vv and read_channel_va. This method also does not currently support dummy removal in the same way as read_line.

Examples:

# df - Pandas DataFrame
# ch  - list of returned channels names
# fid - tuple (fidStart,fidIncrement), channels resampled as necessary

df,ch,fid = gdb.read_line('L100')                           # read all channels in line "L100"
df,ch,fid = gdb.read_line(681)                              # read all channels in line symbol 681
df,ch,fid = gdb.read_line('L100','X')                       # read channel 'X' from line 'L100'
df,ch,fid = gdb.read_line('L100',2135)                      # read channel symbol 2135 from 'L100"
df,ch,fid = gdb.read_line('L100',channels=['X','Y','Z'])    # read a list of channels to (n,3) array

New in version 9.5.

read_line_vv(line, channels=None, dtype=None, fid=None, common_fid=False)

Read a line of data into VVs stored in a dictionary by channel.

Parameters:
  • line – line to read, string or symbol number
  • channels – list of channels, strings or symbol number. If empty, read all channels
  • dtype – numpy data type for the array, default np.float64 for multi-channel data, data type for single channel data. Use “<Unnn” for string type.
  • common_fidTrue to resample all channels to a common fiducial
  • fid – required fid (start, increment), ignored if common_fid=False. if common_fid=True and fid= is not defined, use the smallest common fid.
Returns:

list of tuples [(channel_name, vv), …]

If a requested channel is a VA, it is with channel names ‘name[0]’, ‘name[1]’, etc.

Examples:

# npd - returned numpy array shape (n, number of channels)
# ch  - list of returned channels names, array channels expanded to array[0], array[1], ...
# fid - tuple (fidStart,fidIncrement), channels resampled as necessary

data = gdb.read_line_vv('L100')                           # read all channels in line "L100"
data = gdb.read_line_vv(681)                              # read all channels in line symbol 681
data = gdb.read_line_vv('L100','X')                       # read channel 'X' from line 'L100'
data = gdb.read_line_vv('L100',2135)                      # read channel symbol 2135 from 'L100"
data = gdb.read_line_vv('L100',channels=['X','Y','Z'])    # read a list of channels to (n,3) array
data = gdb.read_line_vv('L100','X',np.int32)              # read channel 'X' into integer array

New in version 9.2.

scan_line_fid(line, channels=None)

Scan channels in a line and return the smallest common fid, line length, data width, list of channels

Parameters:
  • line – line to read, string or symbol number
  • channels – list of channels, strings or symbol number. If empty, read all channels
Returns:

(fid_start, fid_increment, fid_last, data_width, channel_list)

New in version 9.4.

select_lines(selection='', select=True)

Change selected state of a line, or group of lines

Parameters:
  • selection – string representing selection, comma-delimit multiple selections, or provide a list of selections.
  • selectTrue to select, False to deselect

“L99:800” will select all lines of type “L” in range 99 through 800.

Use a “T” prefix for Tie lines.
Use an “F” prefix to specify lines of a specific flight.
For example, “F10” would select all lines of flight 10.
Use an empty string (“”) to select/deselect ALL lines.

Invalid line names are ignored.

New in version 9.1.

set_channel_details(channel, detail)

Set/change channel details from dictionary

Parameters:
  • channel – channel name or symbol
  • detail – dictionary, see chan_details

New in version 9.1.

unlock_(s)

internal_function to unlock a symbol

unlock_all()

Unlock all locked symbols.

New in version 9.3.

update_gxmeta(new_meta)

Update the database Geosoft metadata as a Geosoft geosoft.gxpy.metadata.Metadata instance.

Parameters:meta – the new metadata as a geosoft.gxpy.Metadata instance or a nested dict.

New in version 9.3.1.

used_blobs

number of blobs used

used_channels

number of channels used

used_lines

number of lines used

writeDataChan(*args, **kwargs)

Deprecated since version 9.2: use write_channel

write_channel(line, channel, data, fid=(0.0, 1.0), unit_of_measure=None)

Write data to a single channel.

Parameters:
  • line – line name or symbol
  • channel – channel name or symbol
  • data – numpy array (2D for VA channel), or a list
  • fid – tuple (fid start, increment), default (0.0,1.0)
  • unit_of_measure – data unit of measurement

Changed in version 9.3: support for setting channel from a list

added unit_of_measure

New in version 9.1.

write_channel_va(line, channel, va)

Write VA data to a single channel.

Parameters:
  • line – line name or symbol
  • channel – channel name or symbol
  • va – va data to write

New in version 9.2.

write_channel_vv(line, channel, vv)

Write data to a single channel.

Parameters:
  • line – line name or symbol
  • channel – channel name or symbol
  • vv – vv data to write

New in version 9.2.

write_line(line, data, channels=None, fid=(0.0, 1.0))

Write data to a multiple channels in a line. If no channel list is provided it assumes that the data is for all channels from the line, the compliment of read_line().

Parameters:
  • line – line to write to, name or symbol
  • data – numpy array shape (records,channels). If single dimension, one channel
  • channels – channel name or symbol list, or a single name/symbol. If a single name is specified for multi-column data, a VA channel is assumed. If None, a sorted list of all channels is assumed.
  • fid – option fid tuple (start, increment), default (0.0,1.0)

New in version 9.1.

write_line_vv(line, chan_data)

Write data to multiple channels in a line. If no channel list is provided it assumes that the data is for all channels from the line, the compliment of read_line().

Parameters:
  • line – line to write to, name or symbol
  • chan_data – numpy array shape (records,channels). If single dimension, one channel. Channels are created if they do not exist. VA channels must exist.
  • chan_data – list of tuples [(channel_name, vv), ]

Note

chan_data may contain VA data, which is defined by slice (ie. name[0], name[4]…). If VA data is included the VA channels must already exist.

New in version 9.2.

xyz_channels

The currently identified (x, y, z) channels. Methods that work on spatial locations will use these channels for locating the data at each fiducial of the data. Can be set using a tuple of two or three strings. For example:

gdb.xyz_channels = ('Easting', 'Northing')
gdb.xyz_channels = ('Easting', 'Northing', 'Elevation')

New in version 9.2.

class Line(gdb, name)

Bases: object

Class to work with database lines. Use constructor Line.new to create a new line. Use instance properties to work with line properties.

Parameters:
  • gdbGeosoft_gdb instance
  • name – line name string, must exist - see new() to create a new line

New in version 9.3.

bearing()

Return bearing of a line based on location of the first and last point in the line. Returns None if the line is empty or first and last points are the same.

New in version 9.3.

category

Line category, which can be set:

LINE_CATAGORY_FLIGHT
LINE_CATEGORY_GROUP
LINE_CATEGORY_NORMAL

New in version 9.3.

date

Line date. Can be set.

New in version 9.3.

delete()

Delete the line and all data associated with the line. After calling this method this line instance is no longer valid.

New in version 9.3.

flight

Line flight number (flight/cruise/survey event). Can be set.

New in version 9.3.

group

The lines group class name, ‘’ for a group lines (LINE_CATEGORY_GROUP). Only works for lines that are part of a group. Can be set.

New in version 9.3.

grouped

True if this is a grouped line.

New in version 9.3.

lock

Lock setting:

-1 unlocked (SYMBOL_LOCK_NONE)
0 read-locked (SYMBOL_LOCK_READ)
1 write-locked (SYMBOL_LOCK_WRITE)

Can be set.

lock_set_(fn, v)

write_lock, set and release a gdb attribute that requires locking to write.

locked

True if symbol is locked. Use property lock to determine if read or write lock, or to set the lock.

Setting to False unlocks the symbol.

New in version 9.3.

name

Line name, consistent with names constructed by create_line_name.

To change a line name change the type, number or version.

New in version 9.3.

classmethod new(gdb, name, linetype=None, group=None, dup=None, replace=False)

Create a new line.

Parameters:
  • gdbGeosoft_gdb instance
  • name – line name
  • linetype

    line type for creating a new line, ignored if group defines

    SYMB_LINE_NORMAL normal lines, name is a string
    SYMB_LINE_FLIGHT flight lines, first letter is line type
  • group – group name for a grouped class
  • dup – duplicate properties of this line (name, symbol or Line).
  • replaceTrue to replace line if it exists. Default is False .
Returns:

Line instance

New in version 9.3.

number

Line number. Can be set

New in version 9.3.

selected

True if this line is selected, can be set.

symbol

Line symbol

New in version 9.3.

type

Line type, which can be set:

LINE_TYPE_NORMAL
LINE_TYPE_BASE
LINE_TYPE_TIE
LINE_TYPE_TEST
LINE_TYPE_TREND
LINE_TYPE_SPECIAL
LINE_TYPE_RANDOM

New in version 9.3.

version

Line version number. Can be set.

New in version 9.3.

create_line_name(number=0, line_type=0, version=0)

Returns a valid database line name constructed from the component parts.

Parameters:
  • number – line number, or a string, default is 0
  • line_type – one of LINE_TYPE constants, default is LINE_TYPE_NORMAL
  • version – version number, default is 0
Returns:

string line name

Line name strings are constructed using the line naming convention as in the following:

L10.4 LINE_TYPE_NORMAL, number 10, version 4
B10.4 LINE_TYPE_BASE, number 10, version 4
D10.4 LINE_TYPE_RANDOM, number 10, version 4
P10.4 LINE_TYPE_SPECIAL, number 10, version 4
T10.4 LINE_TYPE_TIE, number 10, version 4
S10.4 LINE_TYPE_TEST, number 10, version 4
R10.4 LINE_TYPE_TREND, number 10, version 4

New in version 9.3.

delete_files(file_name)

Delete all files associates with this database name.

Parameters:file_name – name of the database

New in version 9.3.

is_valid_line_name(name)

Return True if this is a valid line name.

See also create_line_name

New in version 9.3.