Skip to content

Only give lat/lon standard names to spherical meshes - #772

Merged
xylar merged 1 commit into
MPAS-Dev:masterfrom
xylar:fix-planar-lat-lon-standard-names
Oct 23, 2026
Merged

xylar merged 1 commit into
MPAS-Dev:masterfrom
xylar:fix-planar-lat-lon-standard-names

Conversation

@xylar

@xylar xylar commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Since 2.2.0, planar meshes label latCell, lonCell, latEdge, lonEdge, latVertex and lonVertex with standard_name: latitude or longitude. On a planar mesh these are all zero and are not geographic coordinates, so CF-aware tools shouldn't treat them as such.

This PR:

  • moves these standard names out of MESH_VAR_ATTRS into a new SPHERE_VAR_ATTRS in mpas_tools.mesh.attrs, and adds get_mesh_var_attrs(on_a_sphere) to combine the two
  • has add_mesh_attrs() add them only when on_a_sphere is YES. On planar meshes it also removes these standard names if present, so that planar meshes made with 2.2.0 get cleaned up.
  • has MpasMeshConverter.x and MpasCellCuller.x write them only for spherical meshes
  • updates the CF tests to check that planar meshes have no lat/lon standard names and spherical meshes do

Fixes #770


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

🤖 Generated with Claude Code

The latitude and longitude of planar meshes are all zero and are not
geographic coordinates, so CF-aware tools should not treat them as
such.  Move the latitude and longitude standard names out of
MESH_VAR_ATTRS into SPHERE_VAR_ATTRS, add get_mesh_var_attrs() to
combine them, and have add_mesh_attrs() only add them when on_a_sphere
is YES.  On a planar mesh, add_mesh_attrs() also removes these standard
names, which meshes made with 2.2.0 have.  MpasMeshConverter.x and
MpasCellCuller.x likewise only write them for spherical meshes.

Update the CF tests to check that planar meshes have no lat/lon
standard names and spherical meshes do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@xylar

xylar commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator Author

Testing

Because this PR changes MpasMeshConverter.x and MpasCellCuller.x, I built the package locally with rattler-build (ci/linux_64_python3.14.____cpython.yaml) and installed it into the pixi environment from conda_package/pixi.toml.

With that build, the reproducer from #770, extended through cull() and convert() and to a spherical mesh, gives:

Mesh Step on_a_sphere lat/lon standard_name
planar hex (4x4, nonperiodic) make_planar_hex_mesh() NO none
cull() NO none
convert() NO none
mesh.QU.1920km.151026.nc convert() YES latitude / longitude
cull() YES latitude / longitude

From the repo root, pytest conda_package/tests gives 78 passed and 2 failed. The failures are test_pyproject_matches_recipe and test_pyproject_has_no_extra_dependencies in test_dependencies.py. They flag dask in pyproject.toml vs. dask-core in the recipe, and neither file is changed here. The updated tests in test_cf_attrs.py check that planar meshes have no lat/lon standard names after cull() and convert(), that the spherical mesh keeps them after convert(), and that add_mesh_attrs() removes them from a planar mesh and adds them to a spherical one. All of these pass.

pre-commit passes.


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

@xylar
xylar merged commit 44daa15 into MPAS-Dev:master Oct 23, 2026
5 checks passed
@xylar
xylar deleted the fix-planar-lat-lon-standard-names branch October 23, 2026 18:44
@xylar xylar mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planar meshes get latitude and longitude standard names

1 participant