Repository navigation
Use the real mesh geometry for plain Elmer mesh grids - #193
Merged
Merged
Conversation
BenjaminRodenberg
force-pushed
the
elmer-mesh-real-coordinates
branch
from
October 20, 2026 15:19
6239bab to
e3d753c
Compare
This was referenced Oct 20, 2026
BenjaminRodenberg
force-pushed
the
elmer-mesh-real-coordinates
branch
2 times, most recently
from
October 26, 2026 15:38
3eaa683 to
e053416
Compare
Plain --elmer-mesh grids (no DEM) put every column at lat 75, lon 320 (75 N 40 W), placeholder values from the initial implementation. Use the mesh cell centers instead, as the --netcdf-dem-mesh branch already did; both branches now share _set_cell_center_coordinates. Longitudes are now -180..180 instead of 0..360. Both give the same hour angle modulo 360 deg, so cos/sin(h) are unchanged; only the shading azimuth's h < 0 test differs, and Elmer grids cannot shade. On greenland_mesh_v0 (default 1-day January run) Tsurf changes by up to 0.06 K. The CI pseudo-coupling step is bit-identical because its surface energy balance comes from (fake) ICON-Land. Assisted-by: Claude Code:claude-opus-5-5
Plain --elmer-mesh grids (no DEM file) filled grid["z"] with random values between 0 and 100 m. Use the mean of the node z coordinates of each cell instead, which is where reader.py stores DEM elevations and what README.md describes for this input. A mesh without elevation data now gives 0 m everywhere. Assisted-by: Claude Code:claude-opus-5-5
Plain --elmer-mesh grids treated every column as flat. Use the plane through the nodes of each triangle instead. Its gradient in projected x/y is rotated to local east/north with the meridian convergence of the mesh CRS and scaled by the projection scale factor, since slope_x/slope_y are east/north gradients and EPSG:3413/3031 x/y are not. Mesh now keeps its CRS for this. slope_beta/slope_gamma use the same formulas as the MATLAB branch (arctan of the slope, slope_azimuth). A mesh without elevation data, such as greenland_mesh_v0 in CI, still gives exactly zero slopes. With elevation data, --couple-to-elmer-ice now aborts at startup in ElmerIce.validate_grid. Assisted-by: Claude Code:claude-opus-5-5
Elmer mesh grids now carry real slopes, which ElmerIce rejected since they cannot follow the surface elevation it sends back (no dhdx/dhdy yet). That turned every Elmer/Ice run on a mesh with elevation data into an AssertionError. Zero the slopes with a warning instead, which is what these runs used before the mesh slopes were introduced. Shading and 2-D elevation fields are still rejected. validate_grid is renamed to prepare_grid since it now modifies the grid. Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
BenjaminRodenberg
force-pushed
the
elmer-mesh-real-coordinates
branch
from
October 26, 2026 16:26
e053416 to
9f82868
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Grids built from
--elmer-meshalone (no--netcdf-dem-mesh/--netcdf-dem-mesh-unstructured) filled the column geometry with placeholder values from the initial implementation: every column at 75 N 40 W (lon 320), a random elevation between 0 and 100 m, and flat surfaces. This PR replaces them with the geometry of the mesh, one commit each:_set_cell_center_coordinates). Longitudes are now -180..180, as for all other grid types. 320 and -40 give the same hour angle modulo 360 deg; only the shading azimuth testsh < 0, and Elmer grids cannot shade.reader.pywrites DEM elevations. A mesh without elevation data gives 0 m.slope_beta/slope_gammause the formulas of the MATLAB branch, moved unchanged into_slope_angles.Where results change, and where they do not
Measured with
--dump-reference --random-seed 0andtools/compare_snapshots.py, default run (1 Jan 1979, 8 x 3 h), per commit against its parent.--matlab-mesh,--netcdf-mesh--elmer-mesh+--netcdf-dem-mesh(-unstructured)--elmer-meshalone, mesh without elevation (greenland_mesh_v0)reader.py)greenland_mesh_v0,--couple-to-icon-atmo --couple-to-icon-land --couple-to-elmer-ice --fake-coupling)Notes:
ebm_*diagnostics there. A standalone--elmer-meshrun on the same mesh does change.--elmer-meshruns now carries the reallon/latandz.Behaviour with Elmer/Ice coupling
When coupled to Elmer/Ice (
--couple-to-elmer-ice), the columns stay flat and a warning is logged, since the slopes would not follow the surface elevation received from Elmer/Ice (it does not senddhdx/dhdyyet). Such runs therefore get the same flat columns as before.ElmerIce.validate_gridis renamed toElmerIce.prepare_gridbecause it now adapts the grid; shading and 2-D elevation fields are still rejected.Not covered
--netcdf-dem-mesh(-unstructured)branches still use flat slopes; their elevations are interpolated to cell centers only, so there are no node elevations to fit a plane through.slope_gammahas the wrong sign whereslope_y == 0exactly; this is pre-existing, moved unchanged, and fixed separately.Generated with Claude Code