Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Convert LALDict to python dictionary before saving #825

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bilby/core/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,18 @@ def _get_save_data_dictionary(self):
for attr in save_attrs:
try:
dictionary[attr] = getattr(self, attr)
if (attr == "meta_data") and (
"lal_waveform_dictionary"
in dictionary[attr]["likelihood"]["waveform_arguments"]["lal_waveform_dictionary"]
):
from ..gw.utils import gwsignal_from_lal_dict

dictionary[attr]["likelihood"]["waveform_arguments"][
"lal_waveform_dictionary"
] = gwsignal_from_lal_dict(
dictionary[attr]["likelihood"]["waveform_arguments"]["lal_waveform_dictionary"]
)

except ValueError as e:
logger.debug("Unable to save {}, message: {}".format(attr, e))
pass
Expand Down
19 changes: 19 additions & 0 deletions bilby/gw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,3 +1073,22 @@ def calculate_time_to_merger(frequency, mass_1, mass_2, chi=0, safety=1.1):
chi,
-1
)


def gwsignal_from_lal_dict(ldict):
"""
Convert LALDict object to a Python dictionary

Parameters
==========
ldict: LALDict
LALDict object

Returns
=======
d: dict
Python dictionary
"""
from lalsimulation.gwsignal.core.utils import from_lal_dict

return from_lal_dict(ldict)
Loading