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
GYREStellarModel
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
-
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]¶ 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 fieldsRe(x)
becomeRex
. e.g.GYRELog['Refreq']
returns the Re(freq) column.This object will normally be instantiated using
gyre.load_summary()
orgyre.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.
GYREStellarModel
(header, data, G=6.6743e-08)[source]¶ A class that contains and allows one to manipulate the data stored a plain-text GYRE Stellar Model. This will usually be provided from a file by using
load_gyre()
but an object can be constructed from any similarly structured arrays.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
GYREStellarModel.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.
- 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
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
k (NumPy array) – mesh point number
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_file
(filename)[source]¶ Save the model to a file.
- Parameters
filename (str) – Filename to which the data is written.
-
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)