You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Issue**: Grid-based ("g") and array-based ("a") package variants (Chdg, Welg, Drng, Rcha) were missing `converter=Converter(structure_array, ...)` on their period block array fields. Without converters, xattree validates dimension counts before reshape logic runs, causing errors when passing structured arrays.
549
+
550
+
**Solution**: Added converters to all grid-based and array-based package fields:
551
+
-`Chdg.head`: Added converter for automatic reshaping
552
+
-`Welg.q`: Added converter for automatic reshaping
553
+
-`Drng.elev` and `Drng.cond`: Added converters for automatic reshaping
554
+
-`Rcha.recharge`: Added converter for automatic reshaping
**Issue**: Array-based packages use `ncpl` ("number of cells per layer") dimension for 2D per-layer data. The reshape detection only handled `nodes` (3D full grids) but not `ncpl` (2D per-layer), causing errors like:
560
+
```
561
+
ValueError: Shape mismatch: (3, 15, 15) vs (3, 225)
562
+
```
563
+
564
+
**Solution**: Extended `_detect_grid_reshape` to handle `ncpl` dimension:
565
+
```python
566
+
# Handle 'ncpl' dimension (cells per layer, 2D per-layer arrays)
567
+
if"ncpl"in expected_dims and has_structured_2d:
568
+
# Case: (nrow, ncol) → (ncpl,)
569
+
# Case: (nper, nrow, ncol) → (nper, ncpl)
570
+
```
571
+
572
+
This allows automatic reshaping for array-based packages like Rcha.
The stricter validation in the new converter caught the StructuredGrid bug that had existed undetected. While this temporarily broke tests, it exposed a real issue that would have caused problems downstream. This demonstrates the value of proper input validation.
0 commit comments