geosoft.gxpy.vv submodule¶
Geosoft vector.
Classes: |
|
---|
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)¶ 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.
Properties: vv
geosoft.gxapi.GXvv
instancefid
(start, increment) fiduciallength
number of elements in the VVgxtype
GX data typedtype
numpy data typedim
dimensionNew 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.-
dim
¶ Dimension of elements in the array, 1, 2 or 3.
-
dtype
¶ numpy data type
New in version 9.1.
-
fid
¶ fid tuple (start,increment), can be set
New in version 9.1.
-
fill
(value)¶ 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)¶ 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.
-
gxtype
¶ GX data type
New in version 9.1.
-
gxvv
¶ geosoft.gxapi.GXVV
instance
-
is_float
¶ True if a base float type, 32 or 64-bit
-
is_float64
¶ True if a base 64-bit float
New in version 9.3.1.
-
is_int
¶ True if a base integer type
-
is_string
¶ True if a base string type
-
length
¶ number of elements in the VV, can be set
New in version 9.1.
Changed in version 9.3: can be set
-
list
()¶ Return the content of the VV as a list.
New in version 9.2.
-
min_max
()¶ 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.
-
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)¶ 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)¶ Set vv data from an iterable, which can be another
GXvv
instance. If the data is float type numpy.nan are used to indicate dummy values.Parameters: - data – data array of
GXvv
instance, will be reshapped to VV dimension - fid – fid tuple (start,increment), default does not change current fid
New in version 9.1.
Changed in version 9.3: default fid leaves fid unchanged
Changed in version 9.3.1: now accepts
GXvv
instance as the source data.- data – data array of
-
unit_of_measure
¶ data unit of measurement
- 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
-
exception
VVException
(message)¶ Bases:
geosoft.GXRuntimeError
Exceptions from
geosoft.gxpy.vv
.New in version 9.1.
-
np_from_vvset
(vvset, axis=1)¶ Return a 2d numpy array from a set of
GXvv
instances.Parameters: - vvset – (vv1, vv2, …) set ot
geosoft.gxpy.vv.GXvv
instances - axis – 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 – (vv1, vv2, …) set ot
-
vvset_from_np
(npd, axis=1)¶ 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.