Plotting Evolutionary Tracks with PySEP

This script utilizes the PySEP (Python Stellar Evolution Plots) library to plot the evolutionary tracks of stellar models. Users provide paths to their model files, and the script plots these tracks, saving the resultant figure as a PDF. The script accepts multiple model files as input arguments and includes options for defining the output file path.

#!/usr/bin/env python
 
from pysep.dsep.load import load_model
from pysep.plot.evtrack import ev_tracks
import argparse
import os
 
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Plot the evolutionary tracks "
                                     "for some number of models")
    parser.add_argument("models", nargs="+", help="Paths to models", type=str)
    parser.add_argument("-o", "--output", help="path to save results to",
                        type=str, default="./evtrack.pdf")
 
    args = parser.parse_args()
 
    models = list()
    labels = list()
    for path in args.models:
        models.append((path, load_model(path)))
        labels.append(path.split('/')[-2])
 
    models = list(map(lambda x: x[1][0], models))
    fig, ax = ev_tracks(models, labels)
    fig.savefig(args.output)