Package: mesaPlot
mesaplotLibrary of python routines to read MESA ouput files and plot MESA quantitesInstallation instructions:git clone the repo then callpython3setup.pyinstallDepending on choice of python version, --user can also be passed to install locallymakeCan be called as wellTestingpytestTo run tests for current python versiontoxwill run tests for several python versionsContributingBug reports should go to githubs issue tracker.Requests for new features should also got to the issue tracker.If you wish to submit your own fix/new feature please send a pull request.Reading data:importmesaPlotasmpm=mp.MESA()Now m contains all the useful stuffHistory filesm.loadHistory()This loads up the history file data by default it will look for LOGS/history.data.
But if you have a different folder to look at then you can eitherm.log_fold='new_folder/LOGS/'m.loadHistory()orm.loadHistory(f='new_folder/LOGS/')Note this will automatically clean the history data of retries, backups and restarts. To write that data back to diskm.scrubHistory()Which will create a file "LOGS/history.data.scrubbed" if you don't want that then:m.scrubHistory(fileOut='newFile')Data can be accessed as m.hist.data['COLUMN_NAME'] or m.hist.COLUMN_NAME. The second option is
also tab completable. The header information is either m.hist.head['COLUMN_NAME'] or m.hist.COLUMN_NAME.Profile filesTo load a profile file its:m.loadProfile()Again you change the LOGS folder either with log_fold or f=.
To choose which file to load, either:m.loadProfile(num=MODEL_NUMBER)orm.loadProfile(prof=PROFILE_NUMBER)Where MODEL_NUMBER is a MESA model number and PROFILE_NUMBER is the number in the profile file name.
You can also set a modem.loadProfile(num=MODEL_NUMBER,mode='first|lower|upper|nearest')This is for when the model you want isn't in the data. Either we load the first model, the model just before the one you want, the model just after the one you want or the nearest (above or below) the model you want.
There are also two special model numbers 0 for first model and a negative number that counts backwards (-1 is the last model, -2 is last but one etc)Data can be accessed as m.prof.data['COLUMN_NAME'] or m.prof.COLUMN_NAME. The second option is
also tab completable. The header information is either m.prof.head['COLUMN_NAME'] or m.prof.COLUMN_NAME.NOTE:To speed up repeated readings of the LOG data, mesaPlot saves a
binary version of the data (taking care to regenerate this file if the history/profile is updated).
This binary file SHOULD NOT be depended upon for long term storage. The file format may change between
versions and is not backward compatable. For long term storage allways keep the plain text history/profile file
(possibly compressed to save space).PlottingHere we'll show the basics of plotting, there are more complex examples for each section. Commands will assume you are in a MESA work folder, such that the data is in a LOGS/ folder.History dataimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotHistory(m,xaxis='star_age',y1='log_center_T',y2='he_core_mass')Profile dataimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotProfile(m,xaxis='mass',y1='logT',y2='ye')HRimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotHR(m)Kippenhan'sKippenhan plot with model number vs mass. Note all Kippenhan plots
require your history file to have both mixing_regions X and burning_regions Y
set in your history_columns.list file, where X and Y are integers that
specify the maximum number of mixing/burning
zones in your model, values around 20 will usually suffice. Models going to
core collapse may want to increase this limit to 40.importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotKip(m,show_mass_loc=True)Kippenhan plot with star age vs massimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotKip2(m)Generic kippenhan plotterimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotKip3(m,show_mass_loc=True)New way of doing plotKip2 (star age vs mass)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotKip3(m,xaxis='star_age',age_lookback=True,age_log=True)Profile based kippenhansimportmesaPlotasmpm=mp.MESA()m.loadHistory()m.loadProfile(num=1)p=mp.plot()p.plotKip3(m,plot_type='profile',xaxis='model_number',yaxis='mass',zaxis='logRho',mod_min=1,mod_max=3000)AbundancesimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotAbun(m)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotAbunByA(m)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)m2=mp.MESA()m2.log_fold='../some/other/mesa/result'm2.loadprofile(num=-1)p.plotAbunByA(m,m2=m2)importmesaPlotasmpm=mp.MESA()p=mp.plot()p.set_solar('ag89')m.loadProfile(num=-1)#Plot the mass fractions relative to solarp.plotAbunByA(m,stable=True)importmesaPlotasmpm=mp.MESA()p=mp.plot()p.set_solar('ag89')m.loadProfile(num=-1)m2=mp.MESA()m2.log_fold='../some/other/mesa/result'm2.loadprofile(num=-1)#Plot the mass fractions relative to solar relative to 2nd modelp.plotAbunByA(m,m2=m2,stable=True)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()#Use the data in the history file at model_number==modelp.plotAbunByA(m,plot_type='history',model=1000,prefix='log_center_')importmesaPlotasmpm=mp.MESA()p=mp.plot()p.set_solar('ag89')m.loadHistory()#Use the data in the history file, plotting relative to another model number after decaying the isotopes to thier stable versionsp.plotAbunByA(m,plot_type='history',model=1000,model2=1,prefix='surface_',stable=True)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotAbunPAndN(m)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotAbunPAndN(m,plot_type='history',model=1000,prefix='log_center_')importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotAbunHist(m)Burn dataimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotBurn(m)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadHistory()p.plotBurnHist(m)DynamosimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotDynamo(m)importmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotDyanmo2(m)Angular momentum mixingimportmesaPlotasmpm=mp.MESA()p=mp.plot()m.loadProfile(num=-1)p.plotAngMom(m)Time series Profile plotsimportmesaPlotasmpm=mp.MESA()m.loadHistory()m.loadProfile(num=1)p=mp.plot()p.plotSliderProf(m,'plotAbun')Passing in a string for the name of a plotting function, (only ones based on profile data).
This will show that plot with a slider that can be used to iterate over the available profile files
plotSliderProf will take any extra arguments passed to it and
pass them to the plotting function.Stacked plotsMulti profile plotsGrid plotting