[Mesa-users] tomso v0.0.12

Warrick Ball W.H.Ball at bham.ac.uk
Fri Dec 11 09:15:36 EST 2020


Hi everyone,

Over the years, I've built up a library of Python functions for reading and writing various input and output files from various stellar evolution and oscillation programs, including ADIPLS, GYRE, MESA and the Cambridge STARS code, as well as for manipulating FGONG files (which MESA can produce).  These functions are available as the Python module `tomso`, which I thought I'd announced here before but couldn't find in the archives.

So I'm announcing the release of `tomso` v0.0.12, which can be installed from PyPI with `pip` and is documented at

     tomso.readthedocs.io

Existing users (there might be a handful!) should be aware that v0.0.12 defaults to the "new" object-oriented interface.  The old interface is still around but will emit warnings and eventually be dropped.  New users will also see benign warnings because the new interface still sometimes calls the old interface.

For MESA and GYRE, `tomso` might be overkill because their simple plain-text formats already lend themselves to loading with NumPy's `genfromtxt` function.  But I know that the forums are lurked by people using other codes and some of `tomso`'s extra wrapping might be useful even for MESA & GYRE users.

`tomso` presumes that filenames starting with `http` are URLs, so you can quickly plot Model S's sound speed gradient with respect to acoustic depth (as in Fig. 7.30 of Aerts, Christensen-Dalsgaard & Kurtz 2010) with:

     import matplotlib.pyplot as pl
     from tomso import fgong

     S = fgong.load_fgong('https://users-phys.au.dk/jcd/solar_models/fgong.l5bi.d.15c', G=6.67232e-8)
     pl.plot(S.tau, np.gradient(S.cs, S.tau)/1e4)
     pl.xlabel("τ (sec)")
     pl.ylabel("dc/dτ (10⁴ cm/s²)")
     pl.axis([100., 3000., 0., 2.5])

If you use MESA's `astero` module, there are also wrappers for its `output/sample_*.data` files.  Individual files and directories of such files can be read into objects that overload the base dict and list class to make it easier to access data across all the samples. e.g. to get the `chi^2 combined` entry for a full run, you could use

     from glob import glob
     from tomso import mesa

     samples = mesa.load_astero_samples(glob('outputs/samples_*.data'))
     print(samples['chi^2 combined'])

`tomso` also includes a command-line script which allows you to do some simple things from the command line.  This includes converting stellar model files between different formats used by oscillation codes. e.g. using Model S as an example FGONG file again,

     tomso convert https://users-phys.au.dk/jcd/solar_models/fgong.l5bi.d.15c -G 6.67232e-8 -f fgong -t amdl -o modelS.amdl

will save an ADIPLS-ready binary model to `modelS.amdl`.  (The FGONG to AMDL conversion follows ADIPLS's own `fgong-amdl.d` tool very closely.)

`tomso plot` basically supersedes the `qpmg` tool I shared a few years ago [1] and can be used for some simple plots of supporting files from the command line.  For anything vaguely complicated, though, you probably just want to use `tomso` as a library in your own plotting routines.

Cheers,
Warrick

[1] https://lists.mesastar.org/pipermail/mesa-users/2018-September/009360.html

____________

Warrick Ball
Postdoc, School of Physics and Astronomy
University of Birmingham, Edgbaston, Birmingham B15 2TT
W.H.Ball at bham.ac.uk
+44 (0)121 414 4552


More information about the Mesa-users mailing list