mobidicpy 0.2.0__tar.gz → 0.2.1__tar.gz
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.
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/CITATION.cff +1 -1
- {mobidicpy-0.2.0/mobidicpy.egg-info → mobidicpy-0.2.1}/PKG-INFO +2 -2
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/__init__.py +1 -1
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/routing.py +14 -10
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/grid_operations.py +55 -38
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/hillslope_reach_mapping.py +2 -1
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/io.py +1 -1
- {mobidicpy-0.2.0 → mobidicpy-0.2.1/mobidicpy.egg-info}/PKG-INFO +2 -2
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidicpy.egg-info/requires.txt +1 -1
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/pyproject.toml +3 -3
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/LICENSE +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/MANIFEST.in +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/README.md +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/config.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/forward_model.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/instruction.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/metrics.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/observation.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/parameter_mapping.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/pest_setup.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/results.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/calibration/template.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/config/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/config/parser.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/config/schema.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/constants.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/crop_coefficients.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/energy_balance.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/groundwater.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/interpolation.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/pet.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/reservoir.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/simulation.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/core/soil_water_balance.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/data/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/data/kc_clc_mapping.csv +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/io/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/io/meteo.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/io/report.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/io/state.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/gis_reader.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/hyetograph.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/meteo_preprocessing.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/meteo_raster.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/preprocessor.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/reservoirs.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/preprocessing/river_network.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/py.typed +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/utils/__init__.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/utils/crs.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidic/utils/logging.py +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidicpy.egg-info/SOURCES.txt +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidicpy.egg-info/dependency_links.txt +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/mobidicpy.egg-info/top_level.txt +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/setup.cfg +0 -0
- {mobidicpy-0.2.0 → mobidicpy-0.2.1}/tests/test_package.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mobidicpy
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: MOBIDICpy - Distributed and continuous hydrological balance model
|
|
5
5
|
Author-email: Matteo Masi <matteo.masi@unifi.it>, Fabio Castelli <fabio.castelli@unifi.it>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -38,7 +38,7 @@ Requires-Dist: pytest>=7.0; extra == "dev"
|
|
|
38
38
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
39
39
|
Requires-Dist: coverage>=7.0; extra == "dev"
|
|
40
40
|
Requires-Dist: genbadge[coverage]>=1.1.3; extra == "dev"
|
|
41
|
-
Requires-Dist: ruff>=0.2.
|
|
41
|
+
Requires-Dist: ruff>=0.2.1; extra == "dev"
|
|
42
42
|
Requires-Dist: bump-my-version>=1.0; extra == "dev"
|
|
43
43
|
Provides-Extra: calibration
|
|
44
44
|
Requires-Dist: pyemu>=1.4.0; extra == "calibration"
|
|
@@ -98,16 +98,20 @@ def hillslope_routing(
|
|
|
98
98
|
Each cell contains ONLY flow from immediate upstream neighbors (NOT its own flow).
|
|
99
99
|
|
|
100
100
|
Notes:
|
|
101
|
-
Flow direction coding (D8) - MOBIDIC convention from MATLAB stack8point.m
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
Flow direction coding (D8) - MOBIDIC convention from MATLAB stack8point.m.
|
|
102
|
+
Rasters are loaded with `np.flipud` (in `grid_to_matrix`) so that increasing
|
|
103
|
+
row index corresponds to moving NORTH; the codes/offsets below assume that
|
|
104
|
+
orientation.
|
|
105
|
+
|
|
106
|
+
MOBIDIC notation (1-8, CCW from SW; north up):
|
|
107
|
+
7 6 5 (NW N NE)
|
|
108
|
+
8 · 4 (W E)
|
|
109
|
+
1 2 3 (SW S SE)
|
|
110
|
+
|
|
111
|
+
Direction number -> compass direction -> (row_offset, col_offset):
|
|
112
|
+
1: SW (-1, -1), 2: S (-1, 0), 3: SE (-1, +1),
|
|
113
|
+
4: E ( 0, +1), 5: NE (+1, +1), 6: N (+1, 0),
|
|
114
|
+
7: NW (+1, -1), 8: W ( 0, -1)
|
|
111
115
|
|
|
112
116
|
Special values:
|
|
113
117
|
0: Outlet cell (no downstream neighbor)
|
|
@@ -107,11 +107,12 @@ def decimate_flow_direction(
|
|
|
107
107
|
Flow accumulation is normalized by factor **2 to account for cell size change.
|
|
108
108
|
|
|
109
109
|
Notes:
|
|
110
|
-
This function
|
|
110
|
+
This function operates on flow_dir BEFORE conversion to MOBIDIC notation,
|
|
111
|
+
so input is expected in standard GRASS r.watershed 1-8 notation:
|
|
111
112
|
1=NE, 2=N, 3=NW, 4=W, 5=SW, 6=S, 7=SE, 8=E
|
|
112
113
|
|
|
113
114
|
Examples:
|
|
114
|
-
>>> flow_dir = np.array([[2, 2], [2, 2]]) # All cells flow north
|
|
115
|
+
>>> flow_dir = np.array([[2, 2], [2, 2]]) # All cells flow north (Grass code 2)
|
|
115
116
|
>>> flow_acc = np.array([[1, 1], [3, 4]]) # Different accumulation
|
|
116
117
|
>>> dec_dir, dec_acc = decimate_flow_direction(flow_dir, flow_acc, factor=2)
|
|
117
118
|
"""
|
|
@@ -137,10 +138,11 @@ def decimate_flow_direction(
|
|
|
137
138
|
flow_dir_decimated = np.full((nrv, ncv), np.nan, dtype=float)
|
|
138
139
|
flow_acc_decimated = np.full((nrv, ncv), np.nan, dtype=float)
|
|
139
140
|
|
|
140
|
-
# Direction offsets
|
|
141
|
-
# 1=NE, 2=N, 3=NW, 4=W, 5=SW, 6=S, 7=SE, 8=E
|
|
141
|
+
# Direction offsets indexed by code-1, in standard GRASS r.watershed notation
|
|
142
|
+
# (1=NE, 2=N, 3=NW, 4=W, 5=SW, 6=S, 7=SE, 8=E). Offsets are matrix-coord
|
|
143
|
+
# (row, col) where row+1 = down (image orientation, before any flipud).
|
|
142
144
|
di = np.array([-1, -1, -1, 0, 1, 1, 1, 0]) # row offset
|
|
143
|
-
dj = np.array([
|
|
145
|
+
dj = np.array([1, 0, -1, -1, -1, 0, 1, 1]) # column offset
|
|
144
146
|
|
|
145
147
|
# Minimum number of valid cells required
|
|
146
148
|
min_valid_cells = int(factor * factor * min_valid_fraction)
|
|
@@ -204,17 +206,17 @@ def decimate_flow_direction(
|
|
|
204
206
|
flow_dir_decimated[i, j] = -999
|
|
205
207
|
continue
|
|
206
208
|
|
|
207
|
-
# Map coarse cell offset to direction (1-8)
|
|
208
|
-
#
|
|
209
|
+
# Map coarse cell offset to direction (1-8) in standard GRASS r.watershed
|
|
210
|
+
# convention (image orientation, row+1 = down).
|
|
209
211
|
offset_to_dir = {
|
|
210
|
-
(-1,
|
|
211
|
-
(-1, 0): 2, # N
|
|
212
|
-
(-1, 1): 3, # NW
|
|
213
|
-
(0, 1): 4, # W
|
|
214
|
-
(1, 1): 5, # SW
|
|
215
|
-
(1, 0): 6, # S
|
|
216
|
-
(1,
|
|
217
|
-
(0,
|
|
212
|
+
(-1, 1): 1, # NE
|
|
213
|
+
(-1, 0): 2, # N
|
|
214
|
+
(-1, -1): 3, # NW
|
|
215
|
+
(0, -1): 4, # W
|
|
216
|
+
(1, -1): 5, # SW
|
|
217
|
+
(1, 0): 6, # S
|
|
218
|
+
(1, 1): 7, # SE
|
|
219
|
+
(0, 1): 8, # E
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
flow_dir_decimated[i, j] = offset_to_dir.get((coarse_di, coarse_dj), -999)
|
|
@@ -253,9 +255,13 @@ def convert_to_mobidic_notation(
|
|
|
253
255
|
) -> np.ndarray:
|
|
254
256
|
"""Convert flow direction from Grass or Arc notation to MOBIDIC notation.
|
|
255
257
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
Translates standard GRASS r.watershed (1-8) or ESRI ArcGIS (powers of 2) flow
|
|
259
|
+
direction codes to MOBIDIC's internal D8 encoding. The renumbering is
|
|
260
|
+
direction-preserving (each input code maps to the MOBIDIC code with the same
|
|
261
|
+
physical compass direction). The mapping matches MATLAB's
|
|
262
|
+
buildgis_mysql_include.m:
|
|
263
|
+
GRASS: AI=[1 2 3 4 5 6 7 8]; MD=[5 6 7 8 1 2 3 4];
|
|
264
|
+
ArcGIS: AI=[1 2 4 8 16 32 64 128]; MD=[4 3 2 1 8 7 6 5];
|
|
259
265
|
|
|
260
266
|
Args:
|
|
261
267
|
flow_dir: 2D numpy array with flow directions (NaN for nodata).
|
|
@@ -265,25 +271,36 @@ def convert_to_mobidic_notation(
|
|
|
265
271
|
Flow direction array converted to MOBIDIC notation (1-8).
|
|
266
272
|
|
|
267
273
|
Notes:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
6
|
|
285
|
-
|
|
286
|
-
|
|
274
|
+
Standard GRASS r.watershed convention (1-8, CCW from NE; north up):
|
|
275
|
+
|
|
276
|
+
3 2 1 1 = NE 5 = SW
|
|
277
|
+
4 . 8 2 = N 6 = S
|
|
278
|
+
5 6 7 3 = NW 7 = SE
|
|
279
|
+
4 = W 8 = E
|
|
280
|
+
|
|
281
|
+
Standard ESRI ArcGIS convention (powers of 2, CW from E; north up):
|
|
282
|
+
|
|
283
|
+
32 64 128 1 = E 16 = W
|
|
284
|
+
16 . 1 2 = SE 32 = NW
|
|
285
|
+
8 4 2 4 = S 64 = N
|
|
286
|
+
8 = SW 128 = NE
|
|
287
|
+
|
|
288
|
+
MOBIDIC convention (1-8, CCW from SW; north up):
|
|
289
|
+
|
|
290
|
+
7 6 5 1 = SW 5 = NE
|
|
291
|
+
8 . 4 2 = S 6 = N
|
|
292
|
+
1 2 3 3 = SE 7 = NW
|
|
293
|
+
4 = E 8 = W
|
|
294
|
+
|
|
295
|
+
Direction-preserving mapping:
|
|
296
|
+
GRASS -> MOBIDIC: 1->5, 2->6, 3->7, 4->8, 5->1, 6->2, 7->3, 8->4
|
|
297
|
+
ArcGIS -> MOBIDIC: 1->4, 2->3, 4->2, 8->1, 16->8, 32->7, 64->6, 128->5
|
|
298
|
+
|
|
299
|
+
Array orientation: rasters are loaded by `grid_to_matrix()` with `np.flipud`
|
|
300
|
+
so that increasing row index corresponds to moving NORTH. With that
|
|
301
|
+
orientation, MOBIDIC code k drains to the neighbor at offset
|
|
302
|
+
(di, dj) where di = `[-1,-1,-1,0,1,1,1,0][k-1]` and
|
|
303
|
+
dj = `[-1,0,1,1,1,0,-1,-1][k-1]`. For example, code 5 (NE) -> (+1, +1).
|
|
287
304
|
|
|
288
305
|
Examples:
|
|
289
306
|
>>> flow_dir_grass = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 1]])
|
|
@@ -298,7 +315,7 @@ def convert_to_mobidic_notation(
|
|
|
298
315
|
grass_to_mobidic = {1: 5, 2: 6, 3: 7, 4: 8, 5: 1, 6: 2, 7: 3, 8: 4}
|
|
299
316
|
|
|
300
317
|
# Arc to GRASS mapping
|
|
301
|
-
arc_to_grass = {1: 8, 2:
|
|
318
|
+
arc_to_grass = {1: 8, 2: 7, 4: 6, 8: 5, 16: 4, 32: 3, 64: 2, 128: 1}
|
|
302
319
|
|
|
303
320
|
# Create output array
|
|
304
321
|
converted = flow_dir.copy()
|
|
@@ -229,7 +229,8 @@ def map_hillslope_to_reach(
|
|
|
229
229
|
|
|
230
230
|
logger.debug(f"Lookup table built: {len(cell_to_reach)} reach cells")
|
|
231
231
|
|
|
232
|
-
# Direction offsets for MOBIDIC notation (1-8)
|
|
232
|
+
# Direction offsets for MOBIDIC notation (1-8, CCW from SW; north up).
|
|
233
|
+
# Code k (1..8) -> (di[k-1], dj[k-1]); e.g. 1=SW -> (-1,-1), 5=NE -> (+1,+1).
|
|
233
234
|
di = np.array([-1, -1, -1, 0, 1, 1, 1, 0]) # row offset (matches i8)
|
|
234
235
|
dj = np.array([-1, 0, 1, 1, 1, 0, -1, -1]) # column offset (matches j8)
|
|
235
236
|
|
|
@@ -114,7 +114,7 @@ def save_gisdata(gisdata: "GISData", output_path: str | Path) -> None:
|
|
|
114
114
|
"long_name": "Flow Direction",
|
|
115
115
|
"units": "1",
|
|
116
116
|
"description": "Flow direction in MOBIDIC notation (1-8)",
|
|
117
|
-
"notation": "MOBIDIC: 1=
|
|
117
|
+
"notation": "MOBIDIC: 1=SW, 2=S, 3=SE, 4=E, 5=NE, 6=N, 7=NW, 8=W (north up; row+1=N)",
|
|
118
118
|
"grid_mapping": "crs",
|
|
119
119
|
}
|
|
120
120
|
ds["flow_acc"].attrs = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mobidicpy
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: MOBIDICpy - Distributed and continuous hydrological balance model
|
|
5
5
|
Author-email: Matteo Masi <matteo.masi@unifi.it>, Fabio Castelli <fabio.castelli@unifi.it>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -38,7 +38,7 @@ Requires-Dist: pytest>=7.0; extra == "dev"
|
|
|
38
38
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
39
39
|
Requires-Dist: coverage>=7.0; extra == "dev"
|
|
40
40
|
Requires-Dist: genbadge[coverage]>=1.1.3; extra == "dev"
|
|
41
|
-
Requires-Dist: ruff>=0.2.
|
|
41
|
+
Requires-Dist: ruff>=0.2.1; extra == "dev"
|
|
42
42
|
Requires-Dist: bump-my-version>=1.0; extra == "dev"
|
|
43
43
|
Provides-Extra: calibration
|
|
44
44
|
Requires-Dist: pyemu>=1.4.0; extra == "calibration"
|
|
@@ -40,7 +40,7 @@ license = "Apache-2.0"
|
|
|
40
40
|
name = "mobidicpy"
|
|
41
41
|
readme = {file = "README.md", content-type = "text/markdown"}
|
|
42
42
|
requires-python = ">=3.11"
|
|
43
|
-
version = "0.2.
|
|
43
|
+
version = "0.2.1"
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
[project.optional-dependencies]
|
|
@@ -49,7 +49,7 @@ dev = [
|
|
|
49
49
|
"pytest-cov>=4.0",
|
|
50
50
|
"coverage>=7.0",
|
|
51
51
|
"genbadge[coverage]>=1.1.3",
|
|
52
|
-
"ruff>=0.2.
|
|
52
|
+
"ruff>=0.2.1",
|
|
53
53
|
"bump-my-version>=1.0",
|
|
54
54
|
]
|
|
55
55
|
calibration = [
|
|
@@ -136,7 +136,7 @@ force-single-line = true
|
|
|
136
136
|
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]
|
|
137
137
|
|
|
138
138
|
[tool.bumpversion]
|
|
139
|
-
current_version = "0.2.
|
|
139
|
+
current_version = "0.2.1"
|
|
140
140
|
|
|
141
141
|
[[tool.bumpversion.files]]
|
|
142
142
|
filename = "mobidic/__init__.py"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|