You are here: Home / Tools & Utilities / Python

Python

anything that uses python goes here
NuGrid's mesa.py
Demos, examples, and howto for NuGrid's mesa.py 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.
File parse_log.py
converts MESA star.log and lognnn.data 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]% parse_log.py LOGS/log1.data Converted LOGS/log1.data to LOGS/log1.fits You can then open these in python, matlab, IDL, etc and have the column definitions follow.
File update_inlist.py
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: update_inlist.py -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. update_inlist.py -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: update_inlist.py -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)
File SimpleMesaHRD.py
Kick-start python script to generate an HR diagram with Mesa .log data.
File SimpleMesaProf.py
Basis python script to generate a matplotlib structure plot, using the mesa class to easily import data from MESA's .data files
File SimpleMesaMovie.py
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 SimpleMesaKippi.py
Just to give an impression of the results to be expected when using SimpleMesaKippi.py: 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 'history.data' to 'star.log'. Everything else should still work fine.
File MesaHistoryGUI
MesaHistoryGUI.py is a simple script, that can serve as a basecamp to higher ambitions, for interactive inspection of history.data 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 MesaHistoryGUI.py running on some MESA history.data
MESAplot
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
PyMesaReader
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.
ReacSamp
A tool for sampling reaction rates in MESA. Working version found here: https://github.com/carlnotsagan/ReacSamp.
File Galactic Chemical History Tool for Nucleosynthesis
Contains the following: A) gch_abun.py 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 gch_abun.py; Uses Lodders2010 for solar abundance decomposition; Article explaining GCH process: http://adsabs.harvard.edu/abs/2013ApJ...774...75W