Mesa#
- class astropy.io.ascii.Mesa(remove_restart_rows=True)[source]#
Bases:
BaseReaderMESA stellar evolution code output format.
MESA (Modules for Experiments in Stellar Astrophysics) is a widely-used one-dimensional stellar evolution code. This reader handles both history files (evolution over time) and profile files (spatial profiles at a single timestep). It does NOT handle model (.mod) files or output from associated packages like GYRE, adipls, or Stella.
The MESA format consists of:
Lines 0-2: Metadata section with column indices, names, and values
Line 3: Blank line
Line 4: Column indices for main data table
Line 5: Column names for main data table
Line 6+: Data rows (whitespace-delimited)
The metadata from lines 1-2 is stored in the table’s
meta['header']dictionary.For history files, this reader automatically detects and removes restart artifacts. When a MESA run is restarted from an earlier model, the history file will contain duplicate model numbers. This reader removes the earlier instances so that the resulting table has monotonically increasing model numbers suitable for analysis and plotting.
Example:
1 2 version_number compiler "r24.03.1" "gfortran" 1 2 3 model_number num_zones star_age 1 1004 1.00000000000E-05 2 1025 2.20000000000E-05
Example usage:
>>> from astropy.table import Table >>> from astropy.utils.data import get_pkg_data_filename >>> # Find the location of an example file included in astropy >>> mesa_file = get_pkg_data_filename('data/history_mesa.data', ... package='astropy.io.ascii.tests') >>> t = Table.read(mesa_file, format='ascii.mesa') >>> print(t.meta['header']['version_number']) r24.03.1 >>> t['model_number', 'star_age'][:3] <Table length=3> model_number star_age int64 float64 ------------ ---------------------- 1 1e-05 2 2.2e-05 3 3.6400000000000004e-05
Initialize MESA reader.
- Parameters:
- remove_restart_rowsbool, optional
If True (default), automatically remove restart artifacts from history files by detecting non-monotonic model numbers. Set to False to keep all rows including restart artifacts.
Methods Summary
read(table)Read input data into a Table and return the result.
Methods Documentation