Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

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.

Filename, size & hash SHA256 hash help File type Python version Upload date
imod-0.4.0-py3-none-any.whl (27.9 kB) Copy SHA256 hash SHA256 Wheel py3 Oct 4, 2018
imod-0.4.0.tar.gz (40.4 kB) Copy SHA256 hash SHA256 Source None Oct 4, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page