Skip to content

Resolve /position ambiguous body names to JPL Horizons IDs - #13

Merged
dgarciabriseno merged 3 commits into
Helioviewer-Project:mainfrom
mudhoney:fix/position-body-names
Sep 3, 2026
Merged

Resolve /position ambiguous body names to JPL Horizons IDs#13
dgarciabriseno merged 3 commits into
Helioviewer-Project:mainfrom
mudhoney:fix/position-body-names

Conversation

@mudhoney

@mudhoney mudhoney commented Sep 2, 2026

Copy link
Copy Markdown

GET /position/{observatory} fails for bare major-body names (e.g. earth, sun).

Problem

JPL Horizons treats a bare major-body name as a wildcard — earthEARTH* — which matches both the geocenter (399) and the Earth-Moon barycenter (3), so Horizons raises "Multiple major-bodies match string" instead of returning a position.

Fix

Map the ambiguous major-body names to their unambiguous Horizons body-center IDs (earth → 399, sun → 10, …) before the query. Spacecraft names (e.g. SDO) and any unrecognized value pass through unchanged, so existing callers are unaffected.

Notes

  • Single-file change (app/ephemeris.py).
  • The Helioviewer 3D viewer currently pre-maps Earth-based instruments to 399, so it is not hitting this today — this makes the string names work for direct API users, the OpenAPI example, and testing.

GET /position/<body> with a bare major-body name (earth, sun, ...) failed:
JPL Horizons treats it as a wildcard (e.g. "earth" -> "EARTH*") and raises
"Multiple major-bodies match string" instead of returning a position. Map the
ambiguous names to their unambiguous Horizons body-center IDs (earth -> 399,
etc.); spacecraft names (e.g. SDO) and unknown values pass through unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YWMb14TXe3icvCsvwENZnd
@mudhoney
mudhoney force-pushed the fix/position-body-names branch from f22623c to 51f0acd Compare September 2, 2026 16:54
Comment thread app/ephemeris.py Outdated
Comment on lines +14 to +24
"sun": 10,
"mercury": 199,
"venus": 299,
"earth": 399,
"moon": 301,
"mars": 499,
"jupiter": 599,
"saturn": 699,
"uranus": 799,
"neptune": 899,
"pluto": 999,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we comment the ambiguities? Like main comment shows that there's "Earth" and "Earth-Moon Barycenter", we are selecting "Earth", each one of these needs a comment specifying the option we're selecting.

… select when selecting body in parameter, inside the comments
@dgarciabriseno
dgarciabriseno merged commit 2bc8dd4 into Helioviewer-Project:main Sep 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants