Metadata-Version: 2.4
Name: SoilRunNutri
Version: 0.1.16
Summary: A Python package to estimate nutrient loss based on soil erosion.
Author: Soumya Pant, Dr. Sadikul Islam, Dr. Gopal Kumar, Dr. M. Madhu
License: MIT
Keywords: soil,nutrient-loss,nitrogen,phosphorus,potassium
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Erosion Induced Nutrient Loss

**Version:** 0.1.16  
**Python Required:** 3.7 or higher  
**License:** MIT License  

SoilRunoffNutri is a Python package designed to estimate **erosion-induced nutrient losses** using empirical **piecewise linear regression models** that link runoff, soil loss, and sediment-associated nutrient transport from agricultural land.

**Soil loss** is defined as the amount of soil removed from the land surface by rainfall and surface runoff and is expressed as tonnes per hectare (t ha⁻¹). It indicates the severity of erosion and depletion of fertile topsoil.

**Runoff percentage** represents the proportion of rainfall converted into surface runoff, calculated as runoff depth divided by rainfall depth multiplied by 100, and reflects the potential for erosion and nutrient transport.

The package estimates erosion-induced losses of the following nutrients, expressed in kg ha⁻¹:

- Nitrogen (N)  
- Phosphorus (P)  
- Potassium (K)  

Erosion-induced nutrient loss refers to the quantity of plant nutrients removed from agricultural land due to soil erosion and surface runoff. Nutrients are transported either in dissolved form with runoff water or attached to eroded soil particles (sediments).

These losses are computed using empirically derived relationships based on long-term experimental datasets generated by **ICAR – Indian Institute of Soil and Water Conservation (IISWC), Dehradun**, aggregated across multiple agro-ecological regions of India. The resulting models provide robust applicability across diverse climatic and physiographic conditions.

## Piecewise Linear Regression Framework

The nutrient loss estimation framework adopts a **piecewise linear regression approach**, wherein separate linear equations are applied to different ranges of soil loss or runoff rather than a single equation over the entire range. By using locally fitted equations, the model accommodates changes in erosion–nutrient coupling mechanisms such as threshold-driven soil detachment, transport limitation, and nutrient enrichment at higher erosion levels. This structure enhances model flexibility and improves prediction accuracy under varying erosion and runoff intensities.

For each predefined interval of soil loss or runoff, the relationship between nutrient loss and the driving variable is expressed as:

\[
y = m x + c
\]

where:  
- \( y \) = nutrient loss (kg ha⁻¹)  
- \( x \) = soil loss (t ha⁻¹) or runoff (%)  
- \( m \) = slope of the regression line for interval 
- \( c \) = intercept for interval

Statistical significance of regression parameters was assessed at the 5% level (p < 0.05), ensuring that only meaningful and stable relationships were retained. Model predictions are generated dynamically based on user-provided inputs, and the appropriate regression segment is automatically selected according to the input range.

The reliability of the output depends on the accuracy of input data. Results should be interpreted as **decision-support estimates** rather than exact measurements. The author shall not be responsible for any variations in the result.

---

# Installation

Install using pip:

pip install SoilRunNutri


---

# Quick Usage Guide


import SoilRunNutri as srn 

Load default input file (inputuser.txt)

data = srn.load_input_file()

Calculate nutrient loss using main functions

nitrogen_loss = srn.nitrogen_loss(value, mode)

phosphorus_loss = srn.phosphorus_loss(value, mode)

potassium_loss = srn.potassium_loss(value, mode)

print("Nitrogen loss:", nitrogen_loss)

print("Phosphorus loss:", phosphorus_loss)

print("Potassium loss:", potassium_loss)

---

# Functions Available


| Function                                       | Description                                          | Example                                             |
| ---------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------|
| `nitrogen_loss(value, mode)`                   | Returns estimated N loss (kg ha⁻¹)                   | nitrogen_loss   = srn.nitrogen_loss(14, "soil")     |                                               
| `phosphorus_loss(value, mode)`                 | Returns estimated P loss (kg ha⁻¹)                   | phosphorus_loss = srn.phosphorus_loss(20, "soil")   |                                                 
| `potassium_loss(value, mode)`                  | Returns estimated K loss (kg ha⁻¹)                   | potassium_loss  = srn.potassium_loss(10 , "runoff") |                                                  
| `load_input_file(file_path="inputuser.txt")`   | Loads a text input file with soil loss & runoff data |                                                     |




 






