PISM: derive corner longitudes with the grid's own y orientation - #60
Open
xihao001 wants to merge 1 commit into
Open
PISM: derive corner longitudes with the grid's own y orientation#60xihao001 wants to merge 1 commit into
xihao001 wants to merge 1 commit into
Conversation
cell_corners() inverse-projected the corner (x, y) with a proj4 string built from the file's mapping attributes. PROJ's south polar stereographic gives lon = lon_0 + atan2(x, y), but the antarct_cr PISM grids store lon as atan2(x, -y): their y axis runs the other way. Latitude cannot see the difference, since it depends only on sqrt(x^2 + y^2), and neither can cell_areas(), because a reflection preserves spherical area. The mismatch therefore showed up only in the corner longitudes, mirrored to 180 - lon: pyproj lon vs the file's lon median 90.000 deg pyproj lon vs (180 - file's lon) median 0.000 deg Those corners reach latest_discharge.nc via esm_tools' add_cell_bounds.py, where the iceberg generator averages them for each discharge cell's position. Every berg in a 28-cycle coupled AWIESM3-PISM run was seeded on the wrong side of Antarctica: median position error 79.9 deg, the whole Ross front placed near lon 0, and the Ross basin receiving 0 of the 300 Gt/yr it discharged. They also reach grids.nc as ismp.clo; no ISM exchange there is conservative, so the weights were unaffected, but a conservative remapping would have been silently wrong. Decided by measurement rather than assumed, so a PISM grid that does follow the PROJ convention keeps working unchanged: _y_sign transforms the centres, compares against the file's own lon, and raises if neither orientation reproduces it. A y-flip is a reflection and reverses the winding, so _is_ccw restores the counterclockwise order SCRIP expects. After the fix, corner mean vs the file's lon is 0.0000 deg median, and areas are unchanged at 62.22 km2 mean, matching the existing areas.nc. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
cell_corners() inverse-projected the corner (x, y) with a proj4 string built from the file's mapping attributes. PROJ's south polar stereographic gives lon = lon_0 + atan2(x, y), but the antarct_cr PISM grids store lon as atan2(x, -y): their y axis runs the other way.
Latitude cannot see the difference, since it depends only on sqrt(x^2 + y^2), and neither can cell_areas(), because a reflection preserves spherical area. The mismatch therefore showed up only in the corner longitudes, mirrored to 180 - lon:
pyproj lon vs the file's lon median 90.000 deg
pyproj lon vs (180 - file's lon) median 0.000 deg
Those corners reach latest_discharge.nc via esm_tools' add_cell_bounds.py, where the iceberg generator averages them for each discharge cell's position. Every berg in a 28-cycle coupled AWIESM3-PISM run was seeded on the wrong side of Antarctica: median position error 79.9 deg, the whole Ross front placed near lon 0, and the Ross basin receiving 0 of the 300 Gt/yr it discharged. They also reach grids.nc as ismp.clo; no ISM exchange there is conservative, so the weights were unaffected, but a conservative remapping would have been silently wrong.
Decided by measurement rather than assumed, so a PISM grid that does follow the PROJ convention keeps working unchanged: _y_sign transforms the centres, compares against the file's own lon, and raises if neither orientation reproduces it. A y-flip is a reflection and reverses the winding, so _is_ccw restores the counterclockwise order SCRIP expects.
After the fix, corner mean vs the file's lon is 0.0000 deg median, and areas are unchanged at 62.22 km2 mean, matching the existing areas.nc.