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

allow psd var sample rate to change as needed #4541

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 11 additions & 10 deletions bin/pycbc_inspiral
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def template_triggers(t_num):
out_vals['time_index'],
opt.gps_start_time, opt.sample_rate)
#print(idx, out_vals['time_index'])

out_vals_all.append(copy.deepcopy(out_vals))
#print(out_vals_all)
return out_vals_all, tparam
Expand Down Expand Up @@ -358,10 +358,11 @@ with ctx:
if opt.psdvar_segment is not None:
logging.info("Calculating PSD variation")
psd_var = pycbc.psd.calc_filt_psd_variation(gwstrain, opt.psdvar_segment,
opt.psdvar_short_segment, opt.psdvar_long_segment,
opt.psdvar_short_segment, opt.psdvar_long_segment,
opt.psdvar_psd_duration, opt.psdvar_psd_stride,
opt.psd_estimation, opt.psdvar_low_freq, opt.psdvar_high_freq)


if opt.enable_q_transform:
logging.info("Performing q-transform on analysis segments")
q_trans = qtransform.inspiral_qtransform_generator(segments)
Expand Down Expand Up @@ -453,16 +454,16 @@ with ctx:

tsetup = time.time() - tstart
tcheckpoint = time.time()

tanalyze = list(range(tnum_start, len(bank)))
n = opt.finalize_events_template_rate
n = 1 if n is None else n
tchunks = [tanalyze[i:i + n] for i in range(0, len(tanalyze), n)]
tchunks = [tanalyze[i:i + n] for i in range(0, len(tanalyze), n)]

mmap = map
if opt.multiprocessing_nprocesses:
mmap = Pool(opt.multiprocessing_nprocesses).map

for tchunk in tchunks:
data = list(mmap(template_triggers, tchunk))

Expand All @@ -472,11 +473,11 @@ with ctx:
event_mgr.new_template(tmplt=tparam)

for edata in out_vals_all:
event_mgr.add_template_events(names, [edata[n] for n in names])
event_mgr.add_template_events(names, [edata[n] for n in names])

event_mgr.cluster_template_events("time_index", "snr", cluster_window)
event_mgr.finalize_template_events()

if opt.finalize_events_template_rate is not None:
event_mgr.consolidate_events(opt, gwstrain=gwstrain)

Expand All @@ -488,7 +489,7 @@ with ctx:
if opt.checkpoint_exit_maxtime and \
(time.time() - tstart > opt.checkpoint_exit_maxtime):
event_mgr.save_state(max(tchunk), opt.output + '.checkpoint')
sys.exit(opt.checkpoint_exit_code)
sys.exit(opt.checkpoint_exit_code)

event_mgr.consolidate_events(opt, gwstrain=gwstrain)
event_mgr.finalize_events()
Expand Down
4 changes: 0 additions & 4 deletions pycbc/psd/variation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pycbc.psd
from pycbc.types import TimeSeries
from pycbc.filter import resample_to_delta_t


def mean_square(data, delta_t, srate, short_stride, stride):
Expand Down Expand Up @@ -113,9 +112,6 @@ def calc_filt_psd_variation(strain, segment, short_segment, psd_long_segment,
# Convert start and end times immediately to floats
start_time = float(strain.start_time)
end_time = float(strain.end_time)

# Resample the data
strain = resample_to_delta_t(strain, 1.0 / 2048)
srate = int(strain.sample_rate)

# Fix the step for the PSD estimation and the time to remove at the
Expand Down
Loading