Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
f7defcf4
Commit
f7defcf4
authored
6 years ago
by
Colm Talbot
Browse files
Options
Downloads
Patches
Plain Diff
add cubic spline calibration model
parent
d6d87c02
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!113
Add calibration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tupak/gw/calibration.py
+109
-0
109 additions, 0 deletions
tupak/gw/calibration.py
with
109 additions
and
0 deletions
tupak/gw/calibration.py
0 → 100644
+
109
−
0
View file @
f7defcf4
"""
Functions for adding calibration factors to waveform templates.
"""
import
numpy
as
np
from
scipy.interpolate
import
UnivariateSpline
class
Recalibrate
(
object
):
name
=
'
none
'
def
__init__
(
self
,
prefix
=
'
recalib_
'
):
"""
Base calibration object. This applies no transformation
Parameters
----------
prefix: str
Prefix on parameters relating to the calibration.
"""
self
.
params
=
dict
()
self
.
prefix
=
prefix
pass
def
get_calibration_factor
(
self
,
frequency_array
,
**
params
):
"""
Apply calibration model
This method should be overwritten by subclasses
Parameters
----------
frequency_array: array
The frequency values to calculate the calibration factor for.
params : dict
Dictionary of sampling parameters which includes
calibration parameters.
Returns
-------
calibration_factor : array
The factor to multiply the strain by.
"""
self
.
set_calibration_parameters
(
**
params
)
return
np
.
ones_like
(
frequency_array
)
def
set_calibration_parameters
(
self
,
**
params
):
self
.
params
.
update
({
key
[
len
(
self
.
prefix
):]:
params
[
key
]
for
key
in
params
if
self
.
prefix
in
key
})
class
CubicSpline
(
Recalibrate
):
name
=
'
cubic_spline
'
def
__init__
(
self
,
prefix
,
minimum_frequency
,
maximum_frequency
,
n_points
):
"""
Cubic spline recalibration
see https://dcc.ligo.org/DocDB/0116/T1400682/001/calnote.pdf
This assumes the spline points follow
np.logspace(np.log(minimum_frequency), np.log(maximum_frequency), n_points)
Parameters
----------
prefix: str
Prefix on parameters relating to the calibration.
minimum_frequency: float
minimum frequency of spline points
maximum_frequency: float
maximum frequency of spline points
n_points: int
number of spline points
"""
Recalibrate
.
__init__
(
self
,
prefix
=
prefix
)
self
.
n_points
=
n_points
self
.
spline_points
=
np
.
logspace
(
np
.
log
(
minimum_frequency
),
np
.
log
(
maximum_frequency
),
n_points
)
def
get_calibration_factor
(
self
,
frequency_array
,
**
params
):
"""
Apply calibration model
Parameters
----------
frequency_array: array
The frequency values to calculate the calibration factor for.
prefix: str
Prefix for calibration parameter names
params : dict
Dictionary of sampling parameters which includes
calibration parameters.
Returns
-------
calibration_factor : array
The factor to multiply the strain by.
"""
self
.
set_calibration_parameters
(
**
params
)
amplitude_parameters
=
[
self
.
params
[
'
amplitude_{}
'
.
format
(
ii
)]
for
ii
in
range
(
self
.
n_points
)]
amplitude_spline
=
UnivariateSpline
(
self
.
spline_points
,
amplitude_parameters
)
delta_amplitude
=
amplitude_spline
(
frequency_array
)
phase_parameters
=
[
self
.
params
[
'
phase_{}
'
.
format
(
ii
)]
for
ii
in
range
(
self
.
n_points
)]
phase_spline
=
UnivariateSpline
(
self
.
spline_points
,
phase_parameters
)
delta_phase
=
phase_spline
(
frequency_array
)
calibration_factor
=
(
1
+
delta_amplitude
)
*
(
2
+
1j
*
delta_phase
)
/
(
2
-
1j
*
delta_phase
)
return
calibration_factor
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment