FGONG

Functions for manipulating FGONG files. These are provided through the FGONG object and a module function to read an FGONG object from a file.

tomso.fgong.load_fgong(filename, fmt='ivers', G=None)[source]

Given an FGONG file, returns a FGONG that contains NumPy arrays glob and var that correspond to the scalar and point-wise variables, as specified in the FGONG format.

Also returns the first four lines of the file as a comment, if desired. The data can be accessed via properties like x or P for fractional radius and pressure.

The version number ivers is used to infer the format of floats if fmt='ivers'.

Parameters:
  • filename (str) – Name of the FGONG file to read.

  • fmt (str, optional) – Format string for floats in glob and var. If 'ivers', uses %16.9E if the file’s ivers < 1000 or %26.18E3` if ``ivers >= 1000. If 'auto', tries to guess the size of each float. (default: 'ivers')

Returns:

f – The scalar (or global) variables for the stellar model

Return type:

FGONG

class tomso.fgong.FGONG(glob, var, ivers=300, G=None, description=['', '', '', ''])[source]

A class that contains and allows one to manipulate the data in a stellar model stored in the FGONG format.

The main attributes are the glob and var arrays, which follow the definitions in the FGONG standard. The data in these arrays can be accessed via the attributes with more physically-meaningful names (e.g. the radius is FGONG.r).

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 var array but setting x will assign the actual radius r, which is the first column of var. Values that are settable are indicated in the list of parameters.

Parameters:
  • glob (NumPy array) – The global variables for the stellar model.

  • var (NumPy array) – The point-wise variables for the stellar model. i.e. things that vary through the star like temperature, density, etc.

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

  • G (float, optional) – Value for the gravitational constant. If not given (which is the default behaviour), we use glob[14] if it exists and is close to the module-wide default value. Otherwise, we use the module-wide default value.

  • description (list of 4 strs, optional) – The first four lines of the FGONG file, which usually contain notes about the stellar model.

Variables:
  • iconst (int) – number of global data entries (i.e. length of glob)

  • nn (int) – number of points in stellar model (i.e. number of rows in var)

  • ivar (int) – number of variables recorded at each point in stellar model (i.e. number of columns in var)

  • 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

  • lnq (NumPy array, settable) – natural logarithm of the fractional mass co-ordinate

  • T (NumPy array, settable) – temperature

  • P (NumPy array, settable) – pressure

  • rho (NumPy array, settable) – density

  • X (NumPy array, settable) – fractional hydrogen abundance (by mass)

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

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

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

  • Gamma_1 (NumPy array, settable) – first adiabatic index, aliased by G1

  • G1 (NumPy array, settable) – first adiabatic index, alias of Gamma_1

  • cp (NumPy array, settable) – specific heat capacity

  • AA (NumPy array, settable) – Ledoux discriminant

  • Z (NumPy array, settable) – metal abundance

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

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

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

  • 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, float_formatter='ivers')[source]

Save the model to an FGONG file.

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

  • float_formatter (str or function) – Determines how floating point numbers are formatted. If 'ivers' (the default), use the standard formats %16.9E if ivers < 1000 or %26.18E3 if ivers >= 1000. If a Python format specifier (e.g. '%16.9E'), pass floats into that like float_formatter % float. Otherwise, must be a function that takes a float as an argument and returns a string. In most circumstances you’ll want to control the output by changing the value of 'ivers'.

to_amdl()[source]

Convert the model to an ADIPLSStellarModel object.

The output should be identical (to within a few times machine error) to the output of fgong-amdl.d tool distributed with ADIPLS.

to_gyre(version=None)[source]

Convert the model to a PlainGYREStellarModel object.

Parameters:

version (int, optional) – Specify GYRE format version number times 100. i.e., version=101 produces a file with data version 1.01. If None (the default), the latest version available in TOMSO is used.