Conversation
Post release 3.10.0 reset
The model splitter generated empty SSM package files for partitions containing no boundary conditions, causing MODFLOW 6 to fail. The _remap_ssm() method set a dict entry to None to indicate a partition had no boundary flows. Later the dict is checked in an if statement and considered "truthy" since it contains an entry whose value is None Instead, indicate no boundary flows by not adding an entry to the dict. The conditional works, no SSM package is created, no file written, MF6 is happy. Fix #2715
Recently pandas 3 was released. Only minimal changes needed from us, namely * switching timedelta units from deprecated "d" to "D" * a fix in the model splitter where columns that were previously renamed automatically on dataframe construction must now be renamed manually due to stricter dataframe init method requirements There are two other potentially relevant changes * String dtype Pandas 3 will infer string columns as str dtype instead of object. Code checking dtype == 'object' for strings will break. I think we are safe as internal dtype checks are generally on numpy arrays, not pandas DataFrames. We kind of luck out for having not migrated everything over to pandas. When we do pd.DataFrame.from_records(recarray), numpy string fields will get converted to str dtype instead of object. But I don't think we need to care, indexing, selection, etc should all work as before. * Copy-on-Write (CoW) As far as I can tell we use .loc internally, no chained assignments, so we should be good.
I borked devtools 1.9.0 MODFLOW-ORG/modflow-devtools#299, make sure we don't use it. Also add an upper bound.
Delete all the TOMLs before recreating them from DFNs otherwise unwanted TOML components can remain
The logic to separate PRT pathlines by composite key for VTK export was - slow: O(n^4 * m) where n is unique values per column and m is the total number of rows - wrong: exported empty pathlines in most cases due to some incorrect filtering Replace the nested loops and repeated np.unique() calls with a single unique(return_inverse=True) taking a composite key dtype. Should be O(n log n) now.
add_vector() assigns a vector to each grid cell. The method takes an array of shape (3, nnodes) and passes it to numpy_support.numpy_to_vtk(), which due to the order of indices flattens it in column-major order, but VTK expects row-major order. So where cell i should get (x[i], y[i], z[i]) it instead gets (x[3i], x[3i+1], x[3i+2]) Fixed by transposing the array passed to numpy_to_vtk() so it is (nnodes, 3) and is flattened/interpreted correctly
* set data internal for model splitting * fix(split_model): update external file handling for model splitter Maintain external file paths when user passes optional sim_ws parameter * updates(model_splitter.py): multiple bug fixes * filter (-1,) SFR cellids from splitting mask creation in optimize_splitting_mask * adjust (-1,) SFR cellid layer number to 0 in _remap_sfr to avoid index errors * handle external model files by allowing user to specify new simulation workspace `sim_ws` to `split_model` and `split_multi_model` * dynamically adjust `max_columns_of_data` when external model files are maintained in the split models * update external ascii test * Add "angrot" to the offsets dictionary
Small fix to iteration in NodeParticleData.to_prp(). Added another iteration through nodedata, as previously iteration only passed through the first node, so total particles could only equal the number of subdivisions. With fix total particles now equals the number of nodes times the number of subdivisions.
Support writing binary head, budget and grid files, both brand-new via classmethods, and copying existing files to new paths via instance methods.
Add write() classmethods to HeadFile and CellBudgetFile. These write a new file with the given data and return an instance with it open.
There are a few syntax variants for head files.
# dict keyed by (kstp, kper)
hds = HeadFile.write(
'output.hds',
# totim/pertim inferred (dt = 1.0 / time step)
data={
(1, 1): h_t1,
(1, 2): h_t2,
}
)
# list
hds = HeadFile.write('output.hds', data=[
{'data': h_t2, 'kstp': 1, 'kper': 1, 'totim': 10.0, 'pertim': 10.0},
{'data': h_t2, 'kstp': 1, 'kper': 2, 'totim': 20.0, 'pertim': 10.0},
])
# array/list with time as first dimension
# defaults to sequential stress periods: (1,1), (1,2), (1,3), ...
heads = [h_t1, h_t2, h_t3] # or np.array([h_t1, h_t2, h_t3])
hds = HeadFile.write('output.hds', heads)
# array/list with custom tdis
hds = HeadFile.write('output.hds', heads, kstpkper=[(1, 1), (2, 1), (3, 1)])
Again there are variants for budget files. The typical case is to use data with a list, where each entry has "text", "kper", "kstp", and "data" entries, and "data" is an array, typically grid-shaped. But it can be convenient to use text and pass a time-indexed dictionary to data to create a file with a single variable.
# just face flows, dict keyed by (kstp, kper)
cbc = CellBudgetFile.write(
'output.cbc',
text='FLOW-JA-FACE',
nlay=3,
nrow=10,
ncol=20,
data={
(1, 1): q_t1,
(1, 2): q_t2,
}
)
# multiple variables, list
cbc = CellBudgetFile.write(
'output.cbc',
data=[
{'data': q_t1, 'kstp': 1, 'kper': 1, 'totim': 10.0,
'text': 'FLOW-JA-FACE'},
{'data': ...},
...
]
)
# array/list with time dimension (grid-shaped data like storage)
# defaults to sequential stress periods: (1,1), (1,2), (1,3), ...
# grid dimensions inferred from array shape
storage = [s_t1, s_t2, s_t3] # nlay x nrow x ncol arrays
cbc = CellBudgetFile.write('output.cbc', storage, text='STORAGE')
# for face flows, grid dimensions are required since data is 1D
flows = [q_t1, q_t2] # 1D arrays
cbc = CellBudgetFile.write(
'output.cbc',
flows,
text='FLOW-JA-FACE',
nlay=3, nrow=10, ncol=20
)
If only face flows are provided, the grid shape must be specified with nlay/nrow/ncol, nlay/ncpl, or nnodes. If grid-shaped variables are provided, the grid's shape will be inferred.
Instance methods
Add instance export() methods to MfGrdFile, HeadFile, and CellBudgetFile. These copy the contents of an open file to another, optionally filtering by variable and/or time step, or changing the precision. There is no write() method for MfGrdFile, as its signature would have been long and complicated to accommodate all grid types.
from flopy.mf6.utils.binarygrid_util import MfGrdFile
grb = MfGrdFile("model.grb")
grb.export("copy.grb") # copy to another file
grb.export("diff_prec.grb", precision="single") # different precision
from flopy.utils.binaryfile import HeadFile, CellBudgetFile
hds = HeadFile("model.hds")
hds.export("copy.hds") # copy to another file
hds.export("filtered.hds", kstpkper=[(1, 0), (1, 1)]) # filter time steps
hds.export("diff_prec.hds", precision="single") # different precision
cbc = CellBudgetFile("model.cbc")
cbc.export("copy.cbc")
cbc.export("flowja.cbc", text="FLOW-JA-FACE")
cbc.export("bndpkgs.cbc", text=["STORAGE", "CONSTANT HEAD"])
cbc.export("filtered.cbc", kstpkper=[(1, 0)], text="FLOW-JA-FACE")
…#2750) Model-level MVE package was previously supported by virtue of the dfn file. However, simulation-level support for MVE was not supported. A new autotest for MF6 confirms that these changes are sufficient. This missing functionality was discovered when attempting to support parallel energy mover (MVE) transport in MF6. For example, if a stream was split across two flow and transport models and a transport mover was required to properly route solute from an SFT reach in one model to a connected SFT reach in a downstream model, MVT worked, but its complement in GWE, namely MVE, was not working prior to this PR.
* Add entry point to "layered" data specification in MFArray
732a55b introduced setup-uv and switched most jobs off setup-micromamba. Some were not changed because dependencies were only available from conda-forge, not PyPI - windows pymetis - arm mac vtk >=9.4.0 VTK is available from PyPI, and we can use the MF6 pixi rtd environment with setup-pixi where setup-micromamba is otherwise used, dropping setup-micromamba.
* add tests for the PR changes
* New feats: updates to Grid, GridIntersect, and VoronoiGrid Updates support development of generalized HFB creation methods * Grid: add cell_area property via the shoelace algorithm * GridIntersect: add "experimental" support for UnstructuredGrid * VoronoiGrid: add support for get_disu6_gridprops() that can build MF6 DISU packages * Feat(hfb_util): add hfb builder method * add make_hfb_array and supporting methods to build HFB recarrays from LineString / Grid intersections * Linting * update hfb_util: add perturbation routine for edge cases * catches "mid cell split" and "colinear with cell boundary" edge cases * Added tests for hfb_util * fix spelling * Add notebook documentation for `make_hfb_array` utility
The nightly optional dependency job installs the optional dependencies and then removes three of them chosen by the date, so it reaches combinations the job that installs none of them does not. Shapefile export goes through geopandas, but the export tests were marked as needing only pyshp and failed with an ImportError rather than being skipped on the night geopandas was removed. The two export tests that do not go through geopandas keep their existing mark. The mark for sklearn on test_save_load_node_mapping_structured was added commented out and never took effect, so that test failed the same way when scikit-learn was removed.
volumetric_budget_bar_plot labels each bar by indexing the values with the position of the bar, but the values are passed in as a series indexed by zone name, so the label lookup raised a KeyError. Pandas used to fall back to positional indexing for a series that is not indexed by integers and no longer does. The values are now taken out of the series before they are indexed.
* fix(vtk): transpose the vector after the point scalar expansion add_vector builds a row per component and numpy_to_vtk flattens in row-major order, so the array has to be transposed to give a row per cell or point. The transpose was applied to the vector sized 3 * nnodes before the point scalar expansion, which left three of the four paths through the method wrong: the point scalar loop indexed a row per cell rather than a row per component and raised an IndexError, and the vector sized 3 * ncpl was never transposed at all and silently wrote the first component to all three. The transpose is now applied once, after the expansion, so a cell gets its own three components in every case. The vector sized 3 * nnodes without point scalars is the one path that was already correct and is unchanged. test_vtk_vector covers only one of the four paths and is marked slow, so the smoke test used by the test matrix skips it and only the nightly optional dependency workflow runs it. A test covering all four paths has been added without the slow mark. * test(test_export): drop the slow mark from test_vtk_vector The smoke test used by the test matrix skips the tests marked slow, so test_vtk_vector only ran in the nightly optional dependency workflow. It loads a model and exports it but does not run one, and takes about half a second, which is below the median of the tests that carry the mark. It now runs wherever vtk is installed.
Co-authored-by: Joseph Hughes <jdhughes99+1@gmail.com>
Close #2798. Markers can't be applied to fixtures, only tests.
Filter out fields marked in DFNs as removed from the generated classes in the MF6 module. Before, removed fields were included in the generated classes and would be written to input files, which would cause MF6 to raise an error. And remove usages of options recently been removed from MF6.
Motivated by CI errors caused by unreliably provisioned GitHub Actions runners
#2795) * returns dictionary of keyword arguments to build DIS, DISV, and DISU depending on grid type * added cell `.area` calculation via shoelace algorithm to `Grid` * remove deprecated flopy.mf6.utils/reference.py which housed "pre-modelgrid" spatial reference support for MF6 models closes #2388 closes #2661
This PR separates a few optional dependencies into dependency groups, as defined by PEP 735. The optional dependencies (or "extras") are kept, and are intended for user-facing install options: * optional: this is the primary group, with documentation and support functions * codegen: includes other dependencies needed for code generation Dependency groups are intended for internal or developer-facing install options: * lint, test and dev are re-listed as dependency groups * doc is renamed as docs group, plural to match the folder name "docs" * The dev group is similar to as it was as an extra, but doc (now docs) is removed, as not all developers need to create docs (? maybe?); nevertheless it can be installed via --group docs A few sections of DEVELOPER.md were revised to describe how to install the extras or dependency groups in different Python environments. The pytest header (in autotest/conftest.py) is modified to only show "optional" packages and not the "test" dependency group packages. If this is important, it could be re-enabled, but it would need to parse the group directly from pyproject.toml, as this information is not part of the project's metadata.
Some requires_pkg markers were missing, causing optional dependency CI testing to fail
Close #2808 and fix some other example notebook failures * grid_intersection_example.py: removed leading # %% before the YAML front-matter, which was causing jupytext to fail to parse and consequently fail to auto-detect a kernel * feat_working_stack_examples.py: change df_flux.groupby(lambda x: x.split("_")[-1], axis=1) → df_flux.T.groupby(lambda x: x.split("_")[-1]), since pandas 3.0 removed the axis parameter from DataFrame.groupby() * plot_map_view_example.py and plot_cross_section_example.py: these used to use PyCharm-style cell markers until chore(dependencies): update conda environment #2414, but that PR missed a few # + lines that now have no matching closing markers. Jupytext's light-format parser swallows everything after these into one giant cell until it processes some markdown further down that superficially looks like another # + marker, which messes up the notebook's cell rendering.
This check (self.laytyp==5) always defaults to False as self.laytyp is a MFArray due to the super().__init__. Therefore, if laytyp=5 parsed to the MfUsgLpf.init, self.richards will always be False and unsaturated flow won't be simulated.
Related discussion in #2466
requires_pkg() resolves a distribution name and imports the matching module, and scikit-learn matches neither name on its own: the distribution is scikit-learn and the module is sklearn. test_save_load_node_mapping_structured was therefore skipped everywhere, including the nightly optional dependency build, and had never run. Map the distribution to its module so the test runs.
…2823) uv run re-syncs the project before it runs the command, which undoes both the --only-group test install and the random uninstall that precede it. Both matrix variants therefore run the full test suite with every optional dependency present, and the workflow has not been testing the absence of any of them. In the 22 Aug run the no optional dependencies job reported all 21 optional packages installed and passed tests that require pymetis. Run pytest with --no-sync so the environment the steps built is the one used, and add a workflow_dispatch trigger so the workflow can be run on demand.
Installing h5py from pypi into an environment that already carries the HDF5 library from conda loaded the wrong library on windows, so add the optional dependencies FloPy tests need with pixi instead. conda-forge builds pymetis for windows, which pypi does not, so the metis tests run on all three platforms. Adding pymetis runs the metis splitting tests for the first time on a pull request, and test_multi_model fails on macOS. Add h5py and scikit-learn now so the node mapping tests run, and add pymetis once that failure is resolved.
With MF6.8.0 there is no longer a distribution for Intel macOS
For the MF6.8.0 release
… update changelog
wpbonelli
marked this pull request as ready for review
September 3, 2026 14:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FloPy 3.11.0
The release can be approved by merging this pull request into
master. This will trigger a final job to publish the release to PyPI.