Skip to content

Commit 282f1eb

Browse files
authored
Merge pull request #195 from aleaf/main
pandas 3 support, flopy fixes and PRT demo fix + update
2 parents 30d622e + 7bd5ab9 commit 282f1eb

18 files changed

Lines changed: 354 additions & 133 deletions

.github/workflows/build_docs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
with:
4040
path: ~/.local/bin
4141
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
repo: modflow6
4243
- name: Modflow version
4344
shell: bash -l {0}
4445
run: mf6 --version

.github/workflows/test.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111

1212
jobs:
1313
build:
14-
name: ${{ matrix.python-version }}, ${{ matrix.os }}
14+
name: ${{ matrix.env }}, ${{ matrix.os }}
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
fail-fast: false
1818
matrix:
1919
os: [ ubuntu-latest, macos-latest, windows-latest ]
20-
python-version: ['3.12']
20+
env:
21+
- installation/environment.yml
22+
- ci/pandas2_env.yml
2123

2224
steps:
2325
- name: Checkout source
@@ -31,7 +33,7 @@ jobs:
3133
- name: Setup Micromamba
3234
uses: mamba-org/setup-micromamba@v2
3335
with:
34-
environment-file: installation/environment.yml
36+
environment-file: ${{ matrix.env }}
3537
cache-environment: false
3638
cache-downloads: false
3739
# persist on the same day.
@@ -52,6 +54,8 @@ jobs:
5254
with:
5355
path: ~/.local/bin
5456
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
repo: modflow6
58+
cache: false
5559
- name: Modflow version
5660
shell: bash -l {0}
5761
run: mf6 --version
@@ -76,6 +80,6 @@ jobs:
7680
- name: Run tests
7781
shell: bash -l {0}
7882
run: |
79-
pytest tests/test_notebooks.py -v
83+
pytest tests/test_notebooks.py
8084
env:
8185
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

AGENDA.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ Monday
5757
- 1500-1515: break
5858
- 1515-1545: 08 Modflow-setup demo (Andy)
5959
- 1545-1600: break
60-
- 1600-1630: 09 Run and process MF6T (Kalle)
60+
- 1600-1630: 09 Run and process MF6 GWT (Kalle)
6161
- 1630-1700: 10 Run and process MODPATH/MF6-PRT models (Andy)
6262
- 1700: Wrap up

ci/pandas2_env.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: pyclass
2+
channels:
3+
- conda-forge
4+
- nodefaults
5+
dependencies:
6+
# required
7+
- python=3.14
8+
- pip
9+
10+
- numpy
11+
- matplotlib
12+
13+
- jupyter
14+
- jupytext
15+
- jupyterlab
16+
- git
17+
- python-dateutil
18+
- affine
19+
- scipy
20+
- openpyxl
21+
- xlrd
22+
- pandas<3
23+
- netcdf4
24+
- pyshp
25+
- rasterio
26+
- rasterstats
27+
- fiona
28+
- descartes
29+
- pyproj
30+
- shapely
31+
- geos
32+
- geojson
33+
- geopandas
34+
- xarray
35+
- rioxarray
36+
- uxarray
37+
- pyyaml
38+
- rtree
39+
- pyvista
40+
- vtk
41+
- imageio
42+
- requests
43+
- pytest
44+
- statsmodels
45+
- dataretrieval
46+
- flopy=3.9
47+
- gis-utils
48+
- sfrmaker
49+
- contextily
50+
- cartopy
51+
- modflow-export
52+
- modflow-setup

docs/docs-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
dependencies:
55
# required
6-
- python=3.11
6+
- python=3.14
77
- pip
88

99
- numpy

installation/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies:
4343
- pytest
4444
- statsmodels
4545
- dataretrieval
46-
- flopy>=3.7
46+
- flopy=3.9
4747
- gis-utils
4848
- sfrmaker
4949
- contextily

notebooks/part1_flopy/03_Loading_and_visualizing_models.ipynb

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,6 @@
183183
"ax.set_ylabel(f'{modelgrid.units.capitalize()} northing, {modelgrid.crs.name}')"
184184
]
185185
},
186-
{
187-
"cell_type": "markdown",
188-
"metadata": {},
189-
"source": [
190-
"### Exporting the model grid to a shapefile"
191-
]
192-
},
193-
{
194-
"cell_type": "code",
195-
"execution_count": null,
196-
"metadata": {},
197-
"outputs": [],
198-
"source": [
199-
"modelgrid.write_shapefile(str(output_folder / 'pleasant_grid.shp'))"
200-
]
201-
},
202186
{
203187
"cell_type": "markdown",
204188
"metadata": {},
@@ -213,41 +197,15 @@
213197
"outputs": [],
214198
"source": [
215199
"modelgrid = model.modelgrid\n",
216-
"modelgrid_gdf = modelgrid.geo_dataframe"
200+
"modelgrid_gdf = modelgrid.geo_dataframe\n",
201+
"modelgrid_gdf"
217202
]
218203
},
219204
{
220205
"cell_type": "markdown",
221206
"metadata": {},
222207
"source": [
223-
"#### Add row, column information to model grid `GeoDataFrame`"
224-
]
225-
},
226-
{
227-
"cell_type": "code",
228-
"execution_count": null,
229-
"metadata": {},
230-
"outputs": [],
231-
"source": [
232-
"modelgrid.shape"
233-
]
234-
},
235-
{
236-
"cell_type": "code",
237-
"execution_count": null,
238-
"metadata": {},
239-
"outputs": [],
240-
"source": [
241-
"modelgrid_gdf.index[-1] // modelgrid.ncol"
242-
]
243-
},
244-
{
245-
"cell_type": "code",
246-
"execution_count": null,
247-
"metadata": {},
248-
"outputs": [],
249-
"source": [
250-
"1 // modelgrid.ncol"
208+
"### Exporting the model grid to a shapefile"
251209
]
252210
},
253211
{
@@ -256,9 +214,7 @@
256214
"metadata": {},
257215
"outputs": [],
258216
"source": [
259-
"modelgrid_gdf['i'] = modelgrid_gdf.index // modelgrid.ncol\n",
260-
"modelgrid_gdf['j'] = modelgrid_gdf.index % modelgrid.ncol\n",
261-
"modelgrid_gdf.head()"
217+
"modelgrid_gdf.to_file(output_folder / 'pleasant_grid.shp')"
262218
]
263219
},
264220
{
@@ -1100,13 +1056,24 @@
11001056
"fig, ax = plt.subplots(figsize=(10, 5))\n",
11011057
"in_cols = ['STO-SS_IN', 'STO-SY_IN', 'WEL_IN', 'RCHA_IN', 'CHD_IN', 'SFR_IN', 'LAK_IN']\n",
11021058
"out_cols = [c.replace('_IN', '_OUT') for c in in_cols]\n",
1059+
"# as of pandas 3.0.1, \n",
1060+
"# the datatime index of the flux dataframe produced by Flopy produces an error with .plot.bar();\n",
1061+
"# switch the index to a categorical (date string) index instead\n",
1062+
"flux.index = flux.index.strftime('%Y-%m-%d')\n",
11031063
"flux[in_cols].plot.bar(stacked=True, ax=ax)\n",
11041064
"(-flux[out_cols]).plot.bar(stacked=True, ax=ax)\n",
11051065
"ax.legend(loc='lower left', bbox_to_anchor=(1, 0))\n",
11061066
"ax.axhline(0, lw=0.5, c='k')\n",
11071067
"ax.set_ylabel('Simulated Flux, in $m^3/d$')"
11081068
]
11091069
},
1070+
{
1071+
"cell_type": "code",
1072+
"execution_count": null,
1073+
"metadata": {},
1074+
"outputs": [],
1075+
"source": []
1076+
},
11101077
{
11111078
"cell_type": "markdown",
11121079
"metadata": {},
@@ -1142,7 +1109,7 @@
11421109
"name": "python",
11431110
"nbconvert_exporter": "python",
11441111
"pygments_lexer": "ipython3",
1145-
"version": "3.12.11"
1112+
"version": "3.14.3"
11461113
}
11471114
},
11481115
"nbformat": 4,

notebooks/part1_flopy/04_Modelgrid_and_intersection.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@
12021202
"outputs": [],
12031203
"source": [
12041204
"main_stem = []\n",
1205-
"gx = GridIntersect(modelgrid, method=\"vertex\")\n",
1205+
"gx = GridIntersect(modelgrid)\n",
12061206
"for iloc, row in flw_main.iterrows():\n",
12071207
" results = gx.intersect(row.geometry)\n",
12081208
" main_stem.extend(results.cellids)\n",

notebooks/part1_flopy/05_Unstructured_Grid_generation.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@
399399
"metadata": {},
400400
"outputs": [],
401401
"source": [
402-
"ix = GridIntersect(sgrid, method=\"vertex\")\n",
402+
"ix = GridIntersect(sgrid)\n",
403403
"result = ix.intersect(basindf.geometry.values[0], contains_centroid=True)\n",
404404
"rowcol = result[\"cellids\"]"
405405
]
@@ -550,7 +550,7 @@
550550
"outputs": [],
551551
"source": [
552552
"rowcols = []\n",
553-
"ix = GridIntersect(sgrid, method=\"vertex\")\n",
553+
"ix = GridIntersect(sgrid)\n",
554554
"for geom in nhddf.geometry.values:\n",
555555
" rcs = ix.intersects(geom)[\"cellids\"]\n",
556556
" rowcols.extend(list(rcs))"
@@ -673,7 +673,7 @@
673673
"metadata": {},
674674
"outputs": [],
675675
"source": [
676-
"ix = GridIntersect(rfgrid, method=\"vertex\")\n",
676+
"ix = GridIntersect(rfgrid)\n",
677677
"result = ix.intersect(basindf.geometry.values[0], contains_centroid=True)\n",
678678
"rowcol = result[\"cellids\"]\n",
679679
"\n",
@@ -849,7 +849,7 @@
849849
"# live code this/give it as an activity\n",
850850
"idomainp = np.ones(sgrid.idomain.shape, dtype=int)\n",
851851
"\n",
852-
"gix = GridIntersect(sgrid, method=\"vertex\")\n",
852+
"gix = GridIntersect(sgrid)\n",
853853
"result = gix.intersect(lgr_gdf.geometry.values[0])\n",
854854
"cid = result[\"cellids\"]\n",
855855
"\n",
@@ -959,7 +959,7 @@
959959
"metadata": {},
960960
"outputs": [],
961961
"source": [
962-
"ix = GridIntersect(childgrid, method=\"vertex\")\n",
962+
"ix = GridIntersect(childgrid)\n",
963963
"cstrmcells = []\n",
964964
"for geom in nhddf.geometry.values:\n",
965965
" rcs = ix.intersects(geom)[\"cellids\"]\n",
@@ -1120,7 +1120,7 @@
11201120
"source": [
11211121
"# create the idomain array\n",
11221122
"idomain = np.zeros(quadgrid.shape, dtype=int)\n",
1123-
"ix = GridIntersect(quadgrid, method=\"vertex\")\n",
1123+
"ix = GridIntersect(quadgrid)\n",
11241124
"nodes = ix.intersect(basindf.geometry.values[0], contains_centroid=True)[\"cellids\"]\n",
11251125
"\n",
11261126
"idomain[:, list(nodes)] = 1\n",
@@ -1136,7 +1136,7 @@
11361136
"source": [
11371137
"# create an array of stream cells\n",
11381138
"qstr = []\n",
1139-
"ix = GridIntersect(quadgrid, method=\"vertex\")\n",
1139+
"ix = GridIntersect(quadgrid)\n",
11401140
"for geom in nhddf.geometry.values:\n",
11411141
" nodes = ix.intersects(geom)[\"cellids\"]\n",
11421142
" qstr.extend(list(nodes))"
@@ -1383,7 +1383,7 @@
13831383
"outputs": [],
13841384
"source": [
13851385
"tristr = []\n",
1386-
"ix = GridIntersect(trigrid, method=\"vertex\")\n",
1386+
"ix = GridIntersect(trigrid)\n",
13871387
"for geom in nhddf.geometry.values:\n",
13881388
" nodes = ix.intersects(geom)[\"cellids\"]\n",
13891389
" tristr.extend(list(nodes))\n",
@@ -1519,7 +1519,7 @@
15191519
"outputs": [],
15201520
"source": [
15211521
"vorst = []\n",
1522-
"ix = GridIntersect(vorgrid, method=\"vertex\")\n",
1522+
"ix = GridIntersect(vorgrid)\n",
15231523
"for geom in nhddf.geometry.values:\n",
15241524
" nodes = ix.intersects(geom)[\"cellids\"]\n",
15251525
" vorst.extend(list(nodes))\n",

notebooks/part1_flopy/06-Project-structured.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"metadata": {},
144144
"outputs": [],
145145
"source": [
146-
"ix = GridIntersect(base_grid, method=\"vertex\", rtree=True)"
146+
"ix = GridIntersect(base_grid, rtree=True)"
147147
]
148148
},
149149
{

0 commit comments

Comments
 (0)