Skip to main content

Core Pipeline

This page maps the AstroSpectro pipeline from raw LAMOST DR5 FITS files to a trained classifier: what each stage does, which module implements it and which page documents it. The whole chain is orchestrated by MasterPipeline (src/pipeline/master.py) and is usually driven from notebooks/00_master_pipeline.ipynb.


Pipeline position​


Stages​

#StageModule · entry pointWhat it producesPage
1Downloadsrc/tools/dr5_downloader.py · SmartDownloaderFITS files organised by observing planLAMOST DR5
2Batch selectionsrc/tools/dataset_builder.py · DatasetBuilderList of FITS paths not yet used for training (ledger trained_spectra.csv)Master Pipeline
3Cataloguesrc/tools/generate_catalog_from_fits.py · generate_catalog_from_fitsOne row of header metadata per spectrumMaster Catalog
4Gaia enrichment (optional)src/tools/gaia_crossmatcher.py · enrich_catalog_with_gaiaGaia DR3 astrometry, photometry and derived columnsGaia DR3
5Preprocessingsrc/pipeline/preprocessor.py · SpectraPreprocessorWavelength, median-normalised flux, sanitised inverse variancePreprocessing
6Line detectionsrc/pipeline/peak_detector.py · PeakDetectorDetected absorption lines matched to the line list (match_* columns)Peak Detection
7Feature extractionsrc/pipeline/feature_engineering.py · FeatureEngineerSpectroscopic descriptors (feature_* columns)Feature Engineering · theory
8Batch processingsrc/pipeline/processing.py · ProcessingPipeline.runFeature table joined with the catalogue (parallel I/O + CPU)Processing Pipeline
9Classificationsrc/pipeline/classifier.py · SpectralClassifierTrained model, metrics, confusion matrixClassification
10Tracking (optional)src/pipeline/wandb_config.pyWeights & Biases run, when enabledExperiment Tracking

Orchestration​

MasterPipeline chains stages 2 to 9:

MethodStages
select_batch(batch_size, strategy)2
generate_and_enrich_catalog(enrich_gaia, **gaia_kwargs)3–4
process_data()5–8
run_training_session(...)9 (and 10 when W&B is enabled)
run_full_pipeline(...)2–9 in one call, then records the batch in trained_spectra.csv
interactive_training_runner()ipywidgets interface used in the notebook
from src.pipeline.master import MasterPipeline

pipe = MasterPipeline(
raw_data_dir="data/raw/", catalog_dir="data/catalog/", processed_dir="data/processed/",
models_dir="data/models/", reports_dir="data/reports/",
)
pipe.run_full_pipeline(batch_size=500, model_type="XGBoost", enrich_gaia=True)

Feature tables can also be reloaded without reprocessing (load_features_from_csv), which is how training sessions are usually run on a previously built table.


Design choices​

  • Spectroscopic features first. The classifier is meant to rely on descriptors measured on the flux. Non-spectroscopic columns are excluded by spectro_only; the exclusion is incomplete in the reference run (see Classification).
  • No spectrum reused across sessions. DatasetBuilder keeps a ledger of the spectra already used, so successive batches are disjoint.
  • Every run leaves a trace. Models are saved with a _meta.json, and each training session writes a timestamped report directory; see Reproducibility.