Skip to content

Mesh files are not CF compliant #757

Description

@xylar

The mesh files MPAS-Tools writes fail a CF checker: MpasMeshConverter.x and MpasCellCuller.x set Conventions = "MPAS" with no CF entry, which cfchecks reports as an error, and none of the mesh creation tools write units on the mesh variables. Polaris is working around both in E3SM-Project/polaris#784 (for E3SM-Project/polaris#774) by rewriting the attribute and filling in the metadata from its own table before it writes a mesh, but the metadata belongs with the tools that create the variables.

What happens

Running cfchecks (from the cfchecker package, version 4.1.0) on a mesh from make_planar_hex_mesh() passed through cull() and convert():

ERROR: (2.6.1): This netCDF file does not appear to contain CF Convention data.

because the file carries Conventions = "MPAS". Setting it to CF-1.8 MPAS brings the file to zero errors. jigsaw_to_netcdf() output passed through MpasMeshConverter.x has the same attribute.

With that fixed, the checker still warns about every variable: make_planar_hex_mesh() writes neither units nor long_name, and the C++ converter and culler write long_name but no units (for example xCell, areaCell, dcEdge, angleEdge, weightsOnEdge, meshDensity).

What was expected

  • Conventions = "CF-1.8 MPAS" from MpasMeshConverter.x and MpasCellCuller.x (the attribute lists every convention a file follows; CF only needs one entry to be CF-x.y). Any CF entry already on the input should be kept.
  • units and long_name on every mesh variable from make_planar_hex_mesh(), jigsaw_to_netcdf(), the converter and the culler, in the plain udunits form CF uses (m, m2, radians, 1 for dimensionless; index and connectivity variables have no units).

Polaris's table of the attributes is polaris/mesh/attrs.yaml from E3SM-Project/polaris#784, and could be the starting point for the same in mpas_tools.

How to reproduce

With the Polaris (or any mpas_tools + cfchecker) environment on PATH:

from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.io import write_netcdf

ds = make_planar_hex_mesh(nx=10, ny=10, dc=1e3, nonperiodic_x=False, nonperiodic_y=True)
write_netcdf(ds, 'base_mesh.nc')
write_netcdf(convert(cull(ds)), 'culled_mesh.nc')

then cfchecks base_mesh.nc (warnings only) and cfchecks culled_mesh.nc (the error above).


Posted by Claude Code on @xylar's behalf. The testing, analysis and wording above are AI-authored; please check them accordingly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions