Description
This function:
imod-python/imod/msw/meteo_mapping.py
Line 38 in 86bf0ca
contains logic to map the SVAT to the coarse meteo grid files. This logic is the same as the one that can be found in the xugrid CentroidLocatorRegridder:
https://deltares.github.io/xugrid/api/xugrid.CentroidLocatorRegridder.html
The latter one has the advantage of working on unstructured grids as well, and should have more unit tests and the like as well. I recommend replacing the grid_mapping
logic by roughly the following:
regridder = xu.CentroidLocatorRegridder(source=svat, target=meteo_grid)
weights = regridder.weights_as_dataframe()
index = weights["target_index"]
Note that index is an a 1D array for indexing along the faces. You can generate 2D arrays relatively easily, using numpy unravel_index: https://numpy.org/doc/stable/reference/generated/numpy.unravel_index.html
row, column = np.unravel_index(index, shape=svat.shape)
Then, repeat for the number of subunits, etc.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status