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
4 changes: 2 additions & 2 deletions src/emsarray/conventions/shoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def topology(self) -> CFGrid2DTopology:
latitude = next(
name for name, variable in self.dataset.variables.items()
if variable.dims == self._dimensions
and variable.attrs["standard_name"] == "latitude"
and variable.attrs.get("standard_name", None) == "latitude"
)
longitude = next(
name for name, variable in self.dataset.variables.items()
if variable.dims == self._dimensions
and variable.attrs["standard_name"] == "longitude"
and variable.attrs.get("standard_name", None) == "longitude"
)
except StopIteration:
raise ValueError("Could not find the necessary coordinate variables")
Expand Down
7 changes: 7 additions & 0 deletions tests/conventions/test_cfgrid2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ def test_values() -> None:
assert numpy.allclose(values, eta.values.ravel(), equal_nan=True)


def test_topology_with_missing_variable_standard_name() -> None:
# Basic test showing no error when variable has no standard name
dataset = make_dataset(j_size=10, i_size=20, corner_size=5, time_size=3)
del dataset['botz'].attrs['standard_name']
dataset.ems.topology


@pytest.mark.matplotlib
def test_plot_on_figure() -> None:
# Not much to test here, mostly that it doesn't throw an error
Expand Down
Loading