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: diff --git a/ringdown/fit.py b/ringdown/fit.py index 17e7ee91..3a067fb7 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 or {}) ) imr = fit.imr_result diff --git a/ringdown/imr.py b/ringdown/imr.py index f4066228..f96185c0 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 @@ -1169,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}) @@ -1205,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: 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