jax-bandflux
JAX-accelerated supernova bandflux calculation for light curve modeling. Use when the user asks to "compute bandflux", "calculate supernova flux", "fit light…
от fundamental-physics★ 19 звёзд на GitHub
Установить jax-bandflux в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
JAX-bandflux
Overview
JAX-bandflux provides JAX-accelerated supernova light curve modeling with two source models:
SALT3Source: Type Ia supernova standardization using SALT3-NIR model
- Parameters:
x0(amplitude),x1(stretch),c(color) - Model range: phase -20 to +50 days, wavelength 2000-20000 Angstroms
- Parameters:
TimeSeriesSource: Custom SED models from arbitrary spectral time series
- Parameters:
amplitude(scaling factor) - Works with any 2D flux grid (phase x wavelength)
- Parameters:
Workflow Position
This skill provides component (2) Science in the physics workflow:
(1) Research/Brainstorm → (2) Science → (3) Inference → (4) Visualization
Inputs: Photometric observations (times, fluxes, errors, bands) Outputs: Model bandflux values, likelihood functions for sampling
Bandflux likelihoods connect to inference tools (e.g., nested sampling via blackjax-ns).
Installation
pip (CPU)
pip install jax-bandflux
pip install --upgrade "jax[cpu]"
pip (GPU/CUDA 12)
pip install "jax[cuda12]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip install jax-bandflux
uv (recommended for speed)
# CPU
uv pip install jax-bandflux "jax[cpu]"
# GPU/CUDA 12
uv pip install "jax[cuda12]" --find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
uv pip install jax-bandflux
conda
conda create -n jax-bandflux python=3.11
conda activate jax-bandflux
conda install -c conda-forge jax
pip install jax-bandflux
Verify Installation
import jax
jax.config.update("jax_enable_x64", True)
from jax_supernovae import SALT3Source, TimeSeriesSource
print(f"JAX devices: {jax.devices()}")
print("Installation verified!")
Quick Start 1: SALT3 Likelihood with Synthetic Data
This example demonstrates computing a SALT3 likelihood using synthetic photometric data.
Step 1: Generate Synthetic Data
import jax
import jax.numpy as jnp
import numpy as np
jax.config.update("jax_enable_x64", True)
from jax_supernovae import SALT3Source
from jax_supernovae.bandpasses import get_bandpass
from jax_supernovae.salt3 import precompute_bandflux_bridge
# True parameters for synthetic data
TRUE_PARAMS = {'x0': 1.0e-4, 'x1': 0.5, 'c': 0.05}
TRUE_T0 = 0.0 # Peak time (MJD offset)
TRUE_Z = 0.05 # Redshift
# Observation configuration
BANDS = ['bessellb', 'bessellv', 'bessellr']
OBS_TIMES = np.array([-10, -5, 0, 5, 10, 15, 20, 25, 30]) # Days from t0
NOISE_LEVEL = 0.05 # 5% flux uncertainty
# Generate synthetic observations
np.random.seed(42)
source = SALT3Source()
# Convert observer times to rest-frame phases
phases = (OBS_TIMES - TRUE_T0) / (1.0 + TRUE_Z)
# Generate observations for each band
obs_times, obs_fluxes, obs_errors, obs_bands = [], [], [], []
for band in BANDS:
true_flux = np.array(source.bandflux(TRUE_PARAMS, band, phases, zp=27.5, zpsys='ab'))
flux_err = np.abs(true_flux) * NOISE_LEVEL
noisy_flux = true_flux + np.random.normal(0, flux_err)
obs_times.extend(OBS_TIMES)
obs_fluxes.extend(noisy_flux)
obs_errors.extend(flux_err)
obs_bands.extend([band] * len(OBS_TIMES))
# Convert to JAX arrays
times = jnp.array(obs_times)
fluxes = jnp.array(obs_fluxes)
fluxerrs = jnp.array(obs_errors)
zps = jnp.full(len(times), 27.5)
print(f"Generated {len(times)} observations in {len(BANDS)} bands")
Step 2: Set Up Optimized Mode (Bridges)
Pre-compute bridges for ~100x speedup in likelihood evaluation:
# Identify unique bands and create bridges
unique_bands = list(set(obs_bands))
bridges = tuple(precompute_bandflux_bridge(get_bandpass(b)) for b in unique_bands)
# Map observations to band indices
band_to_idx = {b: i for i, b in enumerate(unique_bands)}
band_indices = jnp.array([band_to_idx[b] for b in obs_bands])
print(f"Pre-computed bridges for: {unique_bands}")
Step 3: Define Likelihood Function
FIXED_Z = TRUE_Z # Fixed redshift (known from spectroscopy)
@jax.jit
def loglikelihood(params):
"""Gaussian log-likelihood for SALT3 model.
Args:
params: dict with keys 't0', 'x0', 'x1', 'c'
Returns:
Log-likelihood value (scalar)
"""
t0 = params['t0']
x0 = params['x0']
x1 = params['x1']
c = params['c']
# Convert to rest-frame phases
phases = (times - t0) / (1.0 + FIXED_Z)
# Compute model fluxes (optimized mode)
bandflux_params = {'x0': x0, 'x1': x1, 'c': c}
model_fluxes = source.bandflux(
bandflux_params,
bands=None, # Use band_indices instead
phases=phases,
zp=zps,
zpsys='ab',
band_indices=band_indices,
bridges=bridges,
unique_bands=unique_bands,
)
# Gaussian log-likelihood
chi2 = jnp.sum(((fluxes - model_fluxes) / fluxerrs) ** 2)
return -0.5 * chi2
# Test at true parameters
test_params = {'t0': TRUE_T0, 'x0': TRUE_PARAMS['x0'],
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- scripts/custom_sed_likelihood.py
- scripts/generate_synthetic_data.py
- scripts/salt3_likelihood.py
FAQ
Что делает скилл jax-bandflux?
JAX-accelerated supernova bandflux calculation for light curve modeling. Use when the user asks to "compute bandflux", "calculate supernova flux", "fit light curves with JAX", "use SALT3 model", "create custom SED model", "set up supernova likelihood", or mentions jax-bandflux, SALT3Source, TimeSeriesSource, or supernova photometry. Provides installation guidance, synthetic data generation, and likelihood templates for SALT3 and custom SED models.
Как установить скилл jax-bandflux?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл jax-bandflux запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…