csiro-coasts / emsarray

xarray extension that supports EMS model formats
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Incorrect depth coordinate in UGrid dataset #138

Closed mx-moth closed 2 months ago

mx-moth commented 3 months ago

A UGrid dataset with two depth coordinates:

netcdf example {
dimensions:
    record = UNLIMITED ; // (64 currently)
    nMesh2_face = 9956 ;
    Mesh2_layers = 65 ;
    nMesh2_edge = 29937 ;
    Two = 2 ;
    nMaxMesh2_face_nodes = 8 ;
    nMesh2_face_links = 28347 ;
    Mesh2_layerfaces = 66 ;
    nMesh2_node = 19976 ;
variables:
    ...
    double Mesh2_layerfaces(Mesh2_layerfaces) ;
        Mesh2_layerfaces:units = "metre" ;
        Mesh2_layerfaces:long_name = "Z coordinate at grid layer faces" ;
        Mesh2_layerfaces:coordinate_type = "Z" ;
    double Mesh2_layers(Mesh2_layers) ;
        Mesh2_layers:units = "metre" ;
        Mesh2_layers:long_name = "Z coordinate at grid layer centre" ;
        Mesh2_layers:coordinate_type = "Z" ;
        Mesh2_layers:positive = "up" ;

The two depth variables are equally as valid as depth coordinates as far as emsarray can tell. dataset.ems.get_depth_name() will return "Mesh2_layerfaces", as the variables are processed in order and Mesh2_layerfaces happens to be first in this dataset. This causes problems when plotting transects, for example, which assumes the variable passed in for plotting is defined on the default depth coordinate.

Things to consider:

frizwi commented 3 months ago

+1 for something in the Convention.