Conversation
src/gmt_map.c
Outdated
| } else if (xlat < -90.0) { | ||
| xlat = -180.0 - xlat; | ||
| xlon += 180.0; | ||
| if (xlon > 180.0) xlon -= 360.0; |
There was a problem hiding this comment.
This line is not correctly indented.
|
I revised the code style. |
|
We have test failures |
|
Can it be that originals were wrong? |
For |
|
They are both wrong. |
|
I checked the earliest version of the |
|
Also, the issue 1155 referred to in the comments and commit is this one from an earlier issue tracker: |
Thanks for this link. I couldn't find the issue. |
|
@joa-quim Do we only need to fix the two failing pssolar tests, or is there anything else failing in this PR? |
|
Yes, the two failing PS should be replaced by the new ones obtained when this PR is merged. |





This fixes #8936.
The code was written by Claude after some attemps. This is its explanation:
Problem
On the vernal and autumnal equinoxes (~March 20 and ~September 22), all
four solar terminator lines drawn by
gmt solar -Tdcnaoverlapcompletely instead of appearing as distinct concentric bands.
Root cause
In
gmt_get_smallcircle(src/gmt_map.c), the generating vectorXis computed by finding a starting point
xlatalong the meridianthrough the pole,
colatdegrees away:All four terminator types use
colat > 90°(90.833, 96, 102, 108).On the equinoxes,
plat ≈ −0.04°(solar declination near zero), so:gmt_geo_to_cartreceives an out-of-range latitude and produces thesame degenerate vector
Xfor all four terminators regardless of theirdifferent
colatvalues. All four small circles end up identical.Confirmed with
-Vd: theAdded extra pointcoordinates werebyte-for-byte identical for
-Td(90.833°) and-Ta(108°) beforethe fix.
Fix
When
xlatexceeds ±90°, wrap it around the pole by reflecting thelatitude and shifting the longitude by 180°. This places
Xat thegeometrically equivalent point on the correct side of the pole, at a
valid latitude, preserving the exact angular distance
colatfromP.After the fix,
-Vdshows four distinctAdded extra pointcoordinates,one per terminator, confirming each gets a unique generating vector:
-Td−180/−89.107and180/+89.193-Tc−180/−83.941and180/+84.027-Tn−180/−77.941and180/+78.027-Ta−180/−71.941and180/+72.027Files changed
src/gmt_map.c—gmt_get_smallcircle: added pole-wrap guard andxlonvariable; updatedgmt_geo_to_cartcall to usexloninsteadof
plon.