This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This repository processes DESI (Dark Energy Spectroscopic Instrument) BGS (Bright Galaxy Survey) galaxy catalogs and applies graph neural network models trained on IllustrisTNG simulations to infer cosmic web environments (Void, Wall, Filament, Cluster) for observed galaxies.
The main inference pipeline is in graph_catalog.py:
python graph_catalog.pyThis script:
- Loads or constructs a graph from DESI BGS galaxies (Delaunay or alpha-complex)
- Applies a pre-trained GAT model from the Illustris repository
- Outputs predictions to
DESI_BGS_PRERELEASE_VAC.pkl
-
Catalog Loading (
load_catalog.py)- Reads DESI fastspecfit catalogs from NERSC CFS:
/global/cfs/cdirs/desi/vac/dr2/fastspecfit/loa/v1.0/catalogs/ - Selects galaxies with 0.01 ≤ z ≤ 0.06, SPECTYPE=GALAXY
- Joins with redshift flags and Legacy Survey photometry
- Outputs:
loa-combined-lowz.fits,loa-combined-lowz-zflags.fits,loa-combined-lowz-fastspec-phot.fits
- Reads DESI fastspecfit catalogs from NERSC CFS:
-
Galaxy Catalog Processing (
galaxy_catalog.py)GalaxyCatalogclass: loads FITS files, filters by ZWARN, DELTACHI2, LOGMSTAR, BGS_TARGET- Converts RA/Dec to Cartesian coordinates (Mpc) using Planck18 cosmology
- Separates galactic north/south hemispheres
-
Graph Construction & Inference (
graph_catalog.py)- Creates
networkobject (from../TNG/Illustris/Network_stats.py) - Builds alpha-complex or Delaunay graph from galaxy positions
- Extracts node features, scales with Box-Cox transform
- Loads pre-trained GAT model from Illustris repo
- Outputs per-galaxy environment predictions and probabilities
- Creates
- Illustris Repository:
../TNG/Illustris/provides:Network_stats.py: Graph construction (Delaunay, alpha-complex)Utilities.py: TNG data loading utilities (used for comparison)- Pre-trained model weights:
trained_gat_model_ddp_*.pth
Processed graphs are cached in cache/:
DESI_alpha_graph.pt/DESI_delaunay_graph.pt- NetworkX graphDESI_alpha_geom.pt/DESI_delaunay_geom.pt- PyTorch Geometric Data objectDESI_alpha_features.pt- Scaled node featuresDESI_NETWORKalpha_zcat.pt- Galaxy catalog with predictions
Four cosmic web classes (from T-Web formalism):
- 0: Void
- 1: Wall
- 2: Filament
- 3: Cluster
- Fastspecfit catalogs:
/global/cfs/cdirs/desi/vac/dr2/fastspecfit/loa/v1.0/catalogs/ - Redshift catalog:
/global/cfs/cdirs/desi/spectro/redux/loa/zcatalog/v1/zall-pix-loa.fits - Legacy Survey photometry:
/global/cfs/cdirs/desi/vac/dr2/lsdr9-photometry/loa/v1.0/observed-targets