Metadata-Version: 1.2
Name: imod
Version: 0.1
Summary: Work with iMOD MODFLOW models
Home-page: https://gitlab.com/visr/imod-python
Author: Martijn Visser
Author-email: mgvisser@gmail.com
License: MIT
Description-Content-Type: UNKNOWN
Description: Work with `iMOD <http://oss.deltares.nl/web/imod>`__ MODFLOW models in

        Python.

        

        Getting started

        ---------------

        

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

        

        .. code:: python

        

            import imod

        

            df = imod.io.readipf('wells.ipf')

            imod.io.writeipf(df, 'wells-out.ipf')

        

            # get all calculated heads in a xarray DataArray

            # with dimensions time, layer, y, x

            da = imod.io.loadarray('path/to/results/head_*.idf')

        

            # The aim is to couple iMOD data files and xarray more tightly

            # such that we can lazily import an entire model into an xarray

            # Dataset, do calculations/aggregations/modifications on the

            # Dataset, and write everything back to the iMOD data files.

        

        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 ``loadarray``

        -------------------------------

        

        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 ``DataArray``\ s 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 <https://github.com/dask/dask/issues/1562#issuecomment-248681863>`__:

        

            If it’s already on disk in a memory-mappable format, it’s very hard

            to imagine beating np.memmap.

        
Keywords: imod modflow groundwater modeling
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3
