photic is a small package for joint neural-process style modeling of irregular multi-band light curves.
The current project supports:
- joint reconstruction + binary TDE classification training on the Mallorn dataset
- diagnostics and reconstruction plots for saved checkpoints
- alert-stream polling through ALeRCE
- neural-process forecasting from partial alert photometry
- a NiceGUI viewer for forecast JSON outputs
Base install:
pip install -e .With broker support:
pip install -e ".[brokers]"With GUI support:
pip install -e ".[gui]"With both:
pip install -e ".[brokers,gui]"Show top-level help:
photic --helpCurrent commands:
train-mallorn: train a joint NP model on the Mallorn training set. Supports bothconvgnpandattnnp, checkpoint selection, staged fine-tuning, and the optional early-timeinterestingnesshead.evaluate-mallorn-checkpoint: load a saved checkpoint and score it on the Mallorn validation set using either random or prefix-style contexts, with early-time context/day bins.crossval-mallorn: train one model per Mallornsplit, save out-of-fold predictions, and derive a global OOF threshold for leaderboard-style submission tuning.predict-mallorn-test: run one checkpoint on the Mallorn test set and write a submission CSV inobject_id,predictionformat.predict-mallorn-test-ensemble: average predictions from multiple checkpoints on the Mallorn test set and write a binary or probability submission file.forecast-alert-stream: poll ALeRCE for LSST alerts, fetch photometry, run NP forecasts, and write one JSON forecast per alert object.forecast-gui: launch the NiceGUI viewer for forecast JSON files.
Strong ConvGNP baseline:
photic train-mallorn \
--data-dir /Users/nmearl/research/mallorn \
--out-dir /Users/nmearl/code/photic/output/photic_joint_retrain \
--device mps \
--num-workers 0 \
--model-type convgnp \
--lambda-morph 0.15 \
--checkpoint-metric best_f1Attentive NP with the auxiliary interestingness head:
photic train-mallorn \
--data-dir /Users/nmearl/research/mallorn \
--out-dir /Users/nmearl/code/photic/output/photic_attnnp_interesting \
--device mps \
--num-workers 0 \
--model-type attnnp \
--lambda-interesting 1.0 \
--lambda-cls 1.0 \
--lambda-morph 0.15 \
--checkpoint-metric best_f1Useful flags:
--model-type {convgnp,attnnp}--context-strategy {random,prefix}--checkpoint-metric {best_f1,ap,composite}--lambda-recon FLOAT--lambda-cls FLOAT--lambda-interesting FLOAT--lambda-morph FLOAT--focal-gamma FLOAT
Optional stage-2 fine-tuning exists, but single-stage joint training remains the default:
--stage2-epochs--stage2-from--stage2-lambda-recon--stage2-focal-gamma
Evaluate a checkpoint on early-time prefix contexts:
photic evaluate-mallorn-checkpoint \
--data-dir /Users/nmearl/research/mallorn \
--checkpoint /Users/nmearl/code/photic/output/photic_attnnp_interesting/best_f1_checkpoint.pt \
--device mps \
--num-workers 0 \
--eval-context-strategy prefix \
--out-json /Users/nmearl/code/photic/output/photic_attnnp_interesting/early_eval.jsonThis prints:
- overall
best_f1,ap, reconstruction metrics - context-count bins like
ctx<=3/5/10/20/40/80 - day-since-anchor bins like
days<=7/30/60/90/120/180 - auxiliary
interestinghead metrics when enabled
Train Mallorn split-based cross-validation folds:
photic crossval-mallorn \
--data-dir /Users/nmearl/research/mallorn \
--out-dir /Users/nmearl/code/photic/output/photic_joint_cv \
--model-type convgnp \
--context-strategy random \
--device mps \
--num-workers 0Single-checkpoint submission:
photic predict-mallorn-test \
--data-dir /Users/nmearl/research/mallorn \
--checkpoint /Users/nmearl/code/photic/output/photic_joint_retrain/best_f1_checkpoint.pt \
--out-csv /Users/nmearl/code/photic/output/photic_joint_retrain/submission.csv \
--device mpsEnsemble submission from multiple checkpoints:
photic predict-mallorn-test-ensemble \
--data-dir /Users/nmearl/research/mallorn \
--checkpoint /Users/nmearl/code/photic/output/photic_joint_cv/split_01/best_f1_checkpoint.pt \
--checkpoint /Users/nmearl/code/photic/output/photic_joint_cv/split_02/best_f1_checkpoint.pt \
--out-csv /Users/nmearl/code/photic/output/photic_joint_cv/submission_ensemble.csv \
--threshold-json /Users/nmearl/code/photic/output/photic_joint_cv/oof_summary.json \
--device mpsNotes:
- submission files default to binary
0/1predictions predict-mallorn-testuses the checkpoint’s saved validationbest_thresholdby defaultpredict-mallorn-test-ensemblecan use the OOF threshold fromoof_summary.json
Generate diagnostics for a checkpoint:
python scripts/mallorn_diagnostics.py \
--data-dir /Users/nmearl/research/mallorn \
--checkpoint /Users/nmearl/code/photic/output/photic_joint_retrain/best_f1_checkpoint.pt \
--out-dir /Users/nmearl/code/photic/output/photic_joint_retrain/diagnostics \
--device mps \
--num-workers 0 \
--context-strategy randomFor early-context plots, use:
python scripts/mallorn_diagnostics.py \
--data-dir /Users/nmearl/research/mallorn \
--checkpoint /Users/nmearl/code/photic/output/photic_attnnp_interesting/best_f1_checkpoint.pt \
--out-dir /Users/nmearl/code/photic/output/photic_attnnp_interesting/diagnostics \
--device mps \
--num-workers 0 \
--context-strategy prefixOutputs include:
diagnostics_summary.jsonval_object_metrics.csvtde_reconstructions.pngtde_prefix_reconstructions.pngwhen--context-strategy prefix
photic forecast-alert-stream \
--broker alerce \
--survey lsst \
--checkpoint /Users/nmearl/code/photic/output/photic_joint_retrain/best_f1_checkpoint.pt \
--out-dir /Users/nmearl/research/alert_forecasts \
--device mps \
--since-mjd 59000 \
--min-context-points 5 \
--min-context-bands 2 \
--max-polls 1This writes one JSON file per alert object under:
<out-dir>/forecasts/
Each file contains:
- broker update metadata
- observed alert photometry
- per-band NP forecast curves
- classification score (
prob_tde)
photic forecast-gui \
--forecast-dir /Users/nmearl/research/alert_forecasts/forecasts \
--host 127.0.0.1 \
--port 8080Then open:
http://127.0.0.1:8080
The GUI shows:
- observed photometry by band
- forecast mean and uncertainty by band
- object metadata
- broker update information
- classification confidence
- The current alert forecaster expects difference-flux-style inputs. For LSST ALeRCE payloads, this maps to
psfFlux/psfFluxErr. - Many new alerts only have a few photometric points. Use
--min-context-pointsand--min-context-bandsto avoid generating low-value forecasts. - Existing forecast JSON files generated before recent CLI patches may not include the observed photometry block needed for full GUI overlay.