unifhy-org / unifhy

A Unified Framework for Hydrology
https://unifhy-org.github.io/unifhy
BSD 3-Clause "New" or "Revised" License
11 stars 5 forks source link

fix bug due to ambiguity in using construct method when both dimension and auxiliary coordinates exist (e.g. in BNG) #51

Closed ThibHlln closed 2 years ago

ThibHlln commented 2 years ago

When running Component using the BritishNationalGrid, Y and X axes have both dimension coordinates (i.e. projection_y|x_coordinate) and auxiliary coordinates (i.e. latitude|longitude). In several places in cm4twc the cf.Field method construct is used to get access to dimension coordinates, but this fails with:

ValueError: Field.construct() can't return 2 constructs

This is because Y|X axes feature both a dimension and a auxiliary coordinate.

This can be fixed by explicitly getting access to the dimension coordinates through the cf.Field method dimension_coordinate (or its alias dim).