geosoft.gxpy.vv submodule¶
Geosoft vector.
- Classes
data vector
VA and VV classes are related based on a key called a fiducial,
which has a start value and increment between values. The refid()
method can be used to resample vector
data to the same fiducial so that vector-to-vector operations can be performed.
See also
Note
Regression tests provide usage examples: vv tests
-
class
GXvv
(array=None, dtype=None, fid=None, unit_of_measure=None, dim=None, len=0)[source]¶ Bases:
collections.abc.Sequence
VV class wrapper.
- Parameters
array – array-like, None to create an empty VV. Can have 2 dimensions for float32 or float64 data, in which case the second dimension can be 2 or 3 to use Geosoft 2D and 3D dimensioned types. This can also be another
GXvv
instance, in which case a copy of the data is made and the dtype, dim, fid an unit_of_measurement will default to the source instance.dtype – numpy data type. For unicode strings ‘U#’, where # is a string length. If not specified the type is taken from first element in array, of if no array the default is ‘float’.
dim – dimension can be 1 (default), 2 (2D) or 3 (3D). Ignored if array is defined as the array dimensions will be used.
fid – (start, increment) fiducial
unit_of_measure – unit of measure for the contained data.
len – length of VV
- Properties
vv
geosoft.gxapi.GXvv
instancefid
(start, increment) fiduciallength
number of elements in the VVgxtype
GX data typedtype
numpy data typedim
dimension
New in version 9.1.
Changed in version 9.2: support construction directly from arrays
Changed in version 9.3: added unit_of_measure
Changed in version 9.3.1: added string support in __getitem__, and creates from a source
GVvv
instance.Changed in version 9.6: Added length parameter.
-
__init__
(array=None, dtype=None, fid=None, unit_of_measure=None, dim=None, len=0)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
dim
¶ Dimension of elements in the array, 1, 2 or 3.
-
property
dtype
¶ numpy data type
New in version 9.1.
-
property
fid
¶ fid tuple (start,increment), can be set
New in version 9.1.
-
fill
(value)[source]¶ Fill a vv with a constant value.
- Parameters
value – value to fill
New in version 9.3.1.
-
get_data
(dtype=None, start=0, n=None, float_dummies_to_nan=True)[source]¶ Return vv data in a numpy array
- Parameters
start – index of first value, must be >=0
n – number of values wanted
dtype – numpy data type wanted
- Returns
(data, (fid_start, fid_incr))
New in version 9.1.
-
property
gxtype
¶ GX data type
New in version 9.1.
-
property
gxvv
¶ geosoft.gxapi.GXVV
instance
-
property
is_float
¶ True if a base float type, 32 or 64-bit
-
property
is_float64
¶ True if a base 64-bit float
New in version 9.3.1.
-
property
is_int
¶ True if a base integer type
-
property
is_string
¶ True if a base string type
-
property
length
¶ number of elements in the VV, can be set
New in version 9.1.
Changed in version 9.3: can be set
-
min_max
()[source]¶ Return the minimum and maximum values as doubles. Strings are converted if possible.
- Returns
(minimum, maximum), or if all dummy, (None, None)
New in version 9.3.1.
-
property
np
¶ Numpy array of VV data, in the data type of the VV. Use
get_data()
to get a numpy array in another dtype.Note that changing the data in the numpy array does NOT change the data in the VV. Use
set_data
to change data in the VV.New in version 9.2.
-
refid
(fid, length=None)[source]¶ Resample VV to a new fiducial and length
- Parameters
fid – (start, incr)
length – length, if not specified the length is calculated to the end of the data.
New in version 9.1.
Changed in version 9.3.1: added default length calculation
-
set_data
(data, fid=None)[source]¶ Set vv data from an iterable, which can be another
GXvv
instance. If the data is float type numpy.nanare used to indicate dummy values.
-
property
unit_of_measure
¶ data unit of measurement
-
MAX_VV_BYTES
= 4096¶ maximum bytes per element in VV
-
exception
VVException
(message)[source]¶ Bases:
geosoft.GXRuntimeError
Exceptions from
geosoft.gxpy.vv
.New in version 9.1.
-
np_from_vvset
(vvset, axis=1)[source]¶ Return a 2d numpy array from a set of
GXvv
instances.- Parameters
vvset – (vv1, vv2, …) set ot
geosoft.gxpy.vv.GXvv
instancesaxis – axis for the vv, default is 1, such that each vv is a column,
axis=0
for vv to be rows
- Returns
numpy array shaped (max_vv_length, number_of_vv) for
axis=1
, or (number_of_vv, max_vv_length) foraxis=0
.
New in version 9.3.1.
-
vvset_from_np
(npd, axis=1)[source]¶ Return a set of
GXvv
instances from a 2d numpy array.- Parameters
npd – numpy data array of dimension 2. If the array has higher dimensions it will first be reshaped to a 2-dimension array based on the last axis.
axis – axis for the vv, default is 1, such that each columns become vv,
axis=0
for rows to be vv
- Returns
[vv0, vv1, vv2, …]
geosoft.gxpy.vv.GXvv
instances for each column or row (axis=0
)
For example:
npd = np.array([[1, 2, 3], [4, 5, 6]])
returns (vv([1, 4]), vv([2, 5]), vv([3, 6]))
New in version 9.3.1.