Detecting the first (1G/P1) and second (2G/P2) stellar generations in a globular cluster from real Hubble Space Telescope photometry, using a chromosome map and unsupervised machine learning (K-means and DBSCAN).
Output for NGC 6752 from real HST/HUGS photometry. An unsupervised workflow recovers two stellar generations: the first (blue) and the second (red), whose UV photometry encodes the abundance variations associated with helium- and nitrogen-enhanced stars.
Globular clusters were long assumed to be simple stellar populations all stars born at one time, from one cloud, with one chemistry. Hubble UV photometry overturned that: almost every cluster hosts at least two populations that differ in their light-element abundances (He, C, N, O, Na, Al, Mg) while sharing the same iron content.
This project reproduces that signal end-to-end:
- Loads the public HUGS photometric catalogue for a cluster.
- Selects likely cluster-member red-giant-branch stars.
- Builds the chromosome map, a pseudo-two-colour diagram combining F275W, F336W, F438W and F814W magnitudes that maximally separates the populations.
- Splits the populations with K-means (k=2) and cross-checks with DBSCAN (density-based).
This implementation assumes a two-population model (1G/2G) and is intended as an educational reproduction rather than a full population census. Several real clusters host three or more sub-populations (3G, 4G, …); DBSCAN is included to show where the density structure does or does not support a simple two-way split.
- Writes figures and a labelled per-star table.
NGC 6752 is one of the nearest, low-reddening globular clusters with a
textbook multiple-population signature - making the split recoverable without
heavy differential-reddening correction. (M4, the closest cluster, is also
included as a test case, but its strong, patchy reddening blurs the map; see
notes below.) Swap in any HUGS cluster via --catalog.
pip install -r requirements.txt
# The script downloads the public catalogue directly from MAST:
python multiple_populations.py \
--catalog "https://archive.stsci.edu/hlsps/hugs/ngc6752/hlsp_hugs_hst_wfc3-uvis-acs-wfc_ngc6752_multi_v1_catalog-meth2.txt" \
--name "NGC 6752" --out figures \
--membership-cut 0.9 --max-rms 0.03 --min-qfit 0.9If your environment blocks the STScI archive, download the file in a browser
and pass the local path to --catalog instead.
After running the analysis, regenerate the publication-quality figures (chromosome map, colour-magnitude diagram, and the combined two-panel view) with:
python make_figures.py| File | Description |
|---|---|
chromosome_map.png |
Raw pseudo-two-colour diagram of the RGB |
kmeans_populations.png |
1G vs 2G split (K-means, k=2) |
dbscan_groups.png |
Density-based grouping (DBSCAN) |
labelled_stars.csv |
Per-star map coordinates + population labels |
- The chromosome map is built by verticalising the red-giant branch: colours are detrended against magnitude (robust quadratic fit with outlier rejection) so the population signal is the residual, not the raw colour. This follows the spirit of Milone et al. (2017) but does not use their exact fiducial lines, absolute positions differ from published figures, while the population split is the same physical signal.
- The K-means split is a boundary through a continuous, sheared distribution, not two fully detached islands. Treat the second-generation fraction as approximate; DBSCAN is included to show where density structure does (or does not) support a hard split.
- Differential reddening is not corrected. This is why NGC 6752 (low reddening) gives a clean map while M4 (E(B-V) ~ 0.37, patchy) does not. For high-reddening clusters, add a reddening correction before mapping.
- Quality cuts matter: poor-fit stars form a spurious cloud. Tune
--max-rms,--min-qfit, and--membership-cutper cluster.
Photometry - HUGS / HST UV Legacy Survey of Galactic Globular Clusters
- Piotto et al. 2015, AJ, 149, 91
- Nardiello et al. 2018, MNRAS, 481, 3382
- MAST High Level Science Product "HUGS", DOI: 10.17909/T9810F
- Archive: https://archive.stsci.edu/prepds/hugs/
Chromosome-map technique
- Milone et al. 2017, MNRAS, 464, 3636
Narrative inspiration (not a data source)
- Jan Hattenbach, "Cluster Mystery", Sky & Telescope, July 2026.
Based on observations with the NASA/ESA Hubble Space Telescope, obtained at STScI, operated by AURA under NASA contract NAS 5-26555.
MIT