API Reference

Complete API documentation for mpspline.

Main Function

Classes

HorizonSequence

class mpspline.spline.HorizonSequence(horizons: list[dict], strict: bool = False)

Bases: object

Represents a sequence of soil horizons for a component.

Handles extraction and validation of horizon data, property identification, and preparation for spline interpolation.

Attributes:

horizons: List of horizon dictionaries max_depth: Maximum depth of any horizon (cm) properties: Sorted list of numeric properties across all horizons

__init__(horizons: list[dict], strict: bool = False)

Initialize from horizon list.

Args:
horizons: List of horizon dicts with keys:
  • hzname: Horizon name (str)

  • upper: Depth to top (cm, int/float)

  • lower: Depth to bottom (cm, int/float)

  • [property names]: Property values (float)

strict: If True, raise on validation errors instead of warnings

get_property_data(property_name: str) tuple[ndarray, ndarray]

Extract depth-property pairs for a specific property.

Returns:

Tuple of (depths_array, values_array) where depths are midpoints of each horizon.

to_dataframe() DataFrame

Convert to DataFrame format suitable for spline processing.

Returns:

DataFrame with columns: ‘UD’ (upper depth), ‘LD’ (lower depth), and property columns

ValidationResult

class mpspline.validation.ValidationResult(is_valid: bool, errors: list[str] = <factory>, warnings: list[str] = <factory>, horizon_count: int = 0, max_depth: int = 0)

Bases: object

Result of horizon sequence validation.

is_valid: bool
errors: list[str]
warnings: list[str]
horizon_count: int = 0
max_depth: int = 0
__init__(is_valid: bool, errors: list[str] = <factory>, warnings: list[str] = <factory>, horizon_count: int = 0, max_depth: int = 0) None

Secondary Functions

Single Profile Processing

Algorithm Functions

Validation

Constants

Standard Depths

mpspline.constants.GLOBALSM_DEPTHS: list[tuple[int, int]] = [(0, 5), (5, 15), (15, 30), (30, 60), (60, 100), (100, 200)]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

Standard Soil Properties

mpspline.constants.STANDARD_SOIL_PROPERTIES: dict[str, str] = {'awc_r': 'Available water capacity (cm/cm)', 'ca_r': 'Exchangeable calcium (meq/100g)', 'cec7_r': 'Cation exchange capacity (meq/100g)', 'clay': 'Clay content (%)', 'dbthirdbar_r': 'Bulk density at 1/3 bar (g/cm3)', 'ec_r': 'Electrical conductivity (dS/m)', 'k_r': 'Exchangeable potassium (meq/100g)', 'ksat_r': 'Saturated hydraulic conductivity (cm/hr)', 'mg_r': 'Exchangeable magnesium (meq/100g)', 'na_r': 'Exchangeable sodium (meq/100g)', 'om_r': 'Organic matter (%)', 'ph01mcl_r': 'pH (0.01 M CaCl2)', 'ph1to1h2o_r': 'pH (1:1 H2O)', 'sand': 'Sand content (%)', 'sar_r': 'Sodium adsorption ratio', 'silt': 'Silt content (%)'}

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

Spline Tolerance

mpspline.constants.SPLINE_TOLERANCE: float = 1e-06

Convert a string or number to a floating-point number, if possible.

Module Index