Pynbody Tutorials#

Here you will find tutorials that illustrate the use of pynbody. The Walkthroughs demonstrate pynbody functionality through an interactive session in the ipython shell that you can follow along using either one of the outputs from the bundled test-data or one of your own simulations. To complement the walkthroughs, we also provide a quick-start Jupyter notebook. The Cookbook/Recipes tutorials are more goal-oriented: they provide a script that can be used with only minor modifications to immediately produce a result (i.e. make an image). They also include, however, a somewhat more involved discussion of more advanced options and common pitfalls. Finally, the Advanced topics section is meant to provide a more in-depth look at the inner-workings of the code.

Obtaining test data#

Many of the tutorials below use the same dataset that pynbody is tested on. While they are easily adapted for your own data, you can also download and unpack the test data to replicate the examples exactly. To do this, you can either manually download the tarballs from zenodo and unpack them to a directory of your choice, or automatically download using pynbody’s built-in testdata downloader:

import pynbody.test_utils
pynbody.test_utils.precache_test_data()

Note that pynbody automatically creates a folder called testdata in this case, and the tutorials assume that you have put the data in this folder.

Walkthroughs#

Cookbook/Recipes#

Advanced topics#