Script for Generating Pre Main Sequence Models

This Python script, part of a scientific computing package, automates the generation of pre-main sequence (pre-MS) stellar models based on a given chemical composition file. It employs a command-line interface to receive user inputs specifying the path to the chemical composition file, mass range (lower limit, upper limit, and step size) for which the pre-MS models should be generated, and optional parameters for output directory and composition name. The script utilizes functions from the 'pysep' library to parse the composition file and generate the models across the specified mass range.

from pysep.newpoly.popFileToPolyModel import generate_prems_models
from pysep.opac.tops import open_and_parse
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, ".", compName=args.compName)