From dedc55a8bddfeb7b2b2cefd56f41af10ff02b338 Mon Sep 17 00:00:00 2001 From: "Samson Leong (wkstn)" <55839002+SSL32081@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:26:06 +0800 Subject: [PATCH 1/4] Convert metadata to dict when possible. --- nrcatalogtools/catalog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nrcatalogtools/catalog.py b/nrcatalogtools/catalog.py index 8e755d8..6f850fb 100644 --- a/nrcatalogtools/catalog.py +++ b/nrcatalogtools/catalog.py @@ -69,6 +69,8 @@ def get(self, sim_name): metadata = self.get_metadata(sim_name) if type(metadata) is not dict and hasattr(metadata, "to_dict"): metadata = metadata.to_dict() + elif isinstance(metadata, dict): + metadata = dict(metadata.items()) return waveform.WaveformModes.load_from_h5(filepath, metadata=metadata) def get_metadata(self, sim_name): From f3c6aea984225d4c57744a1c440c90e61bf95853 Mon Sep 17 00:00:00 2001 From: "Samson Leong (wkstn)" <55839002+SSL32081@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:27:43 +0800 Subject: [PATCH 2/4] Distinguish metadata from sim_metadata. --- nrcatalogtools/waveform.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nrcatalogtools/waveform.py b/nrcatalogtools/waveform.py index aea483d..ca9c1f8 100644 --- a/nrcatalogtools/waveform.py +++ b/nrcatalogtools/waveform.py @@ -116,9 +116,9 @@ def load_from_h5(cls, file_path_or_open_file, metadata={}, verbosity=0): # it here. try: - cls._metadata + cls._sim_metadata except AttributeError: - cls._metadata = metadata + cls._sim_metadata = metadata ELL_MIN, ELL_MAX = 2, 10 ell_min, ell_max = 99, -1 @@ -165,7 +165,7 @@ def load_from_h5(cls, file_path_or_open_file, metadata={}, verbosity=0): data[:, idx] = amp_interp(times) * np.exp(1j * phase_interp(times)) w_attributes = {} - w_attributes["metadata"] = metadata + # w_attributes["metadata"] = metadata w_attributes["history"] = "" w_attributes["frame"] = quaternionic.array([[1.0, 0.0, 0.0, 0.0]]) w_attributes["frame_type"] = "inertial" @@ -202,12 +202,12 @@ def filepath(self): @property def sim_metadata(self): """Return the simulation metadata dictionary""" - return self._metadata["metadata"] + return self._sim_metadata @property def metadata(self): """Return the simulation metadata dictionary""" - return self.sim_metadata + return self._metadata @property def label(self): From 92570fd508c45a3588fe9f50a566223ffec40f77 Mon Sep 17 00:00:00 2001 From: "Samson Leong (wkstn)" <55839002+SSL32081@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:45:52 +0800 Subject: [PATCH 3/4] Correct reference to self.sim_metadata. --- nrcatalogtools/waveform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nrcatalogtools/waveform.py b/nrcatalogtools/waveform.py index ca9c1f8..428e1fc 100644 --- a/nrcatalogtools/waveform.py +++ b/nrcatalogtools/waveform.py @@ -212,7 +212,7 @@ def metadata(self): @property def label(self): """Return a Latex label that summarizes key simulation details""" - md = self.metadata + md = self.sim_metadata return ( f"$q{md['relaxed_mass_ratio_1_over_2']:0.3f}\\_" @@ -243,7 +243,7 @@ def get_parameters(self, total_mass=1.0): dict: Initial binary parameters with names compatible with PyCBC. """ - metadata = self.metadata + metadata = self.sim_metadata parameters = md.get_source_parameters_from_metadata( metadata, total_mass=total_mass ) From 2dc1d8f96cc731d817f5c2c15301b20ef9970c1c Mon Sep 17 00:00:00 2001 From: "Samson Leong (wkstn)" <55839002+SSL32081@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:59:55 +0800 Subject: [PATCH 4/4] Remove commented lines. --- nrcatalogtools/waveform.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nrcatalogtools/waveform.py b/nrcatalogtools/waveform.py index 428e1fc..85d2ec6 100644 --- a/nrcatalogtools/waveform.py +++ b/nrcatalogtools/waveform.py @@ -165,7 +165,6 @@ def load_from_h5(cls, file_path_or_open_file, metadata={}, verbosity=0): data[:, idx] = amp_interp(times) * np.exp(1j * phase_interp(times)) w_attributes = {} - # w_attributes["metadata"] = metadata w_attributes["history"] = "" w_attributes["frame"] = quaternionic.array([[1.0, 0.0, 0.0, 0.0]]) w_attributes["frame_type"] = "inertial" @@ -178,7 +177,6 @@ def load_from_h5(cls, file_path_or_open_file, metadata={}, verbosity=0): ) w_attributes["r_is_scaled_out"] = True w_attributes["m_is_scaled_out"] = True - # w_attributes["ells"] = ell_min, ell_max return cls( data,