ioos / cc-plugin-ugrid

Compliance Checker Plugin for UGRID: http://ugrid-conventions.github.io/ugrid-conventions
Apache License 2.0
3 stars 6 forks source link

More than one cf_role:mesh_topology should be allowed. #6

Closed drf5n closed 5 years ago

drf5n commented 7 years ago

https://github.com/ioos/cc-plugin-ugrid/blob/39fa96506c899dc0d3402d73a371a1ddcdd9a08f/cc_plugin_ugrid/checker_10.py#L36

One could have data on multiple grids within a file, each with a separate topology. In http://ugrid-conventions.github.io/ugrid-conventions/#topology the examples could all be concatentated together since all the mesh dimensions and definitions are all distinct.

I think the checker code should drop the >1 code, or add a +1 score to this case. Maybe:

    mt = ds.get_variables_by_attributes(cf_role='mesh_topology')
    if len(mt) >= 1:
        score += 1
    elif len(mt) < 1:
        m = ('Variable with attribute "cf_role:mesh_topology" required')
        messages.append(m)

or

    mt = ds.get_variables_by_attributes(cf_role='mesh_topology')
    if len(mt) == 1:
        score += 1
    elif len(mt) > 1:
        score += 1
        m = ('One variable with attribute "cf_role:mesh_topology" allowed')
        messages.append(m)
    elif len(mt) < 1:
        m = ('Variable with attribute "cf_role:mesh_topology" required')
        messages.append(m)

The capability for multiple meshes is an important feature for nesting and perhaps for subsetting.

daltonkell commented 6 years ago

Hi @drf5n, I'm going to implement this. Do you have an example of a dataset with multiple grids that I could take a look at for testing purposes? Thanks.

drf5n commented 6 years ago

Are the http://ugrid-conventions.github.io/ugrid-conventions/#topology examples available as datasets somewhere? An 'ncks -A ...' could build one.

I can't recall what I did that ran into this, but I think I was using ncml to aggregate and switch between a 0- and 1- based connectivity for some troubleshooting reason. That might be the easiest test set -- create an additional edge-node connectivity variable with an off-by-one adjustment and create the corresponding topology variable. You'd have two congruent grids in the same file, and you could point, for example, salinity at one grid, and temperature to the other grid.

daltonkell commented 5 years ago

Closing in lieu of PR #12