The current error message when merging data-arrays in https://github.com/mllam/mllam-data-prep/blob/main/mllam_data_prep/create_dataset.py#L114 could be more helpful by actually giving the sizes (coordinate names with sizes) of the data arrays being merged.
This could be achieved by adding a funciton like:
def print_dataarray_shapes_by_target(dataarrays_by_target: Mapping[str, list]) -> None:
for target, dataarrays in dataarrays_by_target.items():
print(f"{target}:")
for i, da in enumerate(dataarrays, start=1):
dims_str = ", ".join(f"{dim}={da.sizes[dim]}" for dim in da.dims)
print(f" {i}. {da.name}: {dims_str}")
And calling this to construct the following addition to the exception text:
$> print_dataarray_shapes_by_target(dataarrays_by_target)
state:
1. pres_seasurface: state_feature=7, time=19, grid_index=3061036
2. z: time=19, state_feature=48, grid_index=3061036
static:
1. lsm: static_feature=2, grid_index=3061036
forcing:
1. toa_radiation: forcing_feature=5, time=37, grid_index=3061036
Here it is for example clear that the forcing data-array is 37 time coordinate values where as state only has 19
The current error message when merging data-arrays in https://github.com/mllam/mllam-data-prep/blob/main/mllam_data_prep/create_dataset.py#L114 could be more helpful by actually giving the sizes (coordinate names with sizes) of the data arrays being merged.
This could be achieved by adding a funciton like:
And calling this to construct the following addition to the exception text:
Here it is for example clear that the
forcingdata-array is37time coordinate values where asstateonly has19