bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties
Optimize spline interpolation of calibration uncertainties utilizing formula applicable when spline nodes are evenly spaced. This is similar to the improvement made for ROQ weights in !971 (merged).
Below is a test script used for testing this change:
from bilby.gw.detector.calibration import CubicSpline
import numpy as np
n_points = 10
flow, fhigh = 20., 2048.
prefix = "recalib_H1_"
frequencies = np.linspace(flow, fhigh, 100)
parameters = {}
for i in range(n_points):
parameters[f"{prefix}amplitude_{i}"] = np.random.uniform(-0.1, 0.1)
parameters[f"{prefix}phase_{i}"] = np.random.uniform(-0.1 * np.pi, 0.1 * np.pi)
calobj1 = CubicSpline(prefix, flow, fhigh, n_points)
calobj2 = CubicSplineNew(prefix, flow, fhigh, n_points)
Below are results:
In:
np.max(np.abs(
calobj1.get_calibration_factor(frequencies, **parameters) -
calobj2.get_calibration_factor(frequencies, **parameters)
))
Out:
3.619316683849706e-15
In:
%%timeit -n 100
calobj1.get_calibration_factor(frequencies, **parameters)
Out:
585 µs ± 106 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In:
%%timeit -n 100
calobj2.get_calibration_factor(frequencies, **parameters)
Out:
101 µs ± 23.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Merge request reports
Activity
added 1 commit
- 2c0f1e28 - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties
In the current implementation, the calibration uncertainties are extrapolated if frequency outside the frequency range is requested (as done by !1219 (closed)). It is not difficult to fill vanishing errors there if preferred.
Edited by Soichiro MorisakiHi @colm.talbot @gregory.ashton, is there any chance that this MR can be included for O4? It reduces the online-BNS-PE run time by ~30%, as shown in this review test https://git.ligo.org/pe/O4/online_pe_review/-/wikis/Online-Bilby#bns-p-p-tests.
changed milestone to %2.0.3
- Automatically resolved by Soichiro Morisaki
- Automatically resolved by Soichiro Morisaki
added 10-100 lines label
added 7 commits
-
2c0f1e28...2140bcea - 6 commits from branch
lscsoft:master
- 872ee7aa - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties
-
2c0f1e28...2140bcea - 6 commits from branch
added 9 commits
-
872ee7aa...ba21731f - 8 commits from branch
lscsoft:master
- 8a289fd4 - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties
-
872ee7aa...ba21731f - 8 commits from branch
added 1 commit
- 0474f80e - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties
mentioned in commit f601ba08
picked the changes into the branch
release/2.0.x
with commit 5590075amentioned in commit 5590075a
mentioned in merge request !1219 (closed)
mentioned in issue #637 (closed)
mentioned in merge request !1242 (merged)
changed milestone to %2.1.0