fix: handle MPC comet data with unparseable orbital elements#401
Open
mrosseel wants to merge 1 commit intobrickbots:mainfrom
Open
fix: handle MPC comet data with unparseable orbital elements#401mrosseel wants to merge 1 commit intobrickbots:mainfrom
mrosseel wants to merge 1 commit intobrickbots:mainfrom
Conversation
Skyfield's load_comets_dataframe() can return string dtypes for numeric columns when the MPC data file contains rows it can't parse (e.g. the MPEC 2026-F34 batch of 27 historical comets with malformed fields). Even a few bad rows cause pandas to fall back to dtype=object for the entire perihelion_year column, which then crashes comet_orbit() for *every* comet with a numpy UFuncNoLoopError. Fix: force numeric coercion with pd.to_numeric() after loading, drop rows with unparseable essential fields, and add a try/except safety net around individual comet processing. Co-Authored-By: Claude Opus 4.6 <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.
Summary
load_comets_dataframe()can't parse correctly (e.g. MPEC 2026-F34 added 27 historical comets with malformed fixed-width fields). When even a single row has an unparseableperihelion_year, pandas falls back todtype=objectfor the entire column, turning every year value into a string like'2028'instead of an integer. Skyfield'scomet_orbit()then crashes on every comet withnumpy UFuncNoLoopError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U4'), dtype('float64')).pd.to_numeric(errors="coerce")on all orbital element columns after loading to ensure proper numeric dtypes regardless of bad rowsTest plan
🤖 Generated with Claude Code