Python Script for Generating Pre Mainsequence Models

This file is a Python script designed for astrophysics research, particularly in the area of star formation and evolution. It takes a chemical composition file as input, along with parameters defining a range of stellar masses, and generates pre-mainsequence models for this range. These models simulate the early stages of star formation before the stars begin fusing hydrogen in their cores. The script relies on the pysep package for processing the input and generating the models, and utilizes numpy for handling numerical ranges.

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, DDAGE=1000)