csiro-hydroinformatics / efts-io

Ensemble forecast time series I/O
BSD 3-Clause Clear License
0 stars 0 forks source link

bug: cannot re-index or align objects with conflicting indexes found for the following dimensions: 'station' (2 conflicting indexes) #5

Open jmp75 opened 2 weeks ago

jmp75 commented 2 weeks ago

Description of the bug

Creating an empty EFTS xarray, then trying to assign a new dataarray to the dataset.

Exception has occurred: ValueError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
cannot re-index or align objects with conflicting indexes found for the following dimensions: 'station' (2 conflicting indexes)
Conflicting indexes may occur when
- they relate to different sets of coordinate and/or dimension names
- they don't have the same type
- they may be used to reindex data along common dimensions

Occurs at commit aa91106f4a4b46ffc666a989e2b6085895d0098e when trying to run round-tripping unit test.

I was trying to set multiple indexes (coordinates) for the 'station' dimension, to accomodate the selection of stations by string or by integers, the "old way". I thought I had found the magic via

    # Credits to the work reported in https://github.com/pydata/xarray/issues/2028#issuecomment-1265252754
    d = d.set_xindex(STATION_ID_VARNAME)

However, this makes it difficult without a serious workaround to create new data variables then: https://github.com/pydata/xarray/issues/7695