Skip to content

Commit

Permalink
Merge branch 'master' of git.ligo.org:daniel-williams/minke
Browse files Browse the repository at this point in the history
  • Loading branch information
transientlunatic committed Mar 27, 2018
2 parents 0c05140 + 9e577a6 commit 726d988
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions minke/mdctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def source_from_row(row):
"ga" : lsctables.SimBurstTable,
"sg" : lsctables.SimBurstTable,
"wnb" : lsctables.SimBurstTable,
"sc" : lsctables.SimBurstTable,
# Supernova Families
"d08" : lsctables.SimBurstTable,
"s10" : lsctables.SimBurstTable,
Expand Down Expand Up @@ -120,6 +121,7 @@ class MDCSet():
inj_families_names = {'ga' : 'Gaussian',
'sg' : 'SineGaussian',
'wnb': 'BTLWNB',
"sc" : "StringCusp",
# Supernova families
'd08' : 'Dimmelmeier+08',
's10' : 'Scheidegger+10',
Expand All @@ -135,6 +137,7 @@ class MDCSet():
inj_families_abb = dict((v,k) for k,v in inj_families_names.iteritems())

hist_parameters = {
"StringCusp": ["amplitude", "ra", "dec"],
"SineGaussian": ["hrss", "psi", "ra", "dec"],
"Gaussian": ["hrss", "psi", "ra", "dec"],
"BTLWNB": ["hrss", "ra", "dec"],
Expand Down
29 changes: 29 additions & 0 deletions minke/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,35 @@ def interpolate(self, x_old, y_old, x_new, method="linear"):
interpolator = interp.interp1d(x_old, y_old, method)
return interpolator(x_new)

class StringCusp(Waveform):
"""
A class to represent a StringCusp injection.
"""
waveform = "StringCusp"

def __init__(self, amplitude, f_max, time, sky_dist=uniform_sky,):
"""A class to represent a SineGaussian ad-hoc waveform.
Parameters
----------
amplitude : float
The amplitude of the injection.
f_max : float
The maximum frequency of the injection.
time : float
The central time of the injection.
sky_dist : func
The function describing the sky distribution which the injections
should be made over. Defaults to a uniform sky.
"""
self._clear_params()
self.sky_dist = sky_dist
self.params['amplitude'] = amplitude
self.params['frequency'] = f_max
self.time = time


class SineGaussian(Waveform):
Expand Down
21 changes: 21 additions & 0 deletions tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,27 @@ def test_SG_Waveform_generation(self):

np.testing.assert_array_almost_equal(data[0].data.data[::5000], sgdata)

def test_SC_Waveform_generation(self):
"""
Regression test for StringCusp waveforms
"""

sc = sources.StringCusp(1e-23, 150, 100)
data = sc._generate()

scdata = np.array([ 5.70001763e-63, 5.92586457e-32, 2.59625621e-31,
1.29668495e-30, 4.86418685e-30, 1.25517562e-29,
1.95684680e-29, -2.79296626e-29, -3.97865144e-28,
-1.98228555e-27, -5.83672705e-27, -1.84365082e-27,
7.98894273e-26, 2.10292180e-25, -2.26513533e-24,
-1.58525748e-24, -2.79263187e-25, 1.76952837e-25,
2.03163416e-26, -6.90900890e-27, -3.64716334e-27,
-9.34585595e-28, -1.33656482e-28, 1.26838192e-29,
1.67225169e-29, 7.30560692e-30, 2.67365656e-30,
8.41779831e-31, 1.43679337e-31, 6.07001624e-33])

np.testing.assert_array_almost_equal(data[0].data.data[::5000], scdata)

class TestMinkeADISources(unittest.TestCase):
def setUp(self):
"""
Expand Down

0 comments on commit 726d988

Please sign in to comment.