modflow.infoHomeResourcesToolsExamplesSearchAbout

MODFLOW Document

Writes a Microsoft Word report, with an HTML copy, that documents one or more MODFLOW simulations: packages, grid and layers, stress periods, aquifer properties, boundary conditions, heads, water budget and calibration. Version 1.0.0, November 2026.

1. Overview

Model documentation repeats the same work for every model: tables of layers and properties, maps of each layer, boundary-condition summaries, budget tables, calibration statistics and a hydrograph for every target. MODFLOW Document does that part. It reads the simulations in a folder, takes the project, simulation and hydrostratigraphic names from ConceptualModel.csv, and writes a report with one chapter per simulation.

The text states facts taken from the model files and outputs. Where a statement needs the modeler's knowledge, such as the purpose, data sources, interpretation or the calibration verdict, it writes a highlighted placeholder [Modeler: …] instead of guessing.

4MODFLOW families: 2005, NWT, USG / USG-Transport, MODFLOW 6
2report formats: Word (.docx) and HTML, with the same content
1,214hydrographs for the DWRM4 example: a PNG each, a PDF per layer and one of all
19 minto document DWRM4: 899,955 cells, 240 stress periods, 38.5 GB budget file

MODFLOW Document builds on MODFLOW Review, which reads the models and checks their quality, and is a companion to MODFLOW Compare. It carries its own copy of the reviewer code and of the bundled FloPy fork, so it runs on its own. It never changes the model files.

2. Installation

Copy the modflow_document folder. It runs in the esi_py26 conda environment, which has numpy, pandas, matplotlib, scipy, geopandas, pyproj and plotly, plus python-docx, which writes the Word file:

conda activate esi_py26
python -m pip install python-docx

Microsoft Word is not needed to write the report, only to read it. The FloPy fork in vendor\ is used automatically. MODFLOW itself is only needed by the tests, which run MF2005 from GWV9.

3. Usage

python modflow_document.py FOLDER [-o OUT] [--no-maps] [--no-hydrographs] [--debug]

FOLDER holds the simulations, directly or in subfolders at any depth, and optionally ConceptualModel.csv. The report goes to FOLDER\model_document and is named after the model, for example DWRM4_Model_Documentation.docx and .html.

Command-line options

OptionEffect
-o, --out DIROutput folder instead of FOLDER\model_document.
--no-mapsNo plan-view maps, which is faster. Tables, budget and calibration figures are still drawn.
--no-hydrographsNo hydrograph for each target. Calibration statistics and the review figures stay.
--debugPrint the full Python traceback when something goes wrong.

Errors that stop a run

The app ends with a one-line ERROR: message and exit code 1, never a traceback, when:

Problems that affect only part of the report do not stop it. A simulation that cannot be read gets a short chapter saying why. A missing shapefile, an unreadable package or a figure that cannot be drawn is written to the report's notes.

4. ConceptualModel.csv

A CSV file divided into sections. Each section starts with a line whose first cell begins with #. The example below is the file supplied with DWRM4:

#Project,
Company,"Environmental Simulations, Inc."
Client,Southwest Florida Water Management District
Model,DWRM4
,
#Simulations,
dwrm4_tr15h,Transient Calibration
,
#Stratigraphy,
Surficial Aquifer System,1
Intermediate Confining Unit,2
Upper Arcadia Aquifer,3
...
Lower Floridan Aquifer VIII,15
,
#Shapefiles,
Counties_within_the_District.shp,County Boundaries
SectionEach lineUsed for
#ProjectCompany, Client or Model, and a value; other keys are keptTitle page, report file name, introduction
#SimulationsName-file root (without .nam) and a descriptionWhich simulations are documented, their order and their chapter titles
#StratigraphyUnit name and its layer(s): 3, 3-4, 3 to 4 or 3;5Layer labels on tables, maps and hydrographs; tables and budget by unit; hydrograph selection
#ShapefilesShapefile (relative to the folder) and what it showsOutlines drawn on every plan-view map, with a legend entry

Section names are not case sensitive and the file name is matched in any case. A stratigraphy line without a layer takes the next layer, and layer,name is also accepted. The following are listed under "Notes on the input to this report" in the report:

Without the file the report still works: it uses the file names, refers to layers by number and has no map annotation.

5. How it works

ReadConceptualModel.csv
→
Findsimulations in the folder tree
→
Reviewload the model and outputs; run MODFLOW Review
→
Gathertables, maps, budgets, hydrographs, PDFs
→
Composechapters, captions, placeholders
→
WriteWord and HTML

For each simulation the bundled MODFLOW Review loads the model and reads the heads, the cell-by-cell budget, the listing file and the calibration residual files. It writes its complete review to review\<simulation>. MODFLOW Document reuses everything the review read: each large output file is opened once for the review and only the last budget step is read again for the budget by unit. It then derives its own tables and figures and composes the report as a document model, numbering the figures and tables. Two writers turn that model into Word (python-docx) and HTML.

6. Finding the simulations

7. What the report contains

The report starts with a title page (client, company, month) and an introduction:

Then each simulation gets a chapter with the sections below. Several simulations add a comparison chapter, with layers, cells, stress periods, RMS of each target type, budget discrepancy and review findings side by side. The appendices list the MODFLOW Review findings and the model and report files.

DWRM4 report: title page, introduction with the hydrostratigraphic framework, and the start of the simulation chapter (Word output, rendered).
DWRM4 report: title page, introduction with the hydrostratigraphic framework, and the start of the simulation chapter (Word output, rendered).

Model code and packages

A sentence on the simulation, for example "a transient MODFLOW-USG - DISU simulation with 15 layers and 899,955 cells … 240 stress periods covering 7,305 days, from 01 January 1996 to 01 January 2016". It is followed by every name-file package with a description of what it is, the solver settings, and the flow package. When the length unit is undefined (LENUNI 0) it is taken from the model's .prj or the target coordinates, and a note says so.

Grid and layers

The grid type, rows and columns or nodes per layer, cell sizes and extent. A table gives, for each layer, its unit, cells, active cells, top and bottom elevation ranges and thickness. It is followed by a map of the top of layer 1 and a multi-panel map of layer thickness.

Time discretization

The number of stress periods and time steps, period lengths, and calendar dates. The start date comes from a Groundwater Vistas start_datetime comment, MODFLOW 6 START_DATE_TIME, or the calibration date files. More than 30 periods with few distinct settings are grouped in a short table, and every period is in stress_periods.csv. Adaptive time stepping is recognised: the text then says that MODFLOW chose the steps and how many budgets the listing file has.

Aquifer properties

Kx, Kz, Kz/Kx, Ss and Sy of the active cells:

Specific yield is summarised and mapped only over convertible cells, the only cells where it is used. Storage is left out for steady-state simulations.

Horizontal hydraulic conductivity of each DWRM4 layer, labelled with the hydrostratigraphic unit and its geometric mean, with the county boundaries.
Horizontal hydraulic conductivity of each DWRM4 layer, labelled with the hydrostratigraphic unit and its geometric mean, with the county boundaries.

Boundary conditions

For every package (WEL, RIV, DRN, GHB, CHD, RCH, EVT, …), a summary table and a paragraph give:

Each paragraph ends with a placeholder for its data sources. Figures show the cells of each package coloured by layer, the time-weighted recharge flux and ET rate, and the total specified rates through time.

Cells of each DWRM4 boundary-condition package, coloured by layer.
Cells of each DWRM4 boundary-condition package, coloured by layer.

Initial conditions and simulated heads

Where the starting heads come from (for example a head file listed as DATA), a table of starting and final heads and dry convertible cells by layer, and maps of the final heads with contours.

Water budget

DWRM4 budget terms at each of the 2,652 printed time steps (adaptive time stepping), against calendar dates.
DWRM4 budget terms at each of the 2,652 printed time steps (adaptive time stepping), against calendar dates.

Calibration

For every Groundwater Vistas residual file (<root>_<type>target_resids.csv) the report gives:

Residual maps of single layers stay in the review folder.

Model quality and appendices

The quality section counts the MODFLOW Review errors and warnings, lists the most important, and links the full review report. Appendix A lists every finding with its summary. Appendix B lists the model files with their sizes and explains the report folder.

8. Modeler placeholders

The app writes facts. Interpretation and judgement are left to the modeler, marked yellow in both Word and HTML so they are easy to find, fill in or delete:

In Word, Find with Format › Highlight jumps from one placeholder to the next.

9. Maps and shapefiles

Every grid type (DIS, DISV, DISU including quadtree) is drawn the same way. The plan view is rasterised once per layer: each pixel takes the nearest cell centre of the layer and is blank outside that cell's bounding box. Every map then reuses that lookup, so the 15-layer maps of the 900,000-cell DWRM4 model take seconds each.

The report has a multi-panel figure, one panel per layer, whose columns are chosen so the figure suits a portrait page. A full-size PNG of every layer goes to maps\<simulation>\<map>\.

Shapefiles from #Shapefiles are drawn on every map:

Simulated DWRM4 heads at the end of the calibration period (2016-01-01) with contours, by layer.
Simulated DWRM4 heads at the end of the calibration period (2016-01-01) with contours, by layer.

10. Hydrographs

When a residual file has targets observed at two or more times, there is one hydrograph per target:

Output for each target type:

DWRM4 head targets: best, median and worst target of the Ocala, Avon Park and Lower Floridan aquifers (report figure).
DWRM4 head targets: best, median and worst target of the Ocala, Avon Park and Lower Floridan aquifers (report figure).
A page of a layer's hydrograph PDF (layer 9, Avon Park Aquifer).
A page of a layer's hydrograph PDF (layer 9, Avon Park Aquifer).

11. Output folder and PDFs

Path in model_document\Content
<Model>_Model_Documentation.docxThe report in Word (title page, page numbers, numbered figures and tables, highlighted placeholders)
<Model>_Model_Documentation.htmlThe same report in HTML with a table of contents. Figures are linked, not embedded, so keep the folder together
figures\<sim>\*.png, all_figures.pdfThe report figures, and all of them in one PDF
maps\<sim>\<map>\layer_NN.pngFull-size map of every layer for thickness, kh, kv, ss, sy and heads
maps\<sim>\<map>\<map>_all_layers.pdfEvery layer of that map in one PDF
maps\<sim>\all_maps.pdfEvery layer map of every folder in one PDF
tables\<sim>\*.csvEvery table in full: stress periods, layers, conductivity, storage, boundaries, heads, budgets, budget through time
hydrographs\<sim>\<type>\<layer>\A PNG for each target and <layer>_hydrographs.pdf
hydrographs\<sim>\<type>\all_<type>_hydrographs.pdf, index.html, targets.csv
review\<sim>\The complete MODFLOW Review report, maps, calibration figures and shapefiles

The PDFs keep the PNGs: the PNG files stay where they are, for pasting into other documents. Hydrograph PDFs are vector graphics, three graphs to a portrait letter page. Map PDFs put one map on each page.

12. Example: DWRM4 transient calibration

The District-Wide Regulation Model 4 (DWRM4) of the Southwest Florida Water Management District is a public model. Its 1996–2015 transient calibration (examples\dwrm4_transient) is the largest test of the app.

ItemDWRM4 transient calibration
Code and gridMODFLOW-USG, DISU with a .gsf, Newton (SMS), LENUNI 0 (taken as feet from the .prj)
Size15 layers, 899,955 cells (30,065–79,076 per layer), cells about 2,500 ft across
Time240 monthly stress periods (1996–2015) with adaptive time stepping: 2,652 printed budgets
BoundariesRIV 20,779 cells, DRN 7,260, GHB 1,432, CHD 15,797, WEL 35,087 (layers 1–11), RCH 64,410, EVT 78,944
Calibration1,214 head targets (191,529 observations; RMS 6.45 ft, scaled RMS 3.3%) and 3 spring-flow targets
Outputsbudget file 38.5 GB, heads 2.6 GB, listing 2.4 GB
Report38 pages in Word with 26 figures and 22 tables; 1,214 hydrographs in 7 layer folders, each with its PDF, and a 407-page PDF of all of them; 76 layer maps in 6 map folders with PDFs (all_maps.pdf: 76 pages)
DWRM4 report pages: aquifer properties by unit, boundary conditions and calibration (Word output, rendered).
DWRM4 report pages: aquifer properties by unit, boundary conditions and calibration (Word output, rendered).

13. Run time and memory

DWRM4 took 19 minutes on a workstation:

Memory is set by the boundary tables held by the reviewer, about 8 GB for DWRM4. --no-maps and --no-hydrographs shorten a run when only the tables are needed.

14. Testing

python tests\run_tests.py runs two scripts with 94 checks, all passing:

The DWRM4 example is run by hand because it is large.

15. Limitations

16. Architecture and file layout

modflow_document\
  modflow_document.py        command line; graceful errors
  mfdocument\
    conceptual.py            ConceptualModel.csv
    discover.py              simulations in the folder tree
    gather.py                review, tables, maps, budgets; SimData
    canvas.py                plan-view raster maps, multi-panel figures, PNG -> PDF
    overlays.py              shapefiles: read, reproject, draw
    hydro.py                 hydrograph PNGs, layer PDFs, index.html, best/median/worst figures
    build.py                 composes the report (chapters, captions, placeholders)
    doc.py                   document model, numbering, number formatting
    write_docx.py            Word writer (python-docx)
    write_html.py            HTML writer
    run.py                   orchestration
  mfreview\                  standalone copy of the MODFLOW Review code
  vendor\flopy\              bundled FloPy fork (MODFLOW-USG Transport)
  tests\                     synthetic models and the test scripts
  examples\dwrm4_transient\  DWRM4 transient calibration (public)