Skip to content

Commit

Permalink
Fix resample test: xr.resample will reorder dims
Browse files Browse the repository at this point in the history
  • Loading branch information
BSchilperoort committed Apr 13, 2024
1 parent 14be4b9 commit 79b2346
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/dtscalibration/io/apsensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def read_apsensing_files(
)

ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
ds = ds.transpose("x", "time", ...)
return ds


Expand Down
1 change: 0 additions & 1 deletion src/dtscalibration/io/sensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def read_sensornet_files(
)

ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
ds = ds.transpose("x", "time", ...)
return ds


Expand Down
1 change: 0 additions & 1 deletion src/dtscalibration/io/sensortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def read_sensortran_files(
)

ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
ds = ds.transpose("x", "time", ...)
return ds


Expand Down
1 change: 0 additions & 1 deletion src/dtscalibration/io/silixa.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def read_silixa_files(
)

ds = xr.Dataset(data_vars=data_vars, coords=coords, attrs=attrs, **kwargs)
ds = ds.transpose("x", "time", ...)
return ds


Expand Down
16 changes: 9 additions & 7 deletions tests/test_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,17 @@ def test_resample_datastore():
ds = read_silixa_files(directory=filepath, timezone_netcdf="UTC", file_ext="*.xml")
assert ds.time.size == 3

ds_resampled = Dataset(ds.resample(time="47S").mean())
ds_resampled = ds.resample(time="47s").mean()

assert ds_resampled.time.size == 2
assert ds_resampled.st.dims == ("x", "time"), (
"The dimension have to "
"be manually transposed "
"after resampling. To "
"guarantee the order"
)

## No control over dim order from resample with accessor
# assert ds_resampled.st.dims == ("x", "time"), (
# "The dimension have to "
# "be manually transposed "
# "after resampling. To "
# "guarantee the order"
# )


def test_timeseries_keys():
Expand Down

0 comments on commit 79b2346

Please sign in to comment.