The new lazy loader assigns a time coordinate:
|
coords = {} |
|
if "t_array" in ds: |
|
coords["t"] = ds["t_array"].values |
This is not needed unless you have to use the lazy loaded dataset independently from everyone else, because the time coordinate is set up in apply_geometry:
|
if (tcoord not in updated_ds.coords) and (tcoord in updated_ds.dims): |
|
# Create the time coordinate from t_array |
|
# Slightly odd looking way to create coordinate ensures 'index variable' is |
|
# created, which using set_coords() does not (possible xarray bug? |
|
# https://github.com/pydata/xarray/issues/4417 |
|
updated_ds[tcoord] = updated_ds["t_array"] |
|
updated_ds = updated_ds.drop_vars("t_array") |
Unfortunately, the way it's been assigned links the t_array data and the t coordinate, so changing one means the other is also changed (I know, setting it to .values makes it seem like this shouldn't happen, but... Xarray). Now, xHermes unnormalises both t_array as a data variable and t as a coordinate:
https://github.com/boutproject/xhermes/blob/5588fbd0ceb2ec98344cd1752f2acf69c25055e6/xhermes/accessors.py#L42-L48
Since the assignment in the lazy loader makes them linked, t gets unnormalised twice and the time coordinate is all wrong, which causes the drift-wave test to fail: boutproject/hermes-3#546
@bendudson do you need that time coordinate assignment there or can I remove it?
The new lazy loader assigns a time coordinate:
xBOUT/xbout/lazyload.py
Lines 363 to 365 in e4f23d5
This is not needed unless you have to use the lazy loaded dataset independently from everyone else, because the time coordinate is set up in
apply_geometry:xBOUT/xbout/geometries.py
Lines 130 to 136 in e4f23d5
Unfortunately, the way it's been assigned links the
t_arraydata and thetcoordinate, so changing one means the other is also changed (I know, setting it to.valuesmakes it seem like this shouldn't happen, but... Xarray). Now, xHermes unnormalises botht_arrayas a data variable andtas a coordinate:https://github.com/boutproject/xhermes/blob/5588fbd0ceb2ec98344cd1752f2acf69c25055e6/xhermes/accessors.py#L42-L48
Since the assignment in the lazy loader makes them linked,
tgets unnormalised twice and the time coordinate is all wrong, which causes thedrift-wavetest to fail: boutproject/hermes-3#546@bendudson do you need that time coordinate assignment there or can I remove it?