Пример #1
0
def prep_ccsn(h, sim_times, Tc, fw):
    """Function to prepare a single polarization of a simulated ccsn waveform - resample, high pass filter and window
	"""
    dt = sim_times[1] - sim_times[0]
    h = TimeSeries(h, t0=sim_times[0], dt=dt)
    h = h.resample(rate=fw, ftype='iir',
                   n=20)  # downsample to working frequency fw
    h = h.highpass(frequency=11,
                   filtfilt=True)  # filter out frequencies below 20Hz
    inj_window = scisig.tukey(M=len(h), alpha=0.08, sym=True)
    h = h * inj_window
    h = h.pad(int((fw * Tc - len(h)) / 2))
    return h
Пример #2
0
def load_inject_condition_ccsn(t_i, t_f, t_inj, ra, dec, ccsn_paper, ccsn_file, D_kpc=10, local=False, Tc=16, To=2, fw=2048, window='tukey', detector='H', 
						  qtrans=False, qsplit=False, dT=2.0, save=False, data_path=None):
	"""Fucntion to load a chunk, inject a waveform and condition, created to enable parallelizing.
	"""
	if local:
		files = get_files(detector)
		try:
			data = TimeSeries.read(files, start=t_i, end=t_f, format='hdf5.losc') # load data locally
		except:
			return

	else:
		# load data from losc
		try:
			data = TimeSeries.fetch_open_data(detector + '1', *(t_i, t_f), sample_rate=fw, verbose=False, cache=True)
		except:
			return

	if np.isnan(data.value).any():
		return

	det_obj = Detector(detector + '1')
	delay = det_obj.time_delay_from_detector(Detector('H1'), ra, dec, t_inj)
	t_inj += delay
	fp, fc = det_obj.antenna_pattern(ra, dec, 0, t_inj)

	wfs_path = Path(git_path + '/shared/ccsn_wfs/' + ccsn_paper)
	sim_data = [i.strip().split() for i in open(join(wfs_path, ccsn_file)).readlines()]
	if ccsn_paper == 'radice':
		line_s = 1
	else:
		line_s = 0

	D = D_kpc *  3.086e+21 # cm
	sim_times = np.asarray([float(dat[0]) for dat in sim_data[line_s:]])
	hp = np.asarray([float(dat[1]) for dat in sim_data[line_s:]]) / D
	if ccsn_paper == 'abdikamalov':
		hc = np.zeros(hp.shape)
	else:
		hc = np.asarray([float(dat[2]) for dat in sim_data[line_s:]]) / D

	dt = sim_times[1] - sim_times[0]
	h = fp * hp + fc * hc
	h = TimeSeries(h, t0=sim_times[0], dt=dt)

	h = h.resample(rate=fw, ftype = 'iir', n=20) # downsample to working frequency fw
	h = h.highpass(frequency=11, filtfilt=True) # filter out frequencies below 20Hz
	inj_window = scisig.tukey(M=len(h), alpha=0.08, sym=True)
	h = h * inj_window
	h = h.pad(int((fw * Tc - len(h)) / 2))

	wf_times = data.times.value

	shift = int((t_inj - (wf_times[0] + Tc/2)) * fw)
	h = np.roll(h.value, shift)
	
	h = TimeSeries(h, t0=wf_times[0], dt=data.dt)
	try:
		h = h.taper()
	except:
		pass

	injected_data = data.inject(h)

	
	cond_data = condition_data(injected_data, To, fw, window, qtrans, qsplit, dT)

	x = []
	times = []

	for dat in cond_data:
		x.append(dat.values)
		times.append(dat.t0)

	x = np.asarray(x)
	times = np.asarray(times)

	idx = find_closest_index(t_inj, times)

	x = x[idx]
	times = times[idx]
	return x, times
Пример #3
0
DURATION = 68
FREQ = 1 / 10
SAMPLE = 4096

TIMES = numpy.arange(0, DURATION, 1 / SAMPLE)
PHASE = 42 * numpy.sin(2 * numpy.pi * FREQ * TIMES) / (2 * numpy.pi * FREQ)
SCATTER = TimeSeries(
    (numpy.sin(numpy.pi * TIMES / DURATION) * numpy.cos(2 * numpy.pi * PHASE)),
    sample_rate=SAMPLE,
)

HOFT = TimeSeries(
    numpy.random.normal(loc=1, scale=1.5, size=SCATTER.size),
    sample_rate=SAMPLE,
).inject(SCATTER.highpass(10))

AUX = TimeSeriesDict({
    ':'.join([IFO, chan]): TimeSeries(
        numpy.random.normal(loc=1, scale=1e-3, size=SCATTER.size),
        sample_rate=SAMPLE,
        name=':'.join([IFO, chan]),
    ).crop(4, 64)
    for chan in simple.MOTION_CHANNELS[1::]
})

PHASE = PHASE[4 * SAMPLE:-4 * SAMPLE]
AUX['{}:SUS-ITMX_R0_DAMP_L_IN1_DQ'.format(IFO)] += 1.064 * PHASE / 2

# -- cli tests ----------------------------------------------------------------