Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Fetch all Git tags
run: git fetch --prune --unshallow --tags

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@v3
with:
environment-file: ci/test_environment.yaml
cache-environment: false
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
make -C docs html

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.7.2
uses: JamesIves/github-pages-deploy-action@v4.8.0
if: ${{ github.event_name == 'release' }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -90,7 +90,7 @@ jobs:
TARGET_FOLDER: ${{ github.ref }}

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.7.2
uses: JamesIves/github-pages-deploy-action@v4.8.0
if: ${{ github.event_name == 'push' }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
pull-requests: write
steps:
- name: Checkout master branch
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: master
- name: Bump version and push tag
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
persist-credentials: false
ref: master
Expand All @@ -67,7 +67,7 @@ jobs:
echo ${{ steps.get_version.outputs.version }}

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@v3
with:
environment-file: ci/test_environment.yml
cache-environment: true
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
make -C docs html

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.7.2
uses: JamesIves/github-pages-deploy-action@v4.8.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
Expand All @@ -137,13 +137,13 @@ jobs:
steps:

- name: Checkout master branch
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: master
fetch-tags: true

- name: Setup Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: '3.x'
cache: 'pip'
Expand All @@ -161,7 +161,7 @@ jobs:
run: twine check --strict dist/*

- name: Upload package
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: dist
path: dist
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
persist-credentials: false

Expand All @@ -41,7 +41,7 @@ jobs:
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@v3
with:
environment-file: ci/test_environment.yaml
cache-environment: false
Expand Down Expand Up @@ -78,11 +78,27 @@ jobs:
cp -r bin/$d/. "$HOME/.local/bin/"
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo $GITHUB_PATH
# on Windows, test against last Flopy release
- name: Install latest PyPI flopy
- name: Test with latest PyPI flopy
shell: bash -l {0}
if: contains(matrix.os, 'windows')
run: pip install flopy --force-reinstall
if: ${{ matrix.python-version == 3.12}}
run: |
pip install flopy
pip install git+https://github.com/aleaf/modflow-export@develop
pip install git+https://github.com/usgs/sfrmaker@develop
- name: Test with latest conda flopy
shell: bash -l {0}
if: ${{ matrix.python-version == 3.13}}
run: |
micromamba install flopy
pip install git+https://github.com/aleaf/modflow-export@develop
pip install git+https://github.com/usgs/sfrmaker@develop
- name: Test with latest develop flopy and pandas 3
shell: bash -l {0}
if: ${{ matrix.python-version == 3.14}}
run: |
pip install git+https://github.com/modflowpy/flopy@develop --no-deps
pip install git+https://github.com/aleaf/modflow-export@develop
pip install git+https://github.com/usgs/sfrmaker@develop
- name: Install Modflow-setup and ipykernel
shell: bash -l {0}
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
shell: bash -l {0}
steps:
- name: Checkout source
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Fetch all Git tags
run: git fetch --prune --unshallow --tags
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@v3
with:
environment-file: ci/test_environment.yaml
cache-environment: false
Expand Down
5 changes: 1 addition & 4 deletions ci/test_environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
- coverage
- flake8
- pytest
- sphinx=8.1.3
- sphinx
- numpydoc
- nbsphinx # for rendering notebooks in sphinx-generated docs
- sphinx-copybutton
Expand All @@ -36,6 +36,3 @@ dependencies:
- pip:
- gis-utils
- pytest-timeout
- git+https://github.com/modflowpy/flopy@develop
- git+https://github.com/aleaf/modflow-export@develop
- git+https://github.com/usgs/sfrmaker@develop
5 changes: 5 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
autosummary_generate = True
numpydoc_show_class_members = False

# Only generate for top n sections
# (and then only use sections headers need to be unique;
# duplicate headers are allowed below this level)
#autosectionlabel_maxdepth=2

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down
21 changes: 15 additions & 6 deletions docs/source/release-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@
Release History
===============

Version 0.8.0 (2026-02-xx)
----------------------------------------
**New Features:**
* Add support for Pandas 3
* Add support for geopackage input with layernames (specified in format: filename>.gpkg|layername=<layer name> or filename>.gpkg|layer=<layer name>), for example as a way to specify the active model extent (e.g. in the source_data: idomain: block for Modflow 6 models)

**Bug Fixes:**
* fixes to SFR Package setup:
* re-adjust SFR package layering each time idomain is adjusted, to prevent SFR in inactive cells (SFR reaches with no groundwater connections)
* write SFR Package shapefiles when MODFLOW input is written, so that the shapefiles reflect the final state of the SFR package

Version 0.7.0 (2025-12-31)
----------------------------------------
New Features:
**************
**New Features:**
* Added partial support for GeoPackages (.gpkg) input
* Added support for SFRmaker streambed top field elevations input.
* Add auto_flow_reduce = 0.1 by default in MF6 model Well Packages

Bug Fixes:
*************
**Bug Fixes:**
* Refactor np.in1d to np.isin to resolve numpy error
* Refactoring to support various Flopy interface changes
* Allow shapefile input with no 'id_column' for basic stress packages
* Fix issue with Well Package layer assignment in cases where there is no open interval information (only well bottom). When there is only screen_top or screen_botm, or screen_top == screen_botm, set the screen_top and screen_botm to the top/bottom of layer intersecting the well bottom (i.e. so that the well is placed in this layer). Previously, a zero open interval thickness in these situations was resulting in the well getting re-assigned to the highest transmissivity layer at that i, j location.
* Fix issue with MODFLOW 6 configuration file defaults: Well Package auto_flow_reduce needs to be a float (not True, which will result in an auto flow reduce value of 1.0 being assigned (almost full suppression of pumping); set auto_flow_reduce default of 0.1
* Fix issue with Well Package Setup: Pass non-default screen_top_col and screen_botm_col to assign_layers_from_screen_top_botm; otherwise an error results when non-default names for these are used.
* Fix issue with MODFLOW 6 configuration file defaults: Well Package auto_flow_reduce needs to be a float (not True, which will result in an auto flow reduce value of 1.0 being assigned (almost full suppression of pumping); set auto_flow_reduce default of 0.1.
* Fix issue with Well Package Setup: Pass non-default screen_top_col and screen_botm_col to assign_layers_from_screen_top_botm; otherwise an error results when non-default names for these are used.

Version 0.6.1 (2025-03-17)
----------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions mfsetup/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def setup_basic_stress_data(model, shapefile=None, csvfile=None,
return

# create polygons of model grid cells
if bc_cells.dtype == object:
if pd.api.types.is_string_dtype(bc_cells.dtype):
cells_with_bc = bc_cells.flat != ''
else:
cells_with_bc = bc_cells.flat > 0
Expand All @@ -108,7 +108,7 @@ def setup_basic_stress_data(model, shapefile=None, csvfile=None,
'i': i.flat,
'j': j.flat})
# add the boundnames
if bc_cells.dtype == object:
if pd.api.types.is_string_dtype(bc_cells.dtype):
df_0['boundname'] = bc_cells.flat
nan_boundnames = df_0.boundname.isna() | df_0.boundname.isin({'', 'nan'})
df_0.loc[nan_boundnames, 'boundname'] = 'unnamed'
Expand Down
4 changes: 2 additions & 2 deletions mfsetup/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def load_array(filename, shape=None, nodata=-9999):
print(txt, end=', ')
# arr = np.loadtxt
# pd.read_csv is >3x faster than np.load_txt
arr = pd.read_csv(f, delim_whitespace=True, header=None).values
arr = pd.read_csv(f, sep=r'\s+', header=None).values
if shape2d is not None:
if arr.shape != shape2d:
if arr.size == np.prod(shape2d):
Expand Down Expand Up @@ -1146,7 +1146,7 @@ def read_ggofile(gagefile, model,
names = [n.lower() for n in names]
df = pd.read_csv(src, skiprows=0,
header=None,
delim_whitespace=True,
sep=r'\s+',
names=names
)
kstp = []
Expand Down
10 changes: 6 additions & 4 deletions mfsetup/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def write_bbox_shapefile(modelgrid, outshp):
gdf.to_file(outshp, index=False)


def rasterize(feature, grid, id_column=None,
def rasterize(feature, grid, layer=None, id_column=None,
include_ids=None, exclude_ids=None, names_column=None,
crs=None, **kwargs):
"""Rasterize a feature onto the model grid, using
Expand All @@ -642,8 +642,10 @@ def rasterize(feature, grid, id_column=None,

Parameters
----------
feature : str (shapefile path), list of shapely objects,
feature : str (shapefile or geopackage path), list of shapely objects,
or dataframe with geometry column
layer : str
Layer name containing the feature (for example, in a geopackage)
id_column : str
Column with unique integer identifying each feature; values
from this column will be assigned to the output raster.
Expand Down Expand Up @@ -695,7 +697,7 @@ def rasterize(feature, grid, id_column=None,
trans = get_transform(grid)

if isinstance(feature, str) or isinstance(feature, Path):
df = gpd.read_file(feature)
df = gpd.read_file(feature, layer=layer)
elif isinstance(feature, pd.DataFrame):
df = feature.copy()
df = gpd.GeoDataFrame(df, crs=crs)
Expand Down Expand Up @@ -747,7 +749,7 @@ def rasterize(feature, grid, id_column=None,
numbers = list(range(1, len(df)+1))
# if IDs are strings, get a number for each one
# pd.DataFrame.unique() generally preserves order
elif df[id_column].dtype == object:
elif pd.api.types.is_string_dtype(df[id_column].dtype):
unique_values = df[id_column].unique()
values = dict(zip(unique_values, range(1, len(unique_values) + 1)))
numbers = [values[n] for n in df[id_column]]
Expand Down
13 changes: 11 additions & 2 deletions mfsetup/mf6model.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _set_idomain(self):

# remove cells that are above stream cells
if self.get_package('sfr') is not None:
idomain = deactivate_idomain_above(idomain, self.sfr.packagedata)
idomain = deactivate_idomain_above(idomain, self.sfrdata.reach_data)

# inactivate any isolated cells that could cause problems with the solution
idomain = find_remove_isolated_cells(idomain, minimum_cluster_size=20)
Expand Down Expand Up @@ -262,7 +262,10 @@ def _set_idomain(self):
data={0: irch},
datatype='array2d',
write_fmt='%d', dtype=int)
#self.dis.irch = self.cfg['dis']['irch']

if hasattr(self, 'sfrdata'):
self.adjust_sfr_layers_model_bottom()


def _update_grid_configuration_with_dis(self):
"""Update grid configuration with any information supplied to dis package
Expand Down Expand Up @@ -1045,6 +1048,12 @@ def skip_write(**kwargs):
options=options,
external_files_path=model.external_path
)
# write reach and segment data tables
model.sfrdata.write_tables('{}/{}'.format(self._tables_path, self.name))

# export shapefiles of lines, routing, cell polygons, inlets and outlets
model.sfrdata.write_shapefiles('{}/{}'.format(self._shapefiles_path, self.name))

# add version info to package file headers
files = [model.namefile]
files += [p.filename for p in model.packagelist]
Expand Down
Loading
Loading