Deltares / Deltares/imod-python
`MeteoMapping.grid_mapping` logic by xugrid CentroidLocatorRegridder
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 41
- Forks
- 12
- Avg merge
- 21h 8m
- Merged PRs (30d)
- 1
Description
This function:
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in imod/msw/meteo_mapping.py at the grid_mapping function and compare its current mapping logic with xugrid.CentroidLocatorRegridder. Review weights_as_dataframe(), target_index, and numpy.unravel_index for converting the one-dimensional face indices into row and column arrays. Done means the mapping uses the regridder approach, supports the stated subunit repetition, and preserves the expected mapping shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100