Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/earthkit/data/utils/xarray/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def prepare_tensor(self, ds, dims, name):
elif num > 1 or not self.profile.dims.squeeze or d.name in self.profile.dims.ensure_dims:
tensor_dims.append(d)
tensor_coords[d.key] = vals[d.key]
if d.key in component_vals:
if component_vals and d.key in component_vals:
tensor_coords_component[d.key] = component_vals[d.key]

# check if the dims/coords are consistent with the tensors of
Expand Down
15 changes: 14 additions & 1 deletion tests/xr_engine/test_xr_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def test_xr_engine_single_field():

@pytest.mark.cache
@pytest.mark.parametrize("add", [False, True])
def test_xr_engine_add_earthkit_attrs(add):
def test_xr_engine_add_earthkit_attrs_1(add):
ds_ek = from_source("url", earthkit_remote_test_data_file("test-data/xr_engine/level/pl.grib"))
ds_ek = ds_ek[0]

Expand All @@ -558,3 +558,16 @@ def test_xr_engine_add_earthkit_attrs(add):
assert "_earthkit" in ds["t"].attrs
else:
assert "_earthkit" not in ds["t"].attrs


@pytest.mark.cache
def test_xr_engine_add_earthkit_attrs_2():
ds_ek = from_source("url", earthkit_remote_test_data_file("test-data/xr_engine/level/pl.grib"))
ds_ek = ds_ek[0]

ds = ds_ek.to_xarray(
add_earthkit_attrs=False,
)

assert ds
assert "_earthkit" not in ds["t"].attrs
Loading