Skip to content
  • Frans Roelofsen @fransroelofsen ·
    Developer

    What if one of the IDF's has different dimensions, e.g. smaller cell size? Be aware, regridding is necessary for a correct display of the UGRID data in the (iMOD6) viewer

    Edited by Frans Roelofsen
  • Author Owner

    Good point, I assumed the existing iMODFLOW model had all matching grids (as imod-python writes them), but this is not the case for many existing models.

    In that case, you can regrid as follows:

    ...
    #%% Open data
    top = imod.idf.open(top_idf)
    bot = imod.idf.open(bot_idf)
    khv = imod.idf.open(khv_idf)
    
    # Regrid, I assume khv has a different grid, and the grid of "top" is required.
    # Choose a "like" grid to regrid to, this is a dummy DataArray to which "source" is regridded.
    like = top
    #Regrid, different methods can be chosen, you can even supply your own method, see docs. We here choose "mean".
    khv_regridded = imod.prepare.Regridder(method="mean").regrid(khv, like)
    
    # Continue rest
    ds = xr.merge(layer_coord_to_var(da) for da in [top, bot, khv_regridded])
    ...

    For more information, see our documentation on regridding.

    Edited by Joeri van Engelen
  • Frans Roelofsen @fransroelofsen ·
    Developer

    If I use the command given above:

    # Convert to URGRID ds_ugrid = imod.util.to_ugrid2d(ds)

    ... there is an error message: AttributeError: module 'imod.util' has no attribute 'to_ugrid2d'

    --> Do I have the wrong iMOD version or is the iMOD.util not yet released?

    I updated iMOD and my version (according to print(imod.__version__)) is 0.10.1.

  • Author Owner

    Ah yes, we probably did not release this functionality yet into PyPI (pip install) or conda-forge (conda install).

    As we are adding quite some functionality currently, my advice is to do a "development install". This requires git, which you can download here.

    rem you might want to activate you conda environment, e.g. "imod"
    rem conda activate imod
    cd <path/to/folder/>
    git clone https://gitlab.com/deltares/imod/imod-python.git
    cd imod-python
    pip install -e .

    Whenever you want/need to update imod-python to the last version, cd into your imod-python folder and run:

    git pull

    For more information, see our installation guide

    Edited by Joeri van Engelen
  • Author Owner

    @betsyromero I see you created an example script for UGRID here, similar to this snippet, in the documentation, very good.

    Perhaps it is good to make the following remarks there:

    1. For the new iMOD 3D viewer as well as QGIS, currently every layer needs to be a seperate variable. Hence the call here to layer_coord_to_var
    2. Due to a bug in MDAL, we have to encode the times as np.float64. This is of course only for when people convert data with a time coordinate to UGRID, like transient model output.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment