Example Walkthrough

This chapter walks through a number of typical PyGYEE use-cases.

Reading GYRE Output

PyGYRE’s most important capability is reading the summary and detail files created by GYRE. Assuming you’re in the working directory you created for the GYRE example walkthrough, this illustrates how you can read and inspect the summary file using the pygyre.read_output() function:

import pygyre
import numpy

# Read data from the summary file

s = pygyre.read_output('summary.h5')

# Print the table metadata and contents

print(s.meta)
print(s)

In this example, s is a astropy.table.Table instance, and therefore supports a rich set of data analysis and processing operations. For instance,

# Print only the rows for modes with harmonic degree l = 2

print(s[s['l'] == 1])

# Print the indices of the mode with the largest inertia

i = numpy.argmax(s['E_norm'])

print(s[('l','n_pg')][i])

The same pygyre.read_output() function can also be used to read detail files:

# Read data from one of the detail files

d = pygyre.read_output('detail.l1.n-5.h5')

# Print the table metadata and contents

print(d.meta)
print(d)

Reading Stellar Models

PyGYRE can read stellar models the MESA, GSM and POLY formats. Again assuming that you’re in the working directory for the GYRE example walkthrough, here’s how you can read the model file for the \(5\,{\rm M_{\odot}}\) slowly pulsating B star:

import pygyre

# Read data from the model file

m = pygyre.read_model('spb.mesa')

# Print the table metadata and contents

print(m.meta)
print(m)