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/Science/pynbody/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]:
{'verbose': False,
'centering-scheme': 'ssc',
'snap-class-priority': [pynbody.snapshot.ramses.RamsesSnap,
pynbody.snapshot.grafic.GrafICSnap,
pynbody.snapshot.nchilada.NchiladaSnap,
pynbody.snapshot.gadget.GadgetSnap,
pynbody.snapshot.gadgethdf.EagleLikeHDFSnap,
pynbody.snapshot.gadgethdf.GadgetHDFSnap,
pynbody.snapshot.gadgethdf.SubFindHDFSnap,
pynbody.snapshot.tipsy.TipsySnap,
pynbody.snapshot.ascii.AsciiSnap],
'halo-class-priority': [pynbody.halo.GrpCatalogue,
pynbody.halo.AmigaGrpCatalogue,
pynbody.halo.legacy.RockstarIntermediateCatalogue,
pynbody.halo.rockstar.RockstarCatalogue,
pynbody.halo.ahf.AHFCatalogue,
pynbody.halo.subfind.SubfindCatalogue,
pynbody.halo.hop.HOPCatalogue,
pynbody.halo.adaptahop.AdaptaHOPCatalogue],
'default-cosmology': {'a': 1.0,
'h': 0.6777,
'ns': 0.96,
'running': 0.0,
'omegaL0': 0.691,
'omegaM0': 0.309,
'omegaB0': 0.0482,
'sigma8': 0.8288},
'sph': {'smooth-particles': 32, 'tree-leafsize': 16},
'threading': 'True',
'number_of_threads': 8,
'gravity_calculation_mode': 'direct_omp',
'disk-fit-function': 'expsech'}
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