Configuring pynbodyΒΆ

Pynbody uses a flexible configuration system through the standard Python ConfigParser class. The default configuration is stored in default_config.ini in the pynbody installation directory. The options can be overriden by placing a .pynbodyrc file in the home directory and specifying different values for configuration parameters. The configuration file sets up basic things like particle family names, whether to use mutlithreading, default base units etc.

To find default_config.ini, you can type

In [1]: import pynbody

In [2]: pynbody.__path__
Out[2]: ['/Users/app/anaconda/lib/python2.7/site-packages/pynbody']

to find the pynbody installation directory. The default_config.ini can be found there. Most of the options are explained in the file itself, and in order to use a different default, you simply override the option in .pynbodyrc. For example, if I want to reduce the number of CPU cores that pynbody uses, I would put in .pynbodyrc:

[general]

number_of_threads: 2

For more information on threading, see threading.

Some options can also be changed at runtime. You can check which ones with

In [3]: pynbody.config
Out[3]: 
{'centering-scheme': 'ssc',
 'default-cosmology': {'a': 1.0,
  'h': 0.6777,
  'ns': 0.96,
  'omegaB0': 0.0482,
  'omegaL0': 0.691,
  'omegaM0': 0.309,
  'running': 0.0,
  'sigma8': 0.8288},
 'disk-fit-function': 'expsech',
 'gravity_calculation_mode': 'direct_omp',
 'halo-class-priority': [pynbody.halo.GrpCatalogue,
  pynbody.halo.AmigaGrpCatalogue,
  pynbody.halo.RockstarIntermediateCatalogue,
  pynbody.halo.RockstarCatalogue,
  pynbody.halo.AHFCatalogue,
  pynbody.halo.SubfindCatalogue],
 'number_of_threads': 4,
 'snap-class-priority': [pynbody.snapshot.ramses.RamsesSnap,
  pynbody.snapshot.grafic.GrafICSnap,
  pynbody.snapshot.nchilada.NchiladaSnap,
  pynbody.snapshot.gadget.GadgetSnap,
  pynbody.snapshot.gadgethdf.GadgetHDFSnap,
  pynbody.snapshot.gadgethdf.SubFindHDFSnap,
  pynbody.snapshot.tipsy.TipsySnap,
  pynbody.snapshot.ascii.AsciiSnap],
 'sph': {'smooth-particles': 32, 'tree-leafsize': 16},
 'threading': 'True',
 'verbose': False}

If you wanted to, for example, change how many particles are being used to estimate sph kernel quantities, you could do

In [4]: pynbody.config['sph']['smooth-particles'] = 64