Skip to content
Snippets Groups Projects

bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties

Merged Soichiro Morisaki requested to merge soichiro/bilby:rapid_spline_cal into master
All threads resolved!

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)  
Edited by Soichiro Morisaki

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Colm Talbot
  • Soichiro Morisaki added 7 commits

    added 7 commits

    • 2c0f1e28...2140bcea - 6 commits from branch lscsoft:master
    • 872ee7aa - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties

    Compare with previous version

  • Gregory Ashton approved this merge request

    approved this merge request

  • Soichiro Morisaki added 9 commits

    added 9 commits

    • 872ee7aa...ba21731f - 8 commits from branch lscsoft:master
    • 8a289fd4 - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties

    Compare with previous version

  • Gregory Ashton approved this merge request

    approved this merge request

  • Soichiro Morisaki resolved all threads

    resolved all threads

  • added 1 commit

    • 0474f80e - bilby/gw/detector/calibration.py: optimize spline interpolation of calibration uncertainties

    Compare with previous version

  • Soichiro Morisaki resolved all threads

    resolved all threads

  • Colm Talbot approved this merge request

    approved this merge request

  • Soichiro Morisaki resolved all threads

    resolved all threads

  • Gregory Ashton approved this merge request

    approved this merge request

  • Gregory Ashton mentioned in commit f601ba08

    mentioned in commit f601ba08

  • merged

  • Colm Talbot picked the changes into the branch release/2.0.x with commit 5590075a

    picked the changes into the branch release/2.0.x with commit 5590075a

  • Gregory Ashton mentioned in commit 5590075a

    mentioned in commit 5590075a

  • Soichiro Morisaki mentioned in merge request !1219 (closed)

    mentioned in merge request !1219 (closed)

  • mentioned in issue #637 (closed)

  • Gregory Ashton mentioned in merge request !1242 (merged)

    mentioned in merge request !1242 (merged)

  • Gregory Ashton changed milestone to %2.1.0

    changed milestone to %2.1.0

  • Please register or sign in to reply
    Loading