{"id":13948563,"url":"https://github.com/Deltares/imod-python","last_synced_at":"2025-07-20T10:31:04.133Z","repository":{"id":211876168,"uuid":"729137006","full_name":"Deltares/imod-python","owner":"Deltares","description":"🐍🧰 Make massive MODFLOW models","archived":false,"fork":false,"pushed_at":"2025-07-13T13:07:11.000Z","size":50339,"stargazers_count":25,"open_issues_count":167,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-14T04:53:54.383Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://deltares.github.io/imod-python/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Deltares.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-08T13:57:59.000Z","updated_at":"2025-07-10T13:24:07.000Z","dependencies_parsed_at":"2023-12-30T06:11:25.324Z","dependency_job_id":"cfd697a0-3fe4-4a44-a038-ab509c6d7586","html_url":"https://github.com/Deltares/imod-python","commit_stats":{"total_commits":2091,"total_committers":33,"mean_commits":63.36363636363637,"dds":0.6446676231468197,"last_synced_commit":"6b2e1fbdb6c1925678ce1bdc33279e8a6f461d13"},"previous_names":["deltares/imod-python"],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/Deltares/imod-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fimod-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fimod-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fimod-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fimod-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Deltares","download_url":"https://codeload.github.com/Deltares/imod-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deltares%2Fimod-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266111331,"owners_count":23877979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-08T05:01:24.878Z","updated_at":"2025-07-20T10:31:04.123Z","avatar_url":"https://github.com/Deltares.png","language":"Python","readme":".. image:: https://dpcbuild.deltares.nl/app/rest/builds/buildType:id:iMOD6_IMODPython_Windows_Tests/statusIcon.svg\n   :target: https://github.com/Deltares/imod-python/commits/master/\n.. image:: https://img.shields.io/pypi/l/imod\n   :target: https://choosealicense.com/licenses/mit/\n.. image:: https://img.shields.io/conda/vn/conda-forge/imod.svg\n   :target: https://github.com/conda-forge/imod-feedstock\n.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json\n   :target: https://pixi.sh\n.. image:: https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811\u0026color=%235CA038\n   :target: https://scientific-python.org/specs/spec-0000/\n\nThe ``imod`` Python package is an open source project to make working with\nMODFLOW groundwater models in Python easier. It builds on top of popular\npackages such as `xarray`_, `pandas`_, `geopandas`_, `dask`_,  and `rasterio`_\nto provide a versatile toolset for working with large groundwater modeling\ndatasets. Some of its core functionalities are:\n\n* Preparing and modifying data from a variety of GIS, scientific, and MODFLOW\n  file formats;\n* Regridding, clipping, masking, and splitting MODFLOW 6 models;\n* Fast writing of data to MODFLOW-based models;\n* Selecting and evaluating, e.g. for time series comparison or water budgets;\n* Visualizing cross sections, time series, or 3D animations.\n\nWe currently support the following MODFLOW-based kernels:\n\n* `USGS MODFLOW 6`_, structured (DIS) and discretization by vertices (DISV)\n  grids only. Not all advanced stress packages are supported (only LAK and UZF)\n* `iMOD-WQ`_, which integrates SEAWAT (density-dependent\n  groundwater flow) and MT3DMS (multi-species reactive transport calculations)\n\nDevelopment currently focuses on supporting more MODFLOW 6 functionalities.\niMOD-WQ has been sunset and will no longer be developed.\n\nWhy ``imod``?\n=============\n\n1\\. Easily create grid-based model packages\n-------------------------------------------\n\nSeamlessly integrate your GIS rasters or meshes with MODFLOW 6, by using `xarray`_\nand `xugrid`_ arrays, for structured and unstructured grids, respectively, to\ncreate grid-based model packages. \n\n.. code-block:: python\n\n  import imod\n\n  # Open Geotiff with elevation data as xarray DataArray\n  elevation = imod.rasterio.open(\"elevation.tif\")\n\n  # Create idomain grid\n  layer_template = xr.DataArray([1, 1, 1], dims=('layer',), coords={'layer': [1, 2, 3]})\n  idomain = layer_template * xr.ones_like(elevation).astype(int)\n\n  # Compute bottom elevations of model layers\n  layer_thickness = xr.DataArray([10.0, 20.0, 10.0], dims=('layer',), coords={'layer': [1, 2, 3]})\n  bottom = elevation - layer_thickness.cumsum(dim='layer')\n\n  # Create MODFLOW 6 DIS package\n  dis_pkg = imod.mf6.StructuredDiscretization(\n      idomain=idomain, top=elevation, bottom=bottom.transpose(\"layer\", \"y\", \"x\")\n  )\n\n\n2\\. Assign wells based on data at hand, instead of the model grid\n-----------------------------------------------------------------\n\nAssign wells based on x, y coordinates and filter screen depths, instead of\nlayer, row and column:\n\n.. code-block:: python\n\n  # Specify well locations\n  x = [150_200.0, 160_800.0]\n  y = [450_300.0, 460_200.0]\n\n  # Specify well screen depths\n  screen_top = [0.0, 0.0]\n  screen_bottom = [-4.0, -10.0]\n\n  # Specify flow rate, which changes over time.\n  weltimes = pd.date_range(\"2000-01-01\", \"2000-01-03\", freq=\"2D\")\n  well_rates_period1 = [0.5, 1.0]\n  well_rates_period2 =  [2.5, 3.0]\n  rate = xr.DataArray([well_rates_period1, well_rates_period2], coords={\"time\": weltimes}, dims=(\"time\",\"index\"))\n\n  # Now construct the Well package\n  wel_pkg = imod.mf6.Well(x=x, y=y, rate=rate, screen_top=screen_top, screen_bottom=screen_bottom)\n\niMOD Python will take care of the rest and assign the wells to the correct model\nlayers upon writing the model. It will furthermore distribute well rates based\non transmissivities. To verify how wells will be assigned to MODFLOW 6 cells before\nwriting the entire simulation, you can use the following command:\n\n.. code-block:: python\n\n  # Wells have been distributed across two model layers based on screen depths.\n  wel_mf6_pkg = wel_pkg.to_mf6(idomain, top, bottom, k=1.0)\n  print(wel_mf6_pkg[\"cellid\"])\n\n  # Well rates have been distributed based on screen overlap\n  print(wel_mf6_pkg[\"rate\"])\n\n\n3\\. Utilities to assign 2D river grids to 3D model layers\n---------------------------------------------------------\n\nA common problem in groundwater modeling is to assign 2D river or drain grids to\n3D model layers. iMOD Python has utilities to do this, supporting all kinds of\ndifferent methods. Furthermore, it can help you distribute the conductance\nacross layers.\n\n`See examples here \u003chttps://deltares.github.io/imod-python/user-guide/09-topsystem.html\u003e`_\n\n4\\. Create stress periods based on times assigned to boundary conditions\n--------------------------------------------------------------------------\n\nMODFLOW 6 requires that all stress periods are defined in the time discretization\npackage. However, usually boundary conditions are defined at inconsistent\ntimes. iMOD Python can help you to create a time discretization package that is\nconsistent, based on all the unique times assigned to the boundary conditions.\n\n`See futher explanation here \u003chttps://deltares.github.io/imod-python/user-guide/07-time-discretization.html\u003e`_\n\n.. code-block:: python\n\n  # First add the packages to the simulation. NOTE: To get a functional model,\n  # more packages are needed than these two.\n  simulation = imod.mf6.Modflow6Simulation(\"example\")\n  simulation[\"gwf\"] = imod.mf6.GroundwaterFlowModel()\n  simulation[\"gwf\"][\"dis\"] = dis_pkg\n  simulation[\"gwf\"][\"wel\"] = wel_pkg\n\n  # Create a time discretization based on the times assigned to the packages.\n  # Specify the end time of the simulation as one of the additional_times\n  simulation.create_time_discretization(additional_times=[\"2000-01-07\"])\n\n  # Note that timesteps in well package are also inserted in the time\n  # discretization\n  print(simulation[\"time_discretization\"].dataset)\n\n\n5\\. Regridding MODFLOW 6 models to different grids\n--------------------------------------------------\n\nRegrid MODFLOW 6 models to different grids, even from structured to unstructured\ngrids. iMOD Python takes care of properly scaling the input parameters. You can\nalso configure scaling methods yourself for each input parameter, for example\nwhen you want to upscale drainage elevations with the minimum instead of the\naverage.\n\n.. code-block:: python\n\n  sim_regridded = simulation.regrid_like(new_unstructured_grid)\n  # Notice that discretization has converted to VerticesDiscretization (DISV)\n  print(sim_regridded[\"gwf\"][\"dis\"])\n\n\n`See further explanation here \u003chttps://deltares.github.io/imod-python/user-guide/08-regridding.html\u003e`_\n\n6\\. Clip MODFLOW 6 models to a bounding box\n-------------------------------------------\n\nTo reduce the size of your model, you can clip it to a bounding box. This is\nuseful for example when you want to create a smaller model for testing purposes.\n\n.. code-block:: python\n\n  sim_clipped = simulation.clip_box(x_min=125_000, x_max=175_000, y_min=425_000, y_max=475_000)\n\nYou can even provide states for the model, which will be set on the model boundaries of the clipped model.\n\n.. code-block:: python\n\n  # Create a grid of zeros, which will be used to\n  # set as heads at the boundaries of clipped parts.\n  head_for_boundary = xr.zeros_like(idomain, dtype=float)\n  states_for_boundary = {\"gwf\": head_for_boundary}\n\n  sim_clipped = simulation.clip_box(\n      x_min=125_000, x_max=175_000, y_min=425_000, y_max=475_000, states_for_boundary=states_for_boundary\n  )\n\n  # Notice that a Constant Head (CHD) package has been created for the clipped\n  # model.\n  print(sim_clipped[\"gwf\"])\n\n7\\. Performant writing of MODFLOW 6 models\n------------------------------------------\n\niMOD Python efficiently writes MODFLOW 6 models to disk, especially large models.\nTests we have conducted for the Dutch National Groundwater Model (LHM) show that\niMOD Python can write a model with 21.84 million cells 5 to 60 times faster (for\nrespectively 1 and 365 stress periods) than the alternative `Flopy`_ package. \nFurthermore ``imod`` can even write models that are larger than the available\nmemory, using `dask`_ arrays.\n\n*NOTE:* We don't hate Flopy, nor seek its demise. iMOD developers also\ncontribute and aid in the development of Flopy.\n\n8\\. Import your iMOD5 models\n----------------------------\n\nModels made with `iMOD5`_ can be imported into iMOD Python, provided that they are\ndefined in a projectfile.\n\n.. code-block:: python\n\n  # Open projectfile data\n  imod5_data, period_data = imod.formats.prj.open_projectfile_data(\"path/to/projectfile.prj\")\n\n  # Specify times for the simulation, this will be used to resample iMOD5 wells\n  # to and to set the time discretization\n  times = [np.datetime64(\"2000-01-01\"), np.datetime64(\"2000-01-02\"), np.datetime64(\"2000-01-03\")]\n  \n  # Create a simulation object\n  simulation = imod.mf6.Modflow6Simulation.from_imod5_data(imod5_data, period_data, times)\n\n`See this page for a full list of supported iMO5 functionalities. \u003chttps://deltares.github.io/imod-python/faq/imod5_backwards_compatibility.html\u003e`_\n\nWhy not ``imod``?\n=================\n\n1\\. You want to make a small, synthetic model\n---------------------------------------------\n\nIf you are not interested in deriving models from spatial data, but just want to\nallocate boundary conditions based on layer, row, column numbers, or create a\nmodel of a 2D cross-section: You are better off using `Flopy`_.\n\n2\\. Not all MODFLOW 6 features are supported\n--------------------------------------------\n\nCurrently, we don't support the following MODFLOW 6 features:\n\n- timeseries files\n- DISU package\n- Groundwater Energy Model (GWE)\n- Streamflow routing (SFR) package (`in development \u003chttps://github.com/Deltares/imod-python/pull/1497\u003e`_)\n- Ghost Node Correction (GNC) package\n- Multi-aquifer well (MAW) package\n- Water mover (MVR) package\n- Particle tracking (PRT)\n\nMost of these features can be implemented with some effort, but we have not\nprioritized them yet. The exceptions are the DISU package and the timeseries\nfiles, which would require significant work to our backend. As a result, we will\nlikely not support these two features in the foreseeable future. If you need any of the\nother features, feel free to open an issue on our GitHub page.\n\nAdditional links\n================\n\nDocumentation: https://deltares.github.io/imod-python\n\nSource code: https://github.com/Deltares/imod-python\n\nIssues: https://github.com/Deltares/imod-python/issues\n\n.. _Deltares: https://www.deltares.nl\n.. _dask: https://dask.org/\n.. _xarray: http://xarray.pydata.org/\n.. _xugrid: https://deltares.github.io/xugrid/\n.. _pandas: http://pandas.pydata.org/\n.. _rasterio: https://rasterio.readthedocs.io/en/latest/\n.. _geopandas: http://geopandas.org/\n.. _netCDF: https://www.unidata.ucar.edu/software/netcdf/\n.. _USGS MODFLOW 6: https://www.usgs.gov/software/modflow-6-usgs-modular-hydrologic-model\n.. _iMOD-WQ: https://oss.deltares.nl/web/imod\n.. _iMOD5: https://oss.deltares.nl/web/imod\n.. _Flopy: https://flopy.readthedocs.io/en/latest/\n","funding_links":[],"categories":["Hydrosphere"],"sub_categories":["Freshwater and Hydrology"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDeltares%2Fimod-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDeltares%2Fimod-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDeltares%2Fimod-python/lists"}