Skip to content

Conversation

@mx-moth
Copy link
Contributor

@mx-moth mx-moth commented Aug 19, 2025

Dataset.data_vars doesn't contain any coordinate variables, so looking for the node_x / node_y variables in there could lead to problems.

Unfortunately, iterating over Dataset.variables will return Variable instances not DataArray instances. The best way to iterate all DataArrays - be they coordinates or data - is to iterate as so:

data_arrays = (dataset[name] for name in dataset.variables.keys())
for data_array in data_arrays:
    ...

Fixes #159

@mx-moth mx-moth requested a review from david-sh-csiro August 19, 2025 02:34
@mx-moth mx-moth self-assigned this Aug 19, 2025
Dataset.data_vars doesn't contain any coordinate variables, so looking
for the node_x / node_y variables in there could lead to problems.

Unfortunately, iterating over Dataset.variables will return Variable
instances not DataArray instances. The best way to iterate all
DataArrays - be they coordinates or data - is to iterate as so:

    data_arrays = (dataset[name] for name in dataset.variables.keys())
    for data_array in data_arrays:
        ...
@mx-moth mx-moth force-pushed the 159-ugrid-data-vars branch from 9d3eba8 to a254f86 Compare August 19, 2025 02:36
Copy link
Collaborator

@david-sh-csiro david-sh-csiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works locally and tests pass!

@mx-moth mx-moth merged commit 59ebe13 into main Aug 19, 2025
15 checks passed
@mx-moth mx-moth deleted the 159-ugrid-data-vars branch August 19, 2025 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UGRID convention doesn't detect coordinates

3 participants