SoilRunNutri 0.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ __version__ = "0.1.13"
2
+
3
+ from .model import (nitrogen_loss, phosphorus_loss, potassium_loss)
4
+
5
+ __all__ = ["nitrogen_loss","phosphorus_loss","potassium_loss",]
6
+
7
+ # Function to load your separate input file
8
+ def load_input_file(file_path="inputuser.txt"):
9
+ """
10
+ Load the default input file or any user-specified input file.
11
+
12
+ Parameters:
13
+ file_path : str
14
+ Path to the input file (default is 'inputuser.txt')
15
+
16
+ Returns:
17
+ data : str
18
+ Content of the input file
19
+ """
20
+ with open(file_path, "r") as f:
21
+ data = f.read()
22
+ return data
SoilRunNutri/model.py ADDED
@@ -0,0 +1,130 @@
1
+ """
2
+ Nutrient loss estimation based on either:
3
+ 1. Soil loss
4
+ 2. Percentage runoff
5
+
6
+ User must choose ONE input method.
7
+ """
8
+
9
+
10
+ # =========================
11
+ # NITROGEN
12
+ # =========================
13
+
14
+ def nitrogen_loss(value, mode):
15
+ """
16
+ Calculate Nitrogen loss.
17
+ """
18
+
19
+ if mode == "soil":
20
+
21
+ if 0 <= value < 5:
22
+ nitrogen_loss_value = 2.3647 * value
23
+ elif 5 <= value < 10:
24
+ nitrogen_loss_value = 1.2927 * value + 0.270
25
+ elif 10 <= value < 20:
26
+ nitrogen_loss_value = 0.7909 * value - 0.2909
27
+ else:
28
+ nitrogen_loss_value = 0.8012 * value + 1.1358
29
+
30
+ print(f"The nitrogen loss based on soil loss is {nitrogen_loss_value}")
31
+
32
+ elif mode == "runoff":
33
+
34
+ if 0 <= value < 10:
35
+ nitrogen_loss_value = 4.285 * value
36
+ elif 10 <= value < 20:
37
+ nitrogen_loss_value = 0.415 * value + 0.246
38
+ elif 20 <= value < 30:
39
+ nitrogen_loss_value = 0.0679 * value - 0.0175
40
+ else:
41
+ nitrogen_loss_value = 0.0662 * value + 0.0144
42
+
43
+ print(f"The nitrogen loss based on runoff is {nitrogen_loss_value}")
44
+
45
+ else:
46
+ raise ValueError("Mode must be 'soil' or 'runoff'")
47
+
48
+ return nitrogen_loss_value
49
+
50
+
51
+ # =========================
52
+ # PHOSPHORUS
53
+ # =========================
54
+
55
+ def phosphorus_loss(value, mode):
56
+ """
57
+ Calculate Phosphorus loss.
58
+ """
59
+
60
+ if mode == "soil":
61
+
62
+ if 0 <= value < 5:
63
+ phosphorus_loss_value = 0.2096 * value
64
+ elif 5 <= value < 10:
65
+ phosphorus_loss_value = 0.0853 * value - 0.0103
66
+ elif 10 <= value < 20:
67
+ phosphorus_loss_value = 0.1048 * value + 0.0291
68
+ else:
69
+ phosphorus_loss_value = 0.0622 * value + 0.0794
70
+
71
+ print(f"The phosphorus loss based on soil loss is {phosphorus_loss_value}")
72
+
73
+ elif mode == "runoff":
74
+
75
+ if 0 <= value < 10:
76
+ phosphorus_loss_value = 0.189 * value
77
+ elif 10 <= value < 20:
78
+ phosphorus_loss_value = 0.0478 * value + 0.018
79
+ elif 20 <= value < 30:
80
+ phosphorus_loss_value = 0.027 * value - 0.0066
81
+ else:
82
+ phosphorus_loss_value = 0.0262 * value + 0.0046
83
+
84
+ print(f"The phosphorus loss based on runoff is {phosphorus_loss_value}")
85
+
86
+ else:
87
+ raise ValueError("Mode must be 'soil' or 'runoff'")
88
+
89
+ return phosphorus_loss_value
90
+
91
+
92
+ # =========================
93
+ # POTASSIUM
94
+ # =========================
95
+
96
+ def potassium_loss(value, mode):
97
+ """
98
+ Calculate Potassium loss.
99
+ """
100
+
101
+ if mode == "soil":
102
+
103
+ if 0 <= value < 5:
104
+ potassium_loss_value = 3.1155 * value
105
+ elif 5 <= value < 10:
106
+ potassium_loss_value = 1.2188 * value + 0.2178
107
+ elif 10 <= value < 20:
108
+ potassium_loss_value = 1.0204 * value + 2.5149
109
+ else:
110
+ potassium_loss_value = 0.5914 * value + 0.4662
111
+
112
+ print(f"The potassium loss based on soil loss is {potassium_loss_value}")
113
+
114
+ elif mode == "runoff":
115
+
116
+ if 0 <= value < 10:
117
+ potassium_loss_value = 2.289 * value
118
+ elif 10 <= value < 20:
119
+ potassium_loss_value = 0.4252 * value - 0.1895
120
+ elif 20 <= value < 30:
121
+ potassium_loss_value = 0.4512 * value - 0.3018
122
+ else:
123
+ potassium_loss_value = 0.4361 * value + 0.262
124
+
125
+ print(f"The potassium loss based on runoff is {potassium_loss_value}")
126
+
127
+ else:
128
+ raise ValueError("Mode must be 'soil' or 'runoff'")
129
+
130
+ return potassium_loss_value
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: SoilRunNutri
3
+ Version: 0.1.13
4
+ Summary: A Python package to estimate nutrient loss based on soil erosion.
5
+ Author: Soumya Pant, Dr. Sadikul Islam, Dr. Gopal Kumar, Dr. M. Madhu
6
+ License: MIT
7
+ Keywords: soil,nutrient-loss,nitrogen,phosphorus,potassium
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # Erosion Induced Nutrient Loss
17
+
18
+ **Version:** 0.1.13
19
+ **Python Required:** 3.7 or higher
20
+ **License:** MIT License
21
+
22
+ 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.
23
+
24
+ **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.
25
+
26
+ **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.
27
+
28
+ The package estimates erosion-induced losses of the following nutrients, expressed in kg ha⁻¹:
29
+
30
+ - Nitrogen (N)
31
+ - Phosphorus (P)
32
+ - Potassium (K)
33
+
34
+ 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).
35
+
36
+ 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.
37
+
38
+ ## Piecewise Linear Regression Framework
39
+
40
+ 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.
41
+
42
+ For each predefined interval of soil loss or runoff, the relationship between nutrient loss and the driving variable is expressed as:
43
+
44
+ \[
45
+ y = m x + c
46
+ \]
47
+
48
+ where:
49
+ - \( y \) = nutrient loss (kg ha⁻¹)
50
+ - \( x \) = soil loss (t ha⁻¹) or runoff (%)
51
+ - \( m \) = slope of the regression line for interval
52
+ - \( c \) = intercept for interval
53
+
54
+ 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.
55
+
56
+ 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.
57
+
58
+ ---
59
+
60
+ # Installation
61
+
62
+ Install using pip:
63
+
64
+ pip install SoilRunNutri
65
+
66
+
67
+ ---
68
+
69
+ # Quick Usage Guide
70
+
71
+
72
+ import SoilRunNutri as srn
73
+
74
+ Load default input file (inputuser.txt)
75
+
76
+ data = srn.load_input_file()
77
+
78
+ Calculate nutrient loss using main functions
79
+
80
+ nitrogen_loss = srn.nitrogen_loss(value, mode)
81
+
82
+ phosphorus_loss = srn.phosphorus_loss(value, mode)
83
+
84
+ potassium_loss = srn.potassium_loss(value, mode)
85
+
86
+ print("Nitrogen loss:", nitrogen_loss)
87
+
88
+ print("Phosphorus loss:", phosphorus_loss)
89
+
90
+ print("Potassium loss:", potassium_loss)
91
+
92
+ ---
93
+
94
+ # Functions Available
95
+
96
+
97
+ | Function | Description | Example |
98
+ | ---------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------|
99
+ | `nitrogen_loss(value, mode)` | Returns estimated N loss (kg ha⁻¹) | nitrogen_loss = srn.nitrogen_loss(14, Soil loss) |
100
+ | `phosphorus_loss(value, mode)` | Returns estimated P loss (kg ha⁻¹) | phosphorus_loss = srn.phosphorus_loss(20, Soil loss) |
101
+ | `potassium_loss(value, mode)` | Returns estimated K loss (kg ha⁻¹) | potassium_loss = srn.potassium_loss(10 , Run off) |
102
+ | `load_input_file(file_path="inputuser.txt")` | Loads a text input file with soil loss & runoff data | |
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
@@ -0,0 +1,7 @@
1
+ SoilRunNutri/__init__.py,sha256=INdfw_VNsHznuPb_SGqMv5KqsfiYLgie_yhu2hz2cO8,596
2
+ SoilRunNutri/model.py,sha256=2Fa2ToNVwMGcNtGpXF5eEtutpP5FkxK0V0MpFDiZRfg,3634
3
+ soilrunnutri-0.1.13.dist-info/licenses/LICENSE,sha256=GfnTf_WgKo06BbEPud_ZXVBPovqxIM68FCTMs-0HBio,1089
4
+ soilrunnutri-0.1.13.dist-info/METADATA,sha256=rYwUKLMi9kXJmZQy1wzh6m3u0SK-s8w56GYR0WTr-_U,5455
5
+ soilrunnutri-0.1.13.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ soilrunnutri-0.1.13.dist-info/top_level.txt,sha256=MmLOTR4mPG27B7oNvL1c26AZW6v9cfu9lqoRsYBAiAo,13
7
+ soilrunnutri-0.1.13.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Soumya Pant
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ SoilRunNutri