Skip to main content

Work with iMOD MODFLOW models

Project description

Work with iMOD MODFLOW models in Python.

Documentation: https://deltares.gitlab.io/imod-python/

Source code: https://gitlab.com/deltares/imod-python

Getting started

In absence of actual documentation, here are some of the functions:

import imod

df = imod.ipf.load('wells.ipf')
imod.ipf.save('wells-out.ipf', df)

# get all calculated heads in a xarray DataArray
# with dimensions time, layer, y, x
da = imod.idf.load('path/to/results/head_*.idf')

Notes

  • The iMOD 4.1 release will crash on loading NaN nodata values. In earlier and later releases this is not an issue.

Implementation of imod.idf.load

  1. Do a glob search on all files matching the input path, e.g. head_*.idf

  2. For each IDF:

  3. Gather all metadata from filename and IDF header

  4. Load IDF array with np.memmap in r+ mode.

  5. Set nodata to np.nan (changes input file, done to be compatible with xarray)

  6. Load np.memmap into a dask.array

  7. Combine metadata and dask.array into an xarray.DataArray

  8. Combine the indivual DataArrays into one, adding time and layer dimensions as necessary.

With the current design, I’m not sure what the added benefit of using dask arrays is, and whether it should be removed. One possible benefit is that it is only possible to write to the DataArray after calling .load() on it first, which in this case still doesn’t load it into memory.

We can also still explore using the c copy on write mode of numpy.memmap.

Comment by xarray author Stephan Hoyer about using np.memmap on GitHub:

If it’s already on disk in a memory-mappable format, it’s very hard to imagine beating np.memmap.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imod-0.4.1.tar.gz (43.3 kB view hashes)

Uploaded Source

Built Distribution

imod-0.4.1-py3-none-any.whl (31.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page