diff --git a/nrcatalogtools/catalog.py b/nrcatalogtools/catalog.py index c54c678..a1bea6e 100644 --- a/nrcatalogtools/catalog.py +++ b/nrcatalogtools/catalog.py @@ -82,6 +82,8 @@ def get(self, sim_name, quantity="waveform"): 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()) if quantity.lower() == "waveform": filepath = self.waveform_filepath_from_simname(sim_name) diff --git a/nrcatalogtools/waveform.py b/nrcatalogtools/waveform.py index eb04c2a..d9ebf17 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): # If _metadata is not already a set attribute, then set it here. try: - cls._metadata + cls._sim_metadata except AttributeError: - cls._metadata = metadata + cls._sim_metadata = metadata ell_min, ell_max = 99, -1 LM = [] @@ -164,7 +164,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" @@ -177,7 +176,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, @@ -361,17 +359,17 @@ 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): """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}\\_" @@ -402,7 +400,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 )