Wiki

Clone wiki

gyre / Python Support

To facilitate processing GYRE HDF-format output files with the Python scripting language, the pygyre package is provided in the GYRE_DIR/python subdirectory.

Installation

To build pygyre use the following steps:

cd GYRE_DIR/python
tar xvf pygyre.tar.gz
cd pygyre
python setup.py build	
sudo python setup.py install

or, as most Python users prefer, via pip:

$:> python setup.py sdist
$:> sudo pip install dist/gyre-0.0.tar.gz

In both cases, the gyre package is added to the local packages, so one can immediately do "import gyre" from whatever directory. In the latter case (with pip), also an executable "gyre2ascii" is added to the "/usr/local/bin" or whatever, so that people could simply do::

$:> gyre2ascii *.h5 myoutput.txt

from whatever directory. Also, pip keeps track of installed packages, so you could also simply do:

$:> sudo pip uninstall gyre

to completely remove every trace of it.



the <<src python/gyre.tar.gz stable>> module provides a number of useful routines. This module relies on the following Python packages:

* [[http://www.numpy.org|NumPy]]
* [[http://www.h5py.org|h5py]]

The routines provided by gyre.py are described below.

== Reading Summary & Mode Files ==

Both summary and mode files can be read using the ##gyre.read_output## routine, which is used in the following way:

{{{
import gyre
scalars,arrays = gyre.read_output('summary.h5')

This reads the data in the summary file summary.h5, and returns the scalar information as a dictionary, and array information as a numpy record array. The keys of this dictionary and column names in the record array correspond to the attributes and datasets of the file, defined on the Output Files page.

For eigenvalue files, there is no scalar information so scalars will be empty.

For eigenfunction files, the global information on the star or mode is stored in scalars, the eigenfunctions themselves in the arrays variable.

The script als works as a terminal tool, if you supply an output file as the sole argument:

$:> python gyre.py summary.h5

The contents of the file will be printed in a terminal. Note that this only works if you have matplotlib installed.

Please refer to the script's source code documentation for more information.

Updated