Deltares / Deltares/imod-python
imod.idf.open gives a somewhat confusing error when inferred dimensions and coordinates do not align
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 41
- Forks
- 12
- Avg merge
- 21h 8m
- Merged PRs (30d)
- 1
Description
Taking this LHM inspired example:
IDF files:
budget_1_20000101_l1.idf
budget_1_20000102_l1.idf
budget_1_20000103_l1.idf
budget_2_20000101_l1.idf
budget_2_20000102_l1.idf
budget_2_20000103_l1.idf
budget_2_20000101_l2.idf
budget_2_20000102_l2.idf
budget_2_20000103_l2.idf
Opening with riv = imod.idf.open(path_riv, pattern="{name}_{sys}_{time}_l{layer}")
Results in an error that is not maximally clear:
ValueError: conflicting sizes for dimension 'layer': length 1 on the data but length 2 on coordinate 'layer'
This makes you think there's something wrong with the layer, but it's really the created sys dimension that is probably not desirable.
This is an xarray error, raised here: https://github.com/Deltares/imod-python/blob/8b266c431486436cb2d018e3c23c1f59b4e89b2f/imod/formats/array_io/reading.py#L322
What happens is that sys1 has data for only one layer, but sys2 has data for two layers.
It's a bit hard to debug in this case, because the error is relatively short.
It might be clearer if it stated: Attempted to create DataArray with shape (...), dimensions (...) and coordinates (...) or something like that.
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/formats/array_io/reading.py around line 322 and reproduce the listed imod.idf.open call with the sample IDF layout. Update the resulting error so it identifies the mismatched inferred dimensions and coordinates, especially sys and layer, then verify the example reports the cause clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100