Isochrone Color-Magnitude Diagram (CMD) Generator Script

This script is designed to process isochrone data files, specifically those named 'isochrones.txt' located within a directory structure. It utilizes a custom class, CMDv2, from the ThomasAstro.iso.CMDGenerator module to generate color-magnitude diagrams (CMD) based on the isochrone data. The script iterates over all 'isochrones.txt' files found within the '../outputs' directory and its subdirectories, computes the magnitudes with specific parameters (in this case, 0 and 3.1) using the CMD class, and then serializes the output magnitudes as a pickle file ('CMD.pkl') in the same directory as the input file. This procedure is aimed at astronomers or astrophysicists involved in the study of stellar populations, star clusters, or galaxies, facilitating the visual analysis and comparison of theoretical and observed stellar magnitudes and colors.

from ThomasAstro.iso.CMDGenerator import CMDv2
import os
import pickle as pkl
import pathlib
from tqdm import tqdm
 
for isoPath in tqdm(pathlib.Path("../outputs").rglob("isochrones.txt")):
    print(isoPath)
    dirname = os.path.dirname(isoPath)
    CMD = CMDv2(isoPath)
    mags = CMD.get_mags(0,3.1)
    outName = os.path.join(dirname, "CMD.pkl")
    with open(outName, 'wb') as f:
        pkl.dump(mags, f)