Skip to content

Commit

Permalink
MAINT: move cosmology to global meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-will committed Jan 7, 2025
1 parent fd80245 commit 7af179a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bilby/gw/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ class CompactBinaryCoalescenceResult(CoreResult):
"""
def __init__(self, **kwargs):

# Ensure cosmology is always stored in the meta_data
if "meta_data" not in kwargs:
kwargs["meta_data"] = dict()
if "cosmology" not in kwargs["meta_data"]:
if "global_meta_data" not in kwargs:
kwargs["meta_data"]["global_meta_data"] = dict()
# Ensure cosmology is always stored in the meta_data
if "cosmology" not in kwargs["meta_data"]["global_meta_data"]:
from .cosmology import get_cosmology
kwargs["meta_data"]["cosmology"] = get_cosmology()
kwargs["meta_data"]["global_meta_data"]["cosmology"] = get_cosmology()

super(CompactBinaryCoalescenceResult, self).__init__(**kwargs)

Expand Down Expand Up @@ -131,7 +133,9 @@ def cosmology(self):
.. versionadded:: 2.5.0
"""
return self.__get_from_nested_meta_data('cosmology')
return self.__get_from_nested_meta_data(
'global_meta_data', 'cosmology'
)

def detector_injection_properties(self, detector):
""" Returns a dictionary of the injection properties for each detector
Expand Down

0 comments on commit 7af179a

Please sign in to comment.