aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/share.py
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-07-31 19:50:04 +0800
committerAaron LI <aly@aaronly.me>2017-07-31 19:50:04 +0800
commitfe6857171f11217fdb3e15fd8f50479c11f521fb (patch)
treeaad184260038773fe94f7714db64f513d90065e9 /fg21sim/share.py
parent38ab63fc5191a4893f6f46d9b8b40ae988f66c88 (diff)
downloadfg21sim-fe6857171f11217fdb3e15fd8f50479c11f521fb.tar.bz2
Add the new module `fg21sim.share` missing from the last commit!
Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/share.py')
-rw-r--r--fg21sim/share.py32
1 files changed, 32 insertions, 0 deletions
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 <weitian@aaronly.me>
+# 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(<user_config_file>)``
+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()