From fe6857171f11217fdb3e15fd8f50479c11f521fb Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 31 Jul 2017 19:50:04 +0800 Subject: Add the new module `fg21sim.share` missing from the last commit! Signed-off-by: Aaron LI --- fg21sim/share.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 fg21sim/share.py (limited to 'fg21sim') diff --git a/fg21sim/share.py b/fg21sim/share.py new file mode 100644 index 0000000..a3b516b --- /dev/null +++ b/fg21sim/share.py @@ -0,0 +1,32 @@ +# Copyright (c) 2017 Weitian LI +# MIT license + +""" +Globally shared instances/objects shared throughout ``fg21sim``. + +NOTE: ``global`` and ``globals`` are both preserved by Python :-( +""" + +from .configs import ConfigManager +from .utils import Cosmology + + +# The globally shared `~ConfigManager` instance/object, that holds the +# default configurations as well as user-provided configurations. +# It may be imported by other modules to obtain the current effective +# configuration values, therefore greatly simplify the necessary parameters +# to be passed. +# +# NOTE: The entry script (e.g., `bin/fg21sim`) should load the user +# configurations into this global object by e.g.,: +# ``CONFIGS.read_userconfig()`` +CONFIGS = ConfigManager() + +# The globally shared `~Cosmology` instance/object may be used by other +# modules to calculate various cosmological quantities, and removes the +# need to pass the necessary/user cosmology parameters (e.g., H0, OmegaM0). +# +# NOTE: Once the above shared ``CONFIGS`` setup or loaded with new +# configurations, this ``COSMO`` object needs also been updated: +# ``COSMO.setup(**CONFIGS.cosmology)`` +COSMO = Cosmology() -- cgit v1.2.2