-
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 -
💧 @JoerivanEngelenAuthor OwnerGood 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 -
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. -
💧 @JoerivanEngelenAuthor OwnerAh 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 yourimod-python
folder and run:git pull
For more information, see our installation guide
Edited by Joeri van Engelen -
💧 @JoerivanEngelenAuthor 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:
- 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
- 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.
- For the new iMOD 3D viewer as well as QGIS, currently every layer needs to be a seperate variable. Hence the call here to
Please register or sign in to comment