### Install project dependencies Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Install the core requirements for the project. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install baseline dependencies Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Install additional requirements needed to run classical and nested-sampling baselines. ```bash pip install -r requirements-baselines.txt ``` -------------------------------- ### Full l_rad calculation example Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_lrad_calculation/SKILL.md Complete workflow for calculating l_rad after fitting orbital parameters. ```python # After fitting: P, K, e, omega, M0 (all defined at t_ref = times[0]) import numpy as np t_ref = times[0] Omega_rad = 0.0 # RV-only assumption # M0 is mean anomaly at t_ref from your Keplerian fit l_rad = (Omega_rad + omega + M0) % (2 * np.pi) print(f"l_rad = {l_rad:.6f} rad") ``` -------------------------------- ### Alias Rejection Example Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_period_search/SKILL.md A conceptual example demonstrating how to reject trend aliases and resolve harmonic relationships between periodogram peaks. ```text Observation baseline: 30 days Periodogram peaks: 45d (power 0.82), 1.52d (power 0.71), 3.04d (power 0.65) Analysis: - 45d > 30d baseline → reject as trend alias - 3.04d ≈ 2 × 1.52d → harmonic relationship - Choose 1.52d as true period (shorter, physically more common for hot Jupiters) - Phase-fold at 1.52d → confirm smooth RV curve ``` -------------------------------- ### Perform Global Optimization Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_keplerian_fit/SKILL.md Uses differential evolution to search for initial parameters, preventing the optimizer from getting stuck in local minima. ```python bounds = [ (P_cand * 0.98, P_cand * 1.02), # P: tight around periodogram peak (0.1, 3 * K_sine), # K: semi-amplitude (0.0, 0.8), # e: eccentricity (0.0, 2*np.pi), # omega: argument of periastron (0.0, 2*np.pi), # M0: mean anomaly at t[0] (-50, 50), # gamma: systemic velocity offset ] result = differential_evolution(residual_func, bounds, seed=42, maxiter=300) ``` -------------------------------- ### Run classical baseline Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Execute the periodogram-to-Keplerian baseline script. ```bash python run_classical_baseline.py --output-dir results_classical ``` -------------------------------- ### Tool Call Budget Phases Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_submit_strategy/SKILL.md A structured approach to managing tool call usage across exploration, fitting, and refinement phases. ```text Total tool calls budget: N (typically 30-50) Phase 1 — Exploration (calls 1-8): - Load data, compute periodogram, identify period candidates - Quick sine fit to get rough K Phase 2 — First Fit (calls 9-16): - Full Keplerian fit (differential evolution) - Compute l_rad correctly → SUBMIT BASELINE SOLUTION HERE (call ~15) Phase 3 — Refinement (calls 17-25): - Check residuals for additional planets - Refine eccentricity - Try alternative periods if RMS is poor → SUBMIT IMPROVED SOLUTION IF BETTER Phase 4 — Polish (calls 26+): - MCMC or MCMC-like refinement only if time permits - DO NOT start new analysis from scratch → Submit final best solution before budget exhausted ``` -------------------------------- ### Project Directory Structure Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Visual representation of the repository layout, including core modules, agent tools, and experiment runners. ```text stargazer/ Core package config.py Task and system config dataclasses task_factory.py Synthetic task generation + difficulty scoring bank.py File-based task bank env.py RvEnv: agent-environment loop evaluator.py 4-criterion evaluation (BIC, RMS, Match, Count) matching.py Hungarian matching for planet comparison forward_keplerian.py Analytic Keplerian RV forward model engine_rebound.py N-body RV simulation via REBOUND noise.py Gaussian process and white noise injection agents/ tabular_agent.py LLM agent (OpenAI / Anthropic / OpenRouter) common.py Submission parsing and validation format_utils.py Trace export (JSON / Markdown / HTML) tools/ PythonREPL and submit_action tools benchmarks/baselines.py Null and single-sine baselines Stargazer_synthetic_task/ 100 synthetic tasks (10 per difficulty) Stargazer_real_data_task/ 20 real-world tasks from archival RV data stargazer_skills/ 5 domain-expert skills for prompt injection rv_period_search/ Period search and alias detection rv_keplerian_fit/ Robust Keplerian orbit fitting rv_lrad_calculation/ Mean longitude computation rv_multiplanet_detection/ Iterative residual analysis (difficulty >= 4) rv_submit_strategy/ Submission timing and budget management run_agent_batch.py Base batch runner (library) run_agent_batch_hard_timeout.py Main experiment runner with subprocess watchdog run_agent_batch_skills_timeout.py Skills experiment runner run_classical_baseline.py Lomb–Scargle + greedy Keplerian baseline run_nested_sampling_baseline.py Bayesian nested-sampling baseline ``` -------------------------------- ### Run tasks with injected skills Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Execute tasks using the skills-enabled runner to inject domain-expert knowledge into the system prompt. ```bash python run_agent_batch_skills_timeout.py \ --model gpt-5-mini \ --count 10 \ --output-dir results_gpt5mini_skills ``` -------------------------------- ### Refine Fit with Local Optimizer Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_keplerian_fit/SKILL.md Polishes the results from the global optimization using the Nelder-Mead method. ```python from scipy.optimize import minimize polished = minimize(residual_func, result.x, method='Nelder-Mead', options={'maxiter': 10000, 'xatol': 1e-8}) ``` -------------------------------- ### Handle Multi-Instrument Offsets Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_keplerian_fit/SKILL.md Logic for identifying unique instruments to ensure independent systemic velocity offsets (gamma) are fitted. ```python # Check if 'instruments' field has multiple unique values unique_insts = set(instruments) if len(unique_insts) > 1: # Add gamma_i for each instrument to parameter vector pass ``` -------------------------------- ### Run a single task by ID Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Execute a specific task using its unique identifier. ```bash python run_agent_batch_hard_timeout.py \ --model gpt-5-mini \ --task-ids seed22_diff4 \ --verbose \ --output-dir results_debug ``` -------------------------------- ### Run Lomb-Scargle Periodogram on Residuals Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_multiplanet_detection/SKILL.md Identify potential secondary planet periods by running a periodogram on the residuals of the first planet fit. ```python from astropy.timeseries import LombScargle ls = LombScargle(times, residuals_1, sigmas) freq, power = ls.autopower(minimum_frequency=1/1000, maximum_frequency=1/0.5) periods = 1/freq # Find peak best_P2 = periods[np.argmax(power)] ``` -------------------------------- ### Reference epoch validation Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_lrad_calculation/SKILL.md Demonstrates the correct and incorrect ways to define the reference epoch. ```python # WRONG: t_ref = 0.0 t_ref = np.mean(times) t_ref = 2450000.0 # CORRECT: t_ref = times[0] # Always the first observation time ``` -------------------------------- ### Run tasks with parallel workers Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Execute multiple tasks in parallel by specifying difficulty and worker count. ```bash python run_agent_batch_hard_timeout.py \ --model gpt-5-mini \ --count 1000 \ --difficulties 1 \ --workers 10 \ --output-dir results_diff1 ``` -------------------------------- ### Emergency Submission Protocol Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_submit_strategy/SKILL.md Fallback procedure to submit a simple circular fit when the tool call budget is nearly exhausted. ```python # Immediately fit a simple circular Keplerian (e=0) # using the best period from periodogram # Submit even a rough solution — reward > 0 is better than 0 quick_params = fit_circular(times, rvs, P_best) submit_action(planets=[{ 'P_days': P_best, 'K_ms': K_estimate, 'e': 0.0, 'omega_rad': 0.0, 'l_rad': 0.0, # rough estimate 'm_sin_i_mjup': estimate_mass(K_estimate, P_best, M_star) }]) ``` -------------------------------- ### Evaluate Model Selection with BIC Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_multiplanet_detection/SKILL.md Use the Bayesian Information Criterion to statistically justify adding a second planet to the model. ```python from scipy.optimize import minimize def bic(n_params, n_data, rms): """Bayesian Information Criterion.""" chi2 = n_data * (rms / sigma_median)**2 return chi2 + n_params * np.log(n_data) # 1-planet model: 5 free params per planet + 1 gamma bic_1 = bic(6, len(times), rms_1) # Fit 2-planet model # ... fit params2, compute rms_2 ... bic_2 = bic(11, len(times), rms_2) delta_bic = bic_1 - bic_2 if delta_bic > 10: print("Strong evidence for 2nd planet (ΔBIC > 10)") elif delta_bic > 6: print("Moderate evidence for 2nd planet") else: print("No strong evidence for 2nd planet — submit 1 planet") ``` -------------------------------- ### Multi-Planet Decision Rule Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_multiplanet_detection/SKILL.md Logic for determining whether to add more planets based on residual RMS and BIC values. ```text residual_rms after N planets: > 3× noise: add another planet 2-3× noise: check ΔBIC, add if > 6 < 2× noise: stop, submit N planets ``` -------------------------------- ### Calculate l_rad with M0 at t_ref Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_lrad_calculation/SKILL.md Direct calculation when M0 is already defined at the reference epoch. ```python M0_at_tref = M0 # from optimizer l_rad = (omega_rad + M0_at_tref) % (2 * np.pi) ``` -------------------------------- ### Calculate Residuals for Multi-Planet Detection Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_multiplanet_detection/SKILL.md Subtract the first planet model from the radial velocity data to evaluate the remaining signal against the noise floor. ```python # Subtract planet 1 model from data residuals_1 = rvs - planet1_model(times, *params1) rms_1 = np.sqrt(np.mean(residuals_1**2)) # Compare to noise floor (median sigma) sigma_median = np.median(sigmas) print(f"Residual RMS: {rms_1:.2f} m/s, noise floor: {sigma_median:.2f} m/s") ``` -------------------------------- ### Compute Period Aliases Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_period_search/SKILL.md Calculate potential 1-day aliases and harmonics for a candidate period to identify related peaks in the periodogram. ```python alias_1 = 1 / (1/P_cand - 1) # +1 day alias alias_2 = 1 / (1/P_cand + 1) # -1 day alias alias_half = P_cand / 2 # sub-harmonic alias_double = P_cand * 2 # harmonic ``` -------------------------------- ### Refine Period Search Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_period_search/SKILL.md Perform a fine grid search around a candidate period to improve precision after the initial identification. ```python P_fine = np.linspace(P_cand * 0.95, P_cand * 1.05, 1000) # Re-run GLS on fine grid and take the maximum ``` -------------------------------- ### Submission Parameter Validation Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_submit_strategy/SKILL.md Required checks for physical reasonableness of orbital parameters before calling submit_action. ```python # 1. Parameters are physically reasonable assert 0.1 < P < 10000, "Period out of range" assert K > 0, "Semi-amplitude must be positive" assert 0.0 <= e < 1.0, "Eccentricity must be in [0, 1)" assert 0.0 <= l_rad <= 2*np.pi, "Mean longitude must be in [0, 2π]" # 2. l_rad computed at t_ref = times[0] t_ref = times[0] l_rad = (omega + M0) % (2 * np.pi) # see rv_lrad_calculation skill # 3. Mass from K and orbital parameters # m_sin_i_mjup estimated from K, P, M_star ``` -------------------------------- ### Submission Criteria Logic Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_submit_strategy/SKILL.md Conditions under which a submission should be triggered to avoid analysis paralysis. ```text Submit if ANY of these are true: ✓ RMS < 30 m/s (for typical tasks) ✓ You have spent > 8 tool calls without submitting ✓ Your current fit matches the period and K within 10% ✓ You are about to try something risky (MCMC, re-fit from scratch) ``` -------------------------------- ### Detrend RV Data Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_period_search/SKILL.md Remove linear RV drift using polynomial fitting before running a periodogram to prevent spurious long-period peaks. ```python from numpy.polynomial import polynomial as P trend_coeffs = np.polyfit(times, rvs, 1) rvs_detrended = rvs - np.polyval(trend_coeffs, times) ``` -------------------------------- ### Calculate l_rad for RV-only fits Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_lrad_calculation/SKILL.md Formula for calculating l_rad when Omega_rad is zero. ```python l_rad = (omega_rad + M0_at_tref) % (2 * np.pi) ``` -------------------------------- ### Define Joint 2-Planet RV Model Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_multiplanet_detection/SKILL.md Construct a joint model that sums two Keplerian signals and a gamma offset for simultaneous fitting. ```python # Joint 2-planet RV model: sum of two Keplerian signals + gamma def two_planet_rv(t, P1, K1, e1, w1, M01, P2, K2, e2, w2, M02, gamma): return kepler_rv(t, P1, K1, e1, w1, M01, 0) + \ kepler_rv(t, P2, K2, e2, w2, M02, 0) + gamma ``` -------------------------------- ### Convert M0 to reference epoch Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_lrad_calculation/SKILL.md Adjusts the mean anomaly M0 from a fit time t_fit to the reference epoch t_ref. ```python t_ref = times[0] # If M0 was defined at t_fit: M0_at_tref = (M0_at_tfit + 2*np.pi/P * (t_ref - t_fit)) % (2*np.pi) ``` -------------------------------- ### Define Keplerian RV Model Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_keplerian_fit/SKILL.md Implements the full Keplerian radial velocity model, including iterative solving of Kepler's equation. ```python from scipy.optimize import minimize, differential_evolution def keplerian_rv(t, P, K, e, omega, M0, gamma): """Full Keplerian RV model.""" M = (2 * np.pi / P) * (t - t[0]) + M0 # Solve Kepler's equation iteratively E = M.copy() for _ in range(50): E = M + e * np.sin(E) nu = 2 * np.arctan2(np.sqrt(1+e)*np.sin(E/2), np.sqrt(1-e)*np.cos(E/2)) return K * (np.cos(nu + omega) + e * np.cos(omega)) + gamma ``` -------------------------------- ### BibTeX Citation for Stargazer Source: https://github.com/aips-uoft/stargazer/blob/main/README.md Use this BibTeX entry to cite the Stargazer paper in academic publications. ```bibtex @article{liu2026stargazer, title = {Stargazer: A Scalable Model-Fitting Benchmark Environment for AI Agents under Astrophysical Constraints}, author = {Liu, Xinge and Zhang, Terry Jingchen and Sch{"o}lkopf, Bernhard and Jin, Zhijing and Menou, Kristen}, year = {2026}, journal = {arXiv preprint arXiv:2604.15664}, url = {https://arxiv.org/abs/2604.15664} } ``` -------------------------------- ### Phase-Fold RV Data Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_period_search/SKILL.md Validate a candidate period by folding the detrended RVs to check for a coherent sinusoidal pattern. ```python phases = (times % P_cand) / P_cand # Plot phases vs rvs_detrended — should show a smooth sinusoidal pattern ``` -------------------------------- ### Calculate and Report RMS Source: https://github.com/aips-uoft/stargazer/blob/main/stargazer_skills/rv_keplerian_fit/SKILL.md Computes the root-mean-square error of the residuals to evaluate fit quality. ```python residuals = rvs - model_rvs rms = np.sqrt(np.mean(residuals**2)) print(f"RMS = {rms:.3f} m/s") # If RMS > task threshold, try: different period, different e starting point ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.