Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gate-and-inpainting starting time precise #4403

Merged
merged 25 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
30b86ee
apply time shift to account for the gating start time is a subsamplin…
yi-fan-wang Jun 1, 2023
eb40555
fix int type error
yi-fan-wang Jun 2, 2023
7eb6cac
Merge branch 'gwastro:master' into gatingsub
yi-fan-wang Jun 14, 2023
d12d8b2
correct a misunderstanding for apply_fd_time_shift
yi-fan-wang Jun 15, 2023
f3aa257
correct a unused variable
yi-fan-wang Jun 15, 2023
6c45dca
correct the shift time
yi-fan-wang Jun 17, 2023
46a48eb
address cc issues
yi-fan-wang Jun 22, 2023
2cc658c
apply static method
yi-fan-wang Jul 1, 2023
8dae8bd
complete the gated_gaussian_noise
yi-fan-wang Jul 2, 2023
603462b
typo
yi-fan-wang Jul 2, 2023
793f1a6
typo
yi-fan-wang Jul 2, 2023
0eeff1a
re express time shift
yi-fan-wang Jul 2, 2023
1e27450
Merge branch 'gwastro:master' into gatingsub
yi-fan-wang Jul 2, 2023
99520d8
space
yi-fan-wang Jul 2, 2023
fc58926
start to work on pol marg model
yi-fan-wang Jul 4, 2023
d29e92c
complete shifting for marg pol model
yi-fan-wang Jul 6, 2023
10f28c8
instead of modifying models, now implementing time shifting only in g…
yi-fan-wang Jul 11, 2023
7253bc6
Merge remote-tracking branch 'origin/gatingsub' into gatingsub
yi-fan-wang Jul 11, 2023
bd96f2b
remove all changes in the model
yi-fan-wang Jul 11, 2023
76d5462
remove changes in model
yi-fan-wang Jul 11, 2023
0870e91
fix some bugs when fft/ifft converting, now productive
yi-fan-wang Jul 12, 2023
1186e5b
remove rindex+1 in gate and inpainting, add if condition for time shi…
yi-fan-wang Jul 13, 2023
b7534af
get rindex_time via actually doing the math, this is faster than retr…
yi-fan-wang Sep 15, 2023
5250673
remove the proj and projslc attributes in gated_gaussian_model, it's …
yi-fan-wang Sep 15, 2023
6ad5b22
Merge branch 'gwastro:master' into gatingsub
yi-fan-wang Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pycbc/inference/models/marginalized_gaussian_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __init__(self, variable_params,
generator_class=generator.FDomainDetFrameTwoPolNoRespGenerator,
gates=self.gates, **kwargs['static_params'])
else:
# create a waveform generator for each ifo respestively
# create a waveform generator for each ifo respectively
self.waveform_generator = {}
for det in self.data:
self.waveform_generator[det] = create_waveform_generator(
Expand Down Expand Up @@ -386,7 +386,7 @@ def __init__(self, variable_params, data, low_frequency_cutoff, psds=None,
generator_class=generator.FDomainDetFrameTwoPolGenerator,
gates=self.gates, **kwargs['static_params'])
else:
# create a waveform generator for each ifo respestively
# create a waveform generator for each ifo respectively
self.waveform_generator = {}
for det in self.data:
self.waveform_generator[det] = create_waveform_generator(
Expand Down
8 changes: 4 additions & 4 deletions pycbc/strain/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@ def gate_and_paint(data, lindex, rindex, invpsd, copy=True):
# Copy the data and zero inside the hole
if copy:
data = data.copy()
data[lindex:rindex] = 0
data[lindex:rindex+1] = 0
yi-fan-wang marked this conversation as resolved.
Show resolved Hide resolved

# get the over-whitened gated data
tdfilter = invpsd.astype('complex').to_timeseries() * invpsd.delta_t
owhgated_data = (data.to_frequencyseries() * invpsd).to_timeseries()

# remove the projection into the null space
proj = linalg.solve_toeplitz(tdfilter[:(rindex - lindex)],
owhgated_data[lindex:rindex])
data[lindex:rindex] -= proj
proj = linalg.solve_toeplitz(tdfilter[:(rindex + 1 - lindex)],
owhgated_data[lindex:rindex+1])
data[lindex:rindex+1] -= proj
yi-fan-wang marked this conversation as resolved.
Show resolved Hide resolved
data.projslc = (lindex, rindex)
data.proj = proj
return data
20 changes: 18 additions & 2 deletions pycbc/types/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,15 +595,31 @@ def gate(self, time, window=0.25, method='taper', copy=True,
# Uses the hole-filling method of
# https://arxiv.org/pdf/1908.05644.pdf
from pycbc.strain.gate import gate_and_paint
from pycbc.waveform.utils import apply_fd_time_shift
if invpsd is None:
# These are some bare minimum settings, normally you
# should probably provide a psd
invpsd = 1. / self.filter_psd(self.duration/32, self.delta_f, 0)
lindex = int((time - window - self.start_time) / self.delta_t)
rindex = lindex + int(2 * window / self.delta_t)
rindex = int((time + window - self.start_time) / self.delta_t)
lindex = lindex if lindex >= 0 else 0
rindex = rindex if rindex <= len(self) else len(self)
return gate_and_paint(data, lindex, rindex, invpsd, copy=False)
# shift data such that gate_end_time lands on a specific data sample
fdata = data.to_frequencyseries()
rindex_time = data.sample_times[rindex]
yi-fan-wang marked this conversation as resolved.
Show resolved Hide resolved
offset = rindex_time - (time + window)
yi-fan-wang marked this conversation as resolved.
Show resolved Hide resolved
fdata = apply_fd_time_shift(fdata, offset + fdata.epoch, copy=copy)
# gate and paint in time domain
data = fdata.to_timeseries()
data = gate_and_paint(data, lindex, rindex, invpsd, copy=copy)
# shift back to the original time
fdata = data.to_frequencyseries()
fdata = apply_fd_time_shift(fdata, -offset + fdata.epoch, copy=copy)
tdata = fdata.to_timeseries()
# fill in projslc information
tdata.projslc = data.projslc
tdata.proj = data.proj
return tdata
elif method == 'hard':
tslice = data.time_slice(time - window, time + window)
tslice[:] = 0
Expand Down