GYRE

Functions for manipulating GYRE input and output files.

tomso.gyre.load_summary(filename)[source]

Reads a GYRE summary file and returns the global data and mode data in a dict-like GYRELog object. Uses builtin gzip module to read files ending with .gz.

Parameters:

filename (str) – Filename of the GYRE summary file to load.

Returns:

summary

Return type:

GYRELog object

tomso.gyre.load_mode(filename)[source]

Reads a GYRE mode file and returns the global data and mode profile data a dict-like GYRELog object. Uses builtin gzip module to read files ending with .gz.

Parameters:

filename (str) – Filename of the GYRE mode file to load.

Returns:

mode

Return type:

GYRELog object

tomso.gyre.load_gyre(filename)[source]

Reads a GYRE stellar model file and returns the global data and point-wise data in a PlainGYREStellarModel object. Uses builtin gzip module to read files ending with .gz.

Parameters:

filename (str) – Filename of the GYRE file.

Returns:

model – Dict-like access to global and profile data.

Return type:

PlainGYREStellarModel

tomso.gyre.load_gsm(filename)[source]

Reads a GSM file and returns the global data and point-wise data in a HDF5GYREStellarModel object. Uses the h5py module.

Parameters:

filename (str) – Filename of the GSM file.

Returns:

model – Dict-like access to global and profile data.

Return type:

HDF5GYREStellarModel

tomso.gyre.save_gyre(filename, header, data)[source]

Given the global data and point-wise data for a stellar model (as returned by load_gyre()), saves the data to a target file in the GYRE format.

Parameters:
  • filename (str) – Filename of the GYRE file.

  • header (structured array) – Global data for the stellar model. e.g. total mass, luminosity.

  • data (structured array) – Profile data for the stellar model. e.g. radius, pressure.

class tomso.gyre.GYRELog(header, data)[source]

Bases: object

A dict-like class that contains the data for a GYRE summary or mode file. Variables in the header or the body can be accessed by the appropriate key, as interpreted by numpy.genfromtxt, so the fields Re(x) become Rex. e.g. GYRELog['Refreq'] returns the Re(freq) column.

This object will normally be instantiated using gyre.load_summary() or gyre.load_mode().

Parameters:
  • header (structured array) – Header data for the GYRE summary or mode file. i.e. data for which there is only one value in the file.

  • data (structured array) – Columned data for the summary or mode file. i.e. data for which there are multiple values (one per timestep or mesh point).

class tomso.gyre.AbstractGYREStellarModel[source]

Bases: FullStellarModel

A class that contains and allows one to manipulate the data stored a plain-text or HDF5 GYRE Stellar Model. This will usually be provided from a file by using load_gyre() or load_gsm(), constructing a PlainGYREStellarModel or HDF5GYREStellarModel respectively.

The main attributes are the header and data record arrays, which store the data that’s written in the text file. The data in these arrays can be accessed via the attributes with more physically-meaningful names (e.g. the speed of sound is AbstractGYREStellarModel.cs).

Some of these values can also be set via the attributes if doing so is unambiguous. For example, the fractional radius x is not a member of the data array but setting x will assign the actual radius r to the corresponding values. Values that are settable are indicated in the list of parameters.

Variables:
  • version (int) – file version number

  • M (float, settable) – total mass

  • R (float, settable) – photospheric radius

  • L (float, settable) – total luminosity

  • Teff (float) – effective temperature, derived from luminosity and radius

  • r (NumPy array, settable) – radius co-ordinate

  • T (NumPy array, settable) – temperature

  • P (NumPy array, settable) – pressure

  • rho (NumPy array, settable) – density

  • L_r (NumPy array, settable) – luminosity at radius r

  • kappa (NumPy array, settable) – Rosseland mean opacity

  • eps (NumPy array, settable) – specific energy generation rate

  • Gamma_1 (NumPy array) – first adiabatic index

  • AA (NumPy array) – Ledoux discriminant

  • x (NumPy array, settable) – fractional radius co-ordinate

  • q (NumPy array, settable) – fractional mass co-ordinate

  • m (NumPy array, settable) – mass co-ordinate

  • w (NumPy array) – former fractional mass depth (w=m/(M-m))

  • g (NumPy array) – local gravitational acceleration

  • Hp (NumPy array) – pressure scale height

  • Hrho (NumPy array) – density scale height

  • N2 (NumPy array) – squared Brunt–Väisälä (angular) frequency

  • cs2 (NumPy array) – squared adiabatic sound speed

  • cs (NumPy array) – adiabatic sound speed

  • U (NumPy array) – homology invariant dlnm/dlnr

  • V (NumPy array) – homology invariant dlnP/dlnr

  • Vg (NumPy array) – homology invariant V/Gamma_1

  • tau (NumPy array) – acoustic depth

to_fgong(reverse=True, ivers=1300)[source]

Convert the model to an FGONG object.

Parameters:
  • reverse (bool, optional) – If True (the default), store the FGONG data ordered from the surface to the centre. Otherwise, store the FGONG data ordered from the centre to the surface.

  • ivers (int, optional) – The integer indicating the version number of the file. (default=1300)

to_amdl()[source]

Convert the model to an ADIPLSStellarModel object.

to_plain(filename)[source]

Save the model to a plain text GYRE stellar model.

Parameters:

filename (str) – Filename to which the data is written.

to_gsm(filename)[source]

Save the model to an HDF5 GYRE stellar model.

Parameters:

filename (str) – Filename to which the data is written.

class tomso.gyre.PlainGYREStellarModel(header, data, G=6.6743e-08)[source]

Bases: AbstractGYREStellarModel

GYRE stellar model constructed from a plain text file. This can also be constructed from similarly structured arrays.

Parameters:
  • header (structured array) – Global data for the stellar model. e.g. total mass, luminosity.

  • data (structured array) – Profile data for the stellar model. e.g. radius, pressure.

  • G (float, optional) – Value for the gravitational constant, in cgs units. If not given (which is the default behaviour), we use the module-wise default value.

Variables:

k (NumPy array) – mesh point number

to_plain(filename)[source]

Save the model to a plain text GYRE stellar model.

Parameters:

filename (str) – Filename to which the data is written.

to_gsm(filename)[source]

Save the model to an HDF5 GYRE stellar model.

Parameters:

filename (str) – Filename to which the data is written.

class tomso.gyre.HDF5GYREStellarModel(hdf5_file, G=6.6743e-08)[source]

Bases: AbstractGYREStellarModel

GYRE stellar model constructed from an HDF5 file.

Parameters:
  • hdf5_file (h5py.File) – HDF5 file object containing the stellar model

  • G (float, optional) – Value for the gravitational constant, in cgs units. If not given (which is the default behaviour), we use the module-wise default value.

to_plain(filename)[source]

Save the model to a plain text GYRE stellar model.

Parameters:

filename (str) – Filename to which the data is written.

to_gsm(filename)[source]

Save the model to an HDF5 GYRE stellar model.

Parameters:

filename (str) – Filename to which the data is written.