From 8bc9d384015f17dc419cfd4398ed5e9aea4df1fc Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 10:06:18 -0400 Subject: [PATCH 1/7] linear interp, n in freq grid --- ringdown/data.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ringdown/data.py b/ringdown/data.py index 6841ed9d..c7184c1d 100644 --- a/ringdown/data.py +++ b/ringdown/data.py @@ -234,7 +234,7 @@ def load(cls, path: str | None = None, channel: str | None = None, **kws): ts.attrs.update(dict(load=info)) return ts - _DEF_INTERP_KWS = dict(kind='cubic', fill_value=0, bounds_error=False) + _DEF_INTERP_KWS = dict(kind='linear', fill_value=0, bounds_error=False) def interpolate_to_index(self, new_index, **kwargs): """Reinterpolate the :class:`Series` to new index. @@ -462,7 +462,8 @@ def interpolate_to_index(self, freq: np.ndarray | None = None, f_min = f_min_orig if f_min is None else f_min f_max = f_max_orig if f_max is None else f_max delta_f = delta_f or self.delta_f - n = int((f_max - f_min) / delta_f) + 1 + # n = int((f_max - f_min) / delta_f) + 1 + n = len(self.freq) freq = np.arange(n)*delta_f + f_min if min(freq) < f_min_orig or max(freq) > f_max_orig: From 7fb85dd44c89c25ee702bad9edbc52bfdbb9015e Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 10:32:46 -0400 Subject: [PATCH 2/7] imr_kws in from_imr_result to pass group for IMRResult const --- ringdown/fit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ringdown/fit.py b/ringdown/fit.py index 17e7ee91..803c09bb 100644 --- a/ringdown/fit.py +++ b/ringdown/fit.py @@ -1911,6 +1911,7 @@ def from_imr_result( set_target: bool = True, update_model: bool = True, duration: float | bool = "auto", + imr_kws: dict | None = None, data_kws: dict | None = None, peak_kws: dict | None = None, acf_kws: dict | None = None, @@ -1932,6 +1933,7 @@ def from_imr_result( approximant=approximant, reference_frequency=reference_frequency, psds=psds, + **imr_kws ) imr = fit.imr_result From 9ee19b791539446176012de1b65714332512ff38 Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 10:34:42 -0400 Subject: [PATCH 3/7] remove persisting chars in i.e. min freq dict --- ringdown/utils/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ringdown/utils/utils.py b/ringdown/utils/utils.py index 9df220cd..4e59c274 100644 --- a/ringdown/utils/utils.py +++ b/ringdown/utils/utils.py @@ -373,8 +373,8 @@ def get_bilby_dict(d): """Parse bilby-style data dict string. """ if isinstance(d, str): - chars_to_remove = "'{}" + chars_to_remove = " '{}" translation_table = str.maketrans('', '', chars_to_remove) d = {k.translate(translation_table): v.translate(translation_table) - for k, v in [i.split(':') for i in d.split(',')]} + for k, v in [i.split(':') for i in d.split(',') if ':' in i] } return d From 785e12688087c687f7bc6133846dbb1fefe185de Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 10:36:59 -0400 Subject: [PATCH 4/7] fix extra ' in ifos, set_psds after from_pesummary, f_min=f_start when f_ref too low --- ringdown/imr.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ringdown/imr.py b/ringdown/imr.py index f4066228..a8ca0940 100644 --- a/ringdown/imr.py +++ b/ringdown/imr.py @@ -446,7 +446,8 @@ def ifos(self): """List of detectors in the DataFrame.""" # try config first if "detectors" in self.attrs.get("config", {}): - return self.attrs["config"]["detectors"] + return [k.replace("'", "") for k in self.attrs["config"]['detectors']] + # return self.attrs["config"]['detectors'] time_keys = [k for k in self.columns if TIME_KEY in k] return [k.replace(TIME_KEY, "") for k in time_keys] @@ -803,9 +804,15 @@ def get_waveforms( logger.warning("time arrays have inconsistent lengths") for _, sample in tqdm(df.iterrows(), **tqdm_kws): - h = waveforms.get_detector_signals( - times=time, ifos=ifos, **sample, **kws + if np.array([self.reference_frequency < self.minimum_frequency[ifo] for ifo in ifos]).any(): + h = waveforms.get_detector_signals( + times=time, ifos=ifos, f_low=self.minimum_frequency['waveform'], + **sample, **kws ) + else: + h = waveforms.get_detector_signals( + times=time, ifos=ifos, **sample, **kws + ) for ifo in ifos: if condition: # look for target time 't0' which can be a dict with @@ -1600,6 +1607,7 @@ def construct( path = os.path.abspath(path) r.attrs["path"] = path r.attrs.update(attrs) + r.set_psds(r.psds) else: r = cls(path, attrs=attrs, **kws) if psds is not None: From 903cfe10dc795f237e270634a0f1c1695d3b98b7 Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 12:43:53 -0400 Subject: [PATCH 5/7] interp psd in from_pesummary --- ringdown/imr.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ringdown/imr.py b/ringdown/imr.py index a8ca0940..f96185c0 100644 --- a/ringdown/imr.py +++ b/ringdown/imr.py @@ -1176,7 +1176,7 @@ def from_pesummary( logger.info(f"no group provided; using {group}") config = pe.config.get(group, {}).get("config", {}) p = { - i: data.PowerSpectrum(p).fill_low_frequencies().gate() + i: data.PowerSpectrum(p).fill_low_frequencies().gate().interpolate_to_index() for i, p in pe.psd.get(group, {}).items() } attrs = (attrs or {}).update({"config": config}) @@ -1212,7 +1212,7 @@ def from_pesummary( ) if "psds" in f[group]: p = { - i: data.PowerSpectrum(p).fill_low_frequencies().gate() + i: data.PowerSpectrum(p).fill_low_frequencies().gate().interpolate_to_index() for i, p in f[group]["psds"].items() } else: @@ -1607,7 +1607,6 @@ def construct( path = os.path.abspath(path) r.attrs["path"] = path r.attrs.update(attrs) - r.set_psds(r.psds) else: r = cls(path, attrs=attrs, **kws) if psds is not None: From 9228246ad7bb2bd619da96be34f06c806e9e6bc1 Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 13:36:38 -0400 Subject: [PATCH 6/7] bug fix for **imr_kws --- ringdown/fit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ringdown/fit.py b/ringdown/fit.py index 803c09bb..3a067fb7 100644 --- a/ringdown/fit.py +++ b/ringdown/fit.py @@ -1933,7 +1933,7 @@ def from_imr_result( approximant=approximant, reference_frequency=reference_frequency, psds=psds, - **imr_kws + **(imr_kws or {}) ) imr = fit.imr_result From c1a9b8fbf8a15cfc156d5a9643e581390a50a775 Mon Sep 17 00:00:00 2001 From: Nicole Khusid Date: Tue, 23 Sep 2025 19:01:27 -0400 Subject: [PATCH 7/7] Trigger CI