Skip to main content

Python tools for NuGrid

Project description

Build Status PyPI version


NuGridPy is the NuGrid Python package providing tools to access and analyse (e.g. plot) various output formats (including the NuGrid hdf5-based se format) from NuGrid codes (mppnp and ppn) and from the MESA stellar evolution code using the NuGrid mesa_h5 MESA extension. In principle the NuGridPy package can be used on any stellar evolution code output if the NuGrid se libraries are used for output. The module will work with MESA ASCII output in the LOGS directory.

Using NuGridPy

The NuGridPy modules were written with an interactive work mode in mind, either

  • taking advantage of the interactive ipython session, or

  • inside a jupyter ipython notebooks. Once your session starts import modules, such as mesa, nugridse or ppn (depending on which type of data you are working with) from the NuGridPy package, for example:

from nugridpy import mesa as ms

Example session

A typical example session in a jupyter notebook that can be performed at the Web-Exploration of NuGrid Data Interactive (WENDI) server would look like this:

  1. Go to and sign-in with your github ID (sessions will be culled at regular intervals > a few hours, if you want to use this service beyond this trial period send a message to fherwig at

  2. Start a Python 3 ipython notebooks

  3. Load NuGridPy packages and initialise data source:

    # loading packages
    from nugridpy import nugridse as nuse
    from nugridpy import mesa
    #setting data path for mesa and nuse
    # data_dir='/data/nugrid_apod2/' # alternative data store
    # do ! ls /data/nug* to check for other alternative data stores
  4. Creating see and ppd instances

    # see: Stellar Evolution and Explosion data
    # ppd: Post-Processing Data,Z=0.02)
  5. Plot Hertzsprung-Russel diagram or Kippenhahn diagram

  6. Inquire doc string, plot abundance profiles from ppd data_dir

               linewidth=2,limits=[0.5882, 0.5889,-7.8, -3.2])
    m2z02_ppd.abu_profile(isos=species, ifig=ifig, fname=45500, logy=True, colourblind=True)
    title("Formation of the $^\mathsf{13}\mathsf{C}$ pocket: the partial H-$^\mathsf{12}\mathsf{C}$ zone")


Each module, class, function has (or should have!) reasonable doc strings in the modules. Read the docstring: help(ms), m2z02_see.plot?

The docstrings are also available on the Documentation web page.

If you have made tested and debugged improvements we are happy to know about them. Make a pull request on github. Such improvements include the documentation.

The tools provided here are useful to us, but of course there are still many things that need attention and improvement. Please add submit an issue on the github repo for ideas of improvements and to report bugs. Let us know if you want to help with these. Pull requests and new issues are most welcome!


There are several ways you can install NuGridPy.


Major release from PyPI:

pip install nugridpy

Release from github:

Sometimes you want to install a specific release. Go to the NuGridPy Release page and determine the tag of the release you want. If the tag is v0.7.2 install that release with pip using the following (you could choose something else for the egg name):

pip install -e git://

If you just want to install whatever the latest commit is on github using github you can do:

pip install git+


Especially for developing NuGridPy you may want to use pip but have more control of where the installation goes, to change the repo and commit back. In that case you can clone this repo, e.g.:

cd ; mkdir src; cd src
git clone

and point the PYTHONPATH variable to the NuGridPy repo directory.

Inside a jupyter notebook you can set the path the following way:

import sys

Required packages

All modules should work with the python distribution recommended NuGridDoc python distribution, with one additional package, the future package that needs to be installed additionally.

NuGridPy has the following python dependencies: numpy scipy matplotlib h5py xlrd future

For additional details on required packages, dependencies and manual installation please consult the Wiki.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NuGridpy-0.7.5.tar.gz (171.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page