geost.base.Collection.calculate_gradient#
- Collection.calculate_gradient(column: str, output_column: str | None = None, use_mid_depth: bool = True, inplace: bool = False) Collection | None[source]#
Calculate the rate of change (i.e. “gradient”) over depth of a value column per survey in the Collection’s data table.
The gradient is computed as the difference between consecutive rows of column, divided by the difference between the corresponding depths. The first row of each survey has no preceding row and is therefore set to 0.0.
- Parameters:
column (str) – Name of the numeric column for which to calculate the gradient.
output_column (str, optional) – Name of the column to store the gradient.
use_mid_depth (bool, optional) – If True, the gradient is calculated over the mid depth of each interval. If False, the bottom depth of each interval is used. The default is True.
inplace (bool, optional) – If True, add the gradient to the data table of the current
Collection. In this case, the method returnsNone. Otherwise, return a newCollectioninstance with the gradient added in the data table. The default is False.
- Returns:
New
Collectionwith the gradient added to the data table, or None ifinplace=True.- Return type:
CollectionorNone- Raises:
TypeError – If column is not of a numeric dtype.
Notes
This method operates on the data table of the
Collectionand assumes that the rows are sorted by survey and ascending depth.Examples
>>> result = collection.calculate_gradient("value") # Creates new Collection >>> collection.calculate_gradient("value", use_mid_depth=False, inplace=True) # Modifies the current Collection