Working with Stellar Models and Low-Temperature Opacity Files in Python
This Python script demonstrates how to use a library for simulating stellar models to manage and apply different sets of low-temperature opacity files. It shows the process of selecting specific types of opacity files, organizing these files into different categories based on their origins (Fergeson and Aesopus), and applying them to create and evolve parallel stellar models. The script also covers basic directory operations like checking for the existence of folders and creating them if they do not exist, thereby preparing the environment for output data.
from pysep.api.starting import get_basic_stellar_model from pysep.dm.filetypes import opacf_file from pysep.api.parallel import pStellarModel import os FergLowTempRoot = "./inputs/opac/low/ferg04" AesoLowTempRoot1 = "./inputs/opac/low/aesopusExtend" AesoLowTempRoot2 = "./inputs/opac/low/aesopus" FergFiles = filter(lambda x: x.endswith(".tron"), os.listdir(FergLowTempRoot)) AesoFiles1 = filter(lambda x: x.endswith(".tron"), os.listdir(AesoLowTempRoot1)) AesoFiles2 = filter(lambda x: x.endswith(".tron"), os.listdir(AesoLowTempRoot2)) FergPaths = [os.path.abspath(os.path.join(FergLowTempRoot, x)) for x in FergFiles] AesoPaths1 = [os.path.abspath(os.path.join(AesoLowTempRoot1, x)) for x in AesoFiles1] AesoPaths2 = [os.path.abspath(os.path.join(AesoLowTempRoot2, x)) for x in AesoFiles2] if not os.path.exists("./fergOutput"): os.mkdir("./fergOutput") if not os.path.exists("./aesopusExtendOutput"): os.mkdir("./aesopusExtendOutput") if not os.path.exists("./aesopusOutput"): os.mkdir("./aesopusOutput") FergModel = get_basic_stellar_model("./fergOutput") AesoModel1 = get_basic_stellar_model("./aesopusExtendOutput") AesoModel2 = get_basic_stellar_model("./aesopusOutput") FergModel.control.update_low_temp_opacity_files(FergPaths) AesoModel1.control.update_low_temp_opacity_files(AesoPaths1) AesoModel2.control.update_low_temp_opacity_files(AesoPaths2) pModels = pStellarModel([FergModel, AesoModel1, AesoModel2], name="NewLowTempOpacTest") pModels.pEvolve(autoStash=True)