Skip to content

Commit

Permalink
Fixed the test for Ott waveforms and distance scaling.
Browse files Browse the repository at this point in the history
  • Loading branch information
transientlunatic committed Mar 12, 2018
1 parent 8df58ca commit 02fe5ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 15 additions & 4 deletions minke/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,16 @@ def _generate(self, rate=16384.0, half=False, distance=None):
tail_hp = self.generate_tail(length = 1, h_max = hp.data.data[-1])
tail_hx = self.generate_tail(length = 1, h_max = hx.data.data[-1])

hp.data.data = np.append(hp.data.data(tail_hp))
hx.data.data = np.append(hp.data.data(tail_hx))
hp_data = np.append(hp.data.data,tail_hp.data)
hx_data = np.append(hp.data.data,tail_hx.data)

tail_hp = lal.CreateREAL8Vector(len(hp_data))
tail_hp.data = hp_data
tail_hx = lal.CreateREAL8Vector(len(hx_data))
tail_hx.data = hx_data

hp.data = tail_hp
hx.data = tail_hx

return hp, hx, hp0, hx0

Expand Down Expand Up @@ -481,9 +489,12 @@ def generate_tail(self, sampling=16384.0, length = 1, h_max = 1e-23):

times = np.linspace(0, length, length * sampling)
tail_f = 1.0 / length / 2.0 # Calculate the frequency for a half cosine function over the length of the tail
tail = 0.5 * (h_max + h_max * np.cos( 2 * np.pi * f_tail * times))
tail = 0.5 * (h_max + h_max * np.cos( 2 * np.pi * tail_f * times))

return tail
tailout = lal.CreateREAL8Vector(len(tail))
tailout.data = tail

return tailout


def interpolate(self, x_old, y_old, x_new):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np



ott_data_url = "http://www.stellarcollapse.org/gwdata/ottetal2012b/s27WHW02_LS220_j0_rx3_full_cc_fheat1.05_HlmD.dat.gz"

def download_nr(url):
Expand Down Expand Up @@ -68,7 +69,8 @@ def test_OttWaveform_distance(self):
self.assertAlmostEqual(sn_10.params['amplitude'],float(0.1 * sn_100.params['amplitude']))
sn_10_hp, _, _, _ = sn_10._generate()
sn_100_hp, _, _, _ = sn_100._generate()
assert np.all(sn_100_hp.data.data == 10*sn_10_hp.data.data)

np.testing.assert_almost_equal(10*sn_100_hp.data.data, sn_10_hp.data.data)

def test_OttXML(self):
mdcset = mdctools.MDCSet(['L1', 'H1'])
Expand Down

0 comments on commit 02fe5ca

Please sign in to comment.