You are here: Home / Tools & Utilities / Python


anything that uses python goes here
Demos, examples, and howto for NuGrid's module that provides a profile and a historydata class.
File Python script for automatically generating a basic Tioga script
Here is a mildly interactive python script for reading in a MESA log or profile, automatically storing the data in a two-dimensional array (even with non-standard columns), and producing a rudimentary Tioga script which can be tweaked to make nice plots pretty easily.
converts MESA star.log and files to FITS binary tables. It's pretty simple, and I haven't verified all behavior, but I find it handy. Usage would be: plock[dk_wd]% LOGS/ Converted LOGS/ to LOGS/log1.fits You can then open these in python, matlab, IDL, etc and have the column definitions follow.
allows for command-line modification of inlist files. I find this handy for keeping track of exactly how the files change, and to allow changing things from a script. For example: -u h1_boundary_mass_limit -m h1_boundary_mass_limit 0.140 inlist_newwd uncomments the parameter "h1_boundary_mass_limit", and then sets its value to 0.140. -u save_model_number -m save_model_number 225 -m save_model_filename \'he_0.15_stripped.mod\' inlist_newwd makes mesa/star first save a model and then: -c save_model_number -u load_saved_model -m saved_model_name \'he_0.15_stripped.mod\' inlist_newwd makes it load in that model. It can also be used from within python: import update_inlist inlist='inlist_run' commandlist=[('max_model_number','modify',-1,'any'), ('max_years_for_timestep','modify',1e9,'any'), ('do_element_diffusion','modify','.true.','any'), ('pgstar_flag','modify','.true.','any')] update_inlistfile(inlist, commandlist)
Kick-start python script to generate an HR diagram with Mesa .log data.
Basis python script to generate a matplotlib structure plot, using the mesa class to easily import data from MESA's .data files
Simple python script to generate an mp4 movie using stellar data stored in MESA .data files made available through mesa class
File Kippenhahn diagram python script
A simple kick-start python script to produce decently looking Kippenhahn diagrams using Mesa-produced profile data. As far as I tested, the approach appears to be fast and robust.
File A Kippenhahn Diagram produced with
Just to give an impression of the results to be expected when using The attached plot shows the nuclear burning regions (H-shell and inward propagating He-shell) in 1.3 Msol star that evolves from the top of the giant branch to the giants' clump.
File History Log Scrubber
A simple script for scrubbing history logs. Just put this in a LOGS directory and execute it to remove bad history lines that result from backups, restarts, etc. (i.e., your history log will be properly ordered, and redundant lines are removed, giving preference to the most recently written lines). NOTE: This was written for version of MESA release 4411 and after. If you are using an older release, you will need to change the 'logName' variable from '' to 'star.log'. Everything else should still work fine.
File MesaHistoryGUI is a simple script, that can serve as a basecamp to higher ambitions, for interactive inspection of as computed with the MESA code. The quantities to be plotted can be easily modified, selecting - as of now - from the history data file. The script is simple enough that the user can be expected to read the source code, and together with the embedded comment lines, to easily find his/her way around to adapt it to own needs. The script is knitted around only numpy and matplotlib widgets so that it should run in most python implementations. The user navigates through the models by sliding the cursor along a slider widget at the bottom of the plot window.
File MesaHistoryGUI - Snapshot
Screenshot with running on some MESA
MESAplot is a graphical and dynamical user interface for plotting MESA data. It is a replacement for the mathematica-based MESAFace.
File Sample python script for batch MESA runs
a sample python script for batch processing multiple MESA runs. can be adopted to the work_pms_rotation lab in the 2013 summer school.
mesaplot (rob's)
Python library for ready mesa files and creating plots with mesa quantities
A nifty module for reading in Mesa LOGS directories as well as quickly getting information from history and profile data. Does not produce plots, but easily returns and analyzes numpy arrays that are columns in history and profile files. Pairs wonderfully with matplotlib. Link goes to github repo which has main file and link to documentation.
A tool for sampling reaction rates in MESA. Working version found here:
File Galactic Chemical History Tool for Nucleosynthesis
Contains the following: A) computes isotope abundance vector (mass fractions) at user defined metallicity; B) Isotopes directory contains abundances already computed for [Z]=-4.0,-3.5,-3.0,-2.5,-2.0,-1.5,-1.0,-0.5,0,0.1,0.2; C) Data directory contains solar abundance decomposition and utility files called by; Uses Lodders2010 for solar abundance decomposition; Article explaining GCH process: