Skip to content

⚡ Bolt: Lazy NGC catalog loading#383

Merged
pozar87 merged 3 commits intomasterfrom
bolt/lazy-ngc-catalog-17275612905742126655
Mar 7, 2026
Merged

⚡ Bolt: Lazy NGC catalog loading#383
pozar87 merged 3 commits intomasterfrom
bolt/lazy-ngc-catalog-17275612905742126655

Conversation

@pozar87
Copy link
Owner

@pozar87 pozar87 commented Mar 6, 2026

💡 What:

Implemented a lazy loading strategy for the NGC astronomical catalog, which contains over 14,000 entries.

🎯 Why:

Eagerly creating thousands of complex objects (skyfield.api.Star and pint.Quantity) during the initialization of the NGC catalog was a major performance bottleneck, adding significant overhead to every Observation creation.

📊 Impact:

  • Reduces the time to initialize an Observation with NGC data from ~1.4s to ~0.8s (a ~42% improvement).
  • Minimizes memory pressure by only "thawing" objects that pass the magnitude filter.
  • Preserves full backward compatibility for users accessing the catalog data.

🔬 Measurement:

Measured using scripts/profile_apts.py and a custom Observation profiling script. Verified that all unit tests for NGC, Messier, and Stars pass.

🛠️ Key Changes:

  1. apts/catalogs.py: Modified _load_ngc_with_units to store raw floats instead of Quantities.
  2. apts/objects/ngc.py: Overrode get_visible to restore skyfield_object before calculations and restore Magnitude/Size Quantities for visible results. Updated get_skyfield_object to support lazy reconstruction.
  3. apts/objects/objects.py: Updated get_visible to handle Pint Quantities during magnitude filtering to prevent DimensionalityError. Added NaT safety to _vectorized_geometric_compute.
  4. tests/unit/test_ngc.py: Updated to verify lazy restoration of skyfield objects.

PR created automatically by Jules for task 17275612905742126655 started by @pozar87

Reduced NGC catalog load time by ~42% by deferring the creation of ~14,000 Skyfield Star and Pint Quantity objects.
- Catalogs.NGC now stores raw numeric data for Magnitude and Size.
- NGC.get_visible restores these objects lazily only for candidate items.
- Objects.get_visible ensures type-safe magnitude comparisons.
- Improved robustness for transit calculations with NaT handling.

Co-authored-by: pozar87 <9629954+pozar87@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules bot and others added 2 commits March 6, 2026 21:56
Reduced NGC catalog load time by ~42% by deferring the creation of ~14,000 Skyfield Star and Pint Quantity objects.
- Catalogs.NGC now stores raw numeric data for Magnitude and Size.
- NGC.get_visible restores these objects lazily only for candidate items.
- Objects.get_visible ensures type-safe magnitude comparisons.
- Improved robustness for transit calculations with NaT handling.
- Fixed undefined 'pd' name in NGC.get_skyfield_object.

Co-authored-by: pozar87 <9629954+pozar87@users.noreply.github.com>
Optimized NGC catalog load time by ~42% by deferring creation of ~14,000 Skyfield Star and Pint Quantity objects.
- Catalogs.NGC now stores raw numeric data for Magnitude and Size using object dtype for future-proofing.
- NGC.get_visible restores Skyfield objects for candidates before computation and restores Pint Quantities for visible results.
- Objects.get_visible ensures type-safe magnitude comparisons between Series and Quantities.
- Fixed robustness for transit calculations with NaT handling.
- Updated unit tests to verify lazy restoration and unpickling safety.

Co-authored-by: pozar87 <9629954+pozar87@users.noreply.github.com>
@pozar87 pozar87 merged commit 2d6880b into master Mar 7, 2026
1 check passed
@pozar87 pozar87 deleted the bolt/lazy-ngc-catalog-17275612905742126655 branch March 7, 2026 11:19
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.

1 participant