Script for Generating Pre-Main Sequence Models

This Python script generates pre-main sequence (pre-MS) models for a range of masses given a chemical composition file. The user specifies the path to the composition file, a low and high mass range, and a step size between masses. Additionally, options to specify the output directory and a name for the composition are available. The script uses the PySEP library functions to open and parse the composition file, then generate and output the pre-MS models.

from pysep.opac.tops import open_and_parse
from pysep.newpoly.popFileToPolyModel import generate_prems_models
 
from numpy import arange
import argparse
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Generate pre mainsequence models given a chemical composition file for a range of masses")
    parser.add_argument("path", help="path to chemical composition file", type=str)
    parser.add_argument("mlow", help="low mass range of pre main sequence models to generate", type=float)
    parser.add_argument("mhigh", help="high mass range of pre main sequence models to generate", type=float)
    parser.add_argument("mstep", help="step size betweem pre main sequence masse", type=float)
    parser.add_argument("-o", "--output", help="directory to output pre main sequence models too", type=str, default=".")
    parser.add_argument("-c", "--compName", help="Composition name to use in the premain sequence model", type=str, default="comp")
 
    args = parser.parse_args()
    masses = arange(args.mlow, args.mhigh, args.mstep)
 
    parsed = open_and_parse(args.path)
 
    generate_prems_models(parsed, masses, args.output, compName=args.compName)