From 17737f0209827543605f32cd52ace5a1c772c4f0 Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Tue, 26 Sep 2023 16:26:10 -0400 Subject: [PATCH 01/11] Update pycbc_brute_bank to include option to cut wavelength and save the lower frequency --- bin/bank/pycbc_brute_bank | 63 ++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index f3a43943f7f..8ca38b94844 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -45,6 +45,8 @@ parser.add_argument('--approximant', required=True, parser.add_argument('--minimal-match', default=0.97, type=float) parser.add_argument('--buffer-length', default=2, type=float, help='size of waveform buffer in seconds') +parser.add_argument('--cut-wavelength', type=bool, + help="Option to cut the wavelength") parser.add_argument('--sample-rate', default=2048, type=float, help='sample rate in seconds') parser.add_argument('--low-frequency-cutoff', default=20.0, type=float) @@ -92,8 +94,7 @@ if args.input_config is not None: fdict = {} if args.fixed_params: - for p, v in zip(args.fixed_params, args.fixed_values): - fdict[p] = v + fdict = {p: v for (p, v) in zip(args.fixed_params, args.fixed_values)} class Shrinker(object): def __init__(self, data): @@ -270,16 +271,37 @@ class GenUniformWaveform(object): self.md = q._data[-100:] self.md2 = q._data[0:100] - def generate(self, **kwds): + def generate(self, **kwds): kwds.update(fdict) - if kwds['approximant'] in pycbc.waveform.fd_approximants(): - ws = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, + if kwds['approximant'] in pycbc.waveform.fd_approximants(): + if args.cut_wavelength: + import numpy + from pycbc.waveform.spa_tmplt import spa_length_in_time + flow = numpy.arange(self.f_lower, 100, .1)[::-1] + maxlen = 512 + length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) + + x = numpy.searchsorted(length, maxlen) - 1 + l = length[x] + f = flow[x] + hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, + f_lower=f, f_ref=10.0, **kwds) + kwds['flow'] = f + + if 'fratio' in kwds: + hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) + + else: + import numpy + kwds.update(fdict) + ws = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, f_lower=self.f_lower, **kwds) - hp = ws[0] - hc = ws[1] - if 'fratio' in kwds: - hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) + hp = ws[0] + hc = ws[1] + if 'fratio' in kwds: + hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) else: + logging.info("failed at 2") dt = 1.0 / args.sample_rate hp = pycbc.waveform.get_waveform_filter( pycbc.types.zeros(self.flen, dtype=numpy.complex64), @@ -321,18 +343,16 @@ if args.input_file: def draw(rtype): - params = {} if rtype == 'uniform': if args.input_config is None: - for name, pmin, pmax in zip(args.params, args.min, args.max): - params[name] = numpy.random.uniform(pmin, pmax, size=size) + params = {name: numpy.random.uniform(pmin, pmax, size=size) + for name, pmin, pmax in zip(args.params, args.min, args.max)} else: # `draw_samples_from_config` has its own fixed seed, so must overwrite it. random_seed = numpy.random.randint(low=0, high=2**32-1) samples = draw_samples_from_config(args.input_config, size, random_seed) - for name in samples.fieldnames: - params[name] = samples[name] + params = {name: samples[name] for name in samples.fieldnames} # Add `static_args` back. if static_args is not None: for k in static_args.keys(): @@ -351,8 +371,7 @@ def draw(rtype): kde = gaussian_kde(bdata) points = kde.resample(size=size) - for k, v in zip(p, points): - params[k] = v + params = {k: v for k, v in zip(p, points)} # Add `static_args` back, some transformations may need them. if args.input_config is not None and static_args is not None: @@ -392,8 +411,7 @@ def draw(rtype): else: l = dists_joint.contains(params) - for k in params: - params[k] = params[k][l] + params = {k: params[k][l] for k in params} return params @@ -405,22 +423,19 @@ def cdraw(rtype, ts, te): t = tau0_from_mass1_mass2(p['mass1'], p['mass2'], args.tau0_cutoff_frequency) l = (t < te) & (t > ts) - for k in p: - p[k] = p[k][l] + p = {k: p[k][l] for k in p} i = 0 while len(p[list(p.keys())[0]]) < size: tp = draw(rtype) - for k in p: - p[k] = numpy.concatenate([p[k], tp[k]]) + p = {k: numpy.concatenate([p[k], tp[k]]) for k in p} if len(p[list(p.keys())[0]]) > 0: t = tau0_from_mass1_mass2(p['mass1'], p['mass2'], args.tau0_cutoff_frequency) l = (t < te) & (t > ts) - for k in p: - p[k] = p[k][l] + p = {k: p[k][l] for k in p} i += 1 if i > 1000: From a4ee467ba5eb281347b65c2d6245bc0b73a223d9 Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:09:01 -0400 Subject: [PATCH 02/11] Removed Logging --- bin/bank/pycbc_brute_bank | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 8ca38b94844..1f0bea23c88 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -301,7 +301,6 @@ class GenUniformWaveform(object): if 'fratio' in kwds: hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) else: - logging.info("failed at 2") dt = 1.0 / args.sample_rate hp = pycbc.waveform.get_waveform_filter( pycbc.types.zeros(self.flen, dtype=numpy.complex64), From ff08632d9e019442ee76ca1a78e86035d31517aa Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Fri, 29 Sep 2023 13:22:55 -0400 Subject: [PATCH 03/11] Update pycbc_brute_bank Still need to fix the completion percentage --- bin/bank/pycbc_brute_bank | 42 +++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 1f0bea23c88..7cd39185e84 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -46,7 +46,9 @@ parser.add_argument('--minimal-match', default=0.97, type=float) parser.add_argument('--buffer-length', default=2, type=float, help='size of waveform buffer in seconds') parser.add_argument('--cut-wavelength', type=bool, - help="Option to cut the wavelength") + help="When enabled, the program will adjust the wavelength to fit the specified length in max-signal-length ") +parser.add_argument('--max-signal-length', type= float, + help="maximum length of the waveform model") parser.add_argument('--sample-rate', default=2048, type=float, help='sample rate in seconds') parser.add_argument('--low-frequency-cutoff', default=20.0, type=float) @@ -273,31 +275,35 @@ class GenUniformWaveform(object): def generate(self, **kwds): kwds.update(fdict) + import numpy + from pycbc.waveform.spa_tmplt import spa_length_in_time + flow = numpy.arange(self.f_lower, 100, .1)[::-1] + maxlen = args.max_signal_length + length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) + + x = numpy.searchsorted(length, maxlen) - 1 + l = length[x] + f = flow[x] if kwds['approximant'] in pycbc.waveform.fd_approximants(): if args.cut_wavelength: - import numpy - from pycbc.waveform.spa_tmplt import spa_length_in_time - flow = numpy.arange(self.f_lower, 100, .1)[::-1] - maxlen = 512 - length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) - - x = numpy.searchsorted(length, maxlen) - 1 - l = length[x] - f = flow[x] + #logging.info("cut wavelength is specified") hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, f_lower=f, f_ref=10.0, **kwds) - kwds['flow'] = f + kwds['f_lower'] = f if 'fratio' in kwds: hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) else: - import numpy - kwds.update(fdict) + #import numpy + #logging.info("cut wavelength not specified") ws = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, f_lower=self.f_lower, **kwds) hp = ws[0] hc = ws[1] + + kwds['f_lower'] = self.f_lower + if 'fratio' in kwds: hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) else: @@ -447,6 +453,8 @@ def cdraw(rtype, ts, te): tau0s = args.tau0_start tau0e = tau0s + args.tau0_crawl +# total_it = args.tau0_crawl/(args.tau0_end - tau0s) +# completed_iterations = 0 go = True region = 0 @@ -469,6 +477,7 @@ while tau0s < args.tau0_end: if r > 10: conv = uconv kloop = 0 + while ((kloop == 0) or (kconv / okconv) > .5) and len(bank) > 10: r += 1 kloop += 1 @@ -477,9 +486,13 @@ while tau0s < args.tau0_end: bank, kconv = bank.check_params(gen, params, args.minimal_match) logging.info("%s: Round (K) (%s): %s Size: %s conv: %s added: %s", region, kloop, r, len(bank), kconv, len(bank) - blen) + +# completed_iterations += 1 +# progress_percentage = completed_iterations / total_it + if uconv: logging.info('Ratio of convergences: %2.3f' % (kconv / (uconv))) - logging.info('Progress: {:.0%} completed'.format(tau0s/args.tau0_end)) + logging.info('Progress: {:.0%} completed'.format(tau0e/args.tau0_end)) if kloop == 1: okconv = kconv @@ -500,4 +513,3 @@ for k in bank.keys(): if val.dtype.char == 'U': val = val.astype('bytes') o[k] = val -o['f_lower'] = numpy.ones(len(val)) * args.low_frequency_cutoff From 039f4021ad2371952c34ef142c9601a52eaadc0f Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:59:33 -0400 Subject: [PATCH 04/11] Update pycbc_brute_bank --- bin/bank/pycbc_brute_bank | 45 +++++++++++++++------------------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 7cd39185e84..22a7fb8960a 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -22,6 +22,7 @@ import numpy, h5py, logging, argparse, numpy.random import pycbc.waveform, pycbc.filter, pycbc.types, pycbc.psd, pycbc.fft, pycbc.conversions from pycbc import transforms +from pycbc.waveform.spa_tmplt import spa_length_in_time from pycbc.distributions import read_params_from_config from pycbc.distributions.utils import draw_samples_from_config, prior_from_config from scipy.stats import gaussian_kde @@ -45,10 +46,8 @@ parser.add_argument('--approximant', required=True, parser.add_argument('--minimal-match', default=0.97, type=float) parser.add_argument('--buffer-length', default=2, type=float, help='size of waveform buffer in seconds') -parser.add_argument('--cut-wavelength', type=bool, - help="When enabled, the program will adjust the wavelength to fit the specified length in max-signal-length ") parser.add_argument('--max-signal-length', type= float, - help="maximum length of the waveform model") + help="When specified, it cuts the maximum length of the waveform model to the lengh provided") parser.add_argument('--sample-rate', default=2048, type=float, help='sample rate in seconds') parser.add_argument('--low-frequency-cutoff', default=20.0, type=float) @@ -275,28 +274,11 @@ class GenUniformWaveform(object): def generate(self, **kwds): kwds.update(fdict) - import numpy - from pycbc.waveform.spa_tmplt import spa_length_in_time flow = numpy.arange(self.f_lower, 100, .1)[::-1] - maxlen = args.max_signal_length length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) - - x = numpy.searchsorted(length, maxlen) - 1 - l = length[x] - f = flow[x] + if kwds['approximant'] in pycbc.waveform.fd_approximants(): - if args.cut_wavelength: - #logging.info("cut wavelength is specified") - hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, - f_lower=f, f_ref=10.0, **kwds) - kwds['f_lower'] = f - - if 'fratio' in kwds: - hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) - - else: - #import numpy - #logging.info("cut wavelength not specified") + if args.max_signal_length is None: ws = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, f_lower=self.f_lower, **kwds) hp = ws[0] @@ -304,6 +286,19 @@ class GenUniformWaveform(object): kwds['f_lower'] = self.f_lower + if 'fratio' in kwds: + hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) + + else: + maxlen = args.max_signal_length + x = numpy.searchsorted(length, maxlen) - 1 + l = length[x] + f = flow[x] + + hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, + f_lower=f, f_ref=10.0, **kwds) + kwds['f_lower'] = f + if 'fratio' in kwds: hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) else: @@ -453,8 +448,6 @@ def cdraw(rtype, ts, te): tau0s = args.tau0_start tau0e = tau0s + args.tau0_crawl -# total_it = args.tau0_crawl/(args.tau0_end - tau0s) -# completed_iterations = 0 go = True region = 0 @@ -486,10 +479,6 @@ while tau0s < args.tau0_end: bank, kconv = bank.check_params(gen, params, args.minimal_match) logging.info("%s: Round (K) (%s): %s Size: %s conv: %s added: %s", region, kloop, r, len(bank), kconv, len(bank) - blen) - -# completed_iterations += 1 -# progress_percentage = completed_iterations / total_it - if uconv: logging.info('Ratio of convergences: %2.3f' % (kconv / (uconv))) logging.info('Progress: {:.0%} completed'.format(tau0e/args.tau0_end)) From a67bb273ecb443a9d1b8a974af2c7eee2814e8c1 Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:37:06 -0400 Subject: [PATCH 05/11] Update pycbc_brute_bank --- bin/bank/pycbc_brute_bank | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 22a7fb8960a..73f257233e1 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -276,31 +276,23 @@ class GenUniformWaveform(object): kwds.update(fdict) flow = numpy.arange(self.f_lower, 100, .1)[::-1] length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) - - if kwds['approximant'] in pycbc.waveform.fd_approximants(): - if args.max_signal_length is None: - ws = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, - f_lower=self.f_lower, **kwds) - hp = ws[0] - hc = ws[1] - - kwds['f_lower'] = self.f_lower - - if 'fratio' in kwds: - hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) - - else: + if args.max_signal_length is not None: maxlen = args.max_signal_length x = numpy.searchsorted(length, maxlen) - 1 l = length[x] f = flow[x] + else: + f = self.f_lower + + if kwds['approximant'] in pycbc.waveform.fd_approximants(): - hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, + hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, f_lower=f, f_ref=10.0, **kwds) - kwds['f_lower'] = f - - if 'fratio' in kwds: - hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) + kwds['f_lower'] = f + + if 'fratio' in kwds: + hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) + else: dt = 1.0 / args.sample_rate hp = pycbc.waveform.get_waveform_filter( @@ -445,9 +437,10 @@ def cdraw(rtype, ts, te): return None return p - + tau0s = args.tau0_start tau0e = tau0s + args.tau0_crawl + go = True region = 0 @@ -479,6 +472,8 @@ while tau0s < args.tau0_end: bank, kconv = bank.check_params(gen, params, args.minimal_match) logging.info("%s: Round (K) (%s): %s Size: %s conv: %s added: %s", region, kloop, r, len(bank), kconv, len(bank) - blen) + + if uconv: logging.info('Ratio of convergences: %2.3f' % (kconv / (uconv))) logging.info('Progress: {:.0%} completed'.format(tau0e/args.tau0_end)) From 5afdeba0b6988696385c7c642145a22e21680d2e Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:45:07 -0400 Subject: [PATCH 06/11] Update pycbc_brute_bank Debugged test example --- bin/bank/pycbc_brute_bank | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 73f257233e1..61cd7d9ddf6 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -283,12 +283,13 @@ class GenUniformWaveform(object): f = flow[x] else: f = self.f_lower - + + kwds['f_lower'] = f + if kwds['approximant'] in pycbc.waveform.fd_approximants(): - - hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, - f_lower=f, f_ref=10.0, **kwds) - kwds['f_lower'] = f + hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f, + f_ref=10.0, **kwds) + if 'fratio' in kwds: hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio']) @@ -357,10 +358,10 @@ def draw(rtype): p = bank.keys() p = [k for k in p if k not in fdict] p.remove('approximant') + p.remove('f_lower') if args.input_config is not None: p = variable_args bdata = numpy.array([bank.key(k)[-trail:] for k in p]) - kde = gaussian_kde(bdata) points = kde.resample(size=size) params = {k: v for k, v in zip(p, points)} @@ -492,6 +493,7 @@ while tau0s < args.tau0_end: tau0e += args.tau0_crawl / 2 o = h5py.File(args.output_file, 'w') + for k in bank.keys(): val = bank.key(k) if val.dtype.char == 'U': From d5e220128a2f465237875f2c75d2a078f2efb409 Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:32:52 -0400 Subject: [PATCH 07/11] Update pycbc_brute_bank --- bin/bank/pycbc_brute_bank | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 61cd7d9ddf6..ef07ef06770 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -274,9 +274,9 @@ class GenUniformWaveform(object): def generate(self, **kwds): kwds.update(fdict) - flow = numpy.arange(self.f_lower, 100, .1)[::-1] - length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) if args.max_signal_length is not None: + flow = numpy.arange(self.f_lower, 100, .1)[::-1] + length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) maxlen = args.max_signal_length x = numpy.searchsorted(length, maxlen) - 1 l = length[x] From 58a908c80d7ce599e036f202389c50568e629381 Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:14:13 -0400 Subject: [PATCH 08/11] Update pycbc_brute_bank From cc8de9bedbd234968da4316f976d2496033a6da6 Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:55:26 -0400 Subject: [PATCH 09/11] Testing Condor Condor installation is not working properly for the checks after I changed two lines. From 82e4b214383124324b38c56d3c3f057752766c9c Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:01:01 -0400 Subject: [PATCH 10/11] Testing Testing with file used before swapping two lines caused errors --- bin/bank/pycbc_brute_bank | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index ef07ef06770..61cd7d9ddf6 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -274,9 +274,9 @@ class GenUniformWaveform(object): def generate(self, **kwds): kwds.update(fdict) + flow = numpy.arange(self.f_lower, 100, .1)[::-1] + length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) if args.max_signal_length is not None: - flow = numpy.arange(self.f_lower, 100, .1)[::-1] - length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) maxlen = args.max_signal_length x = numpy.searchsorted(length, maxlen) - 1 l = length[x] From 050c915265edc4c45a9ccd86b9518bb8f19389ae Mon Sep 17 00:00:00 2001 From: kkacanja <123669569+kkacanja@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:00:28 -0400 Subject: [PATCH 11/11] Update pycbc_brute_bank Swapped two lines to be within the if statment --- bin/bank/pycbc_brute_bank | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/bank/pycbc_brute_bank b/bin/bank/pycbc_brute_bank index 61cd7d9ddf6..ef07ef06770 100644 --- a/bin/bank/pycbc_brute_bank +++ b/bin/bank/pycbc_brute_bank @@ -274,9 +274,9 @@ class GenUniformWaveform(object): def generate(self, **kwds): kwds.update(fdict) - flow = numpy.arange(self.f_lower, 100, .1)[::-1] - length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) if args.max_signal_length is not None: + flow = numpy.arange(self.f_lower, 100, .1)[::-1] + length = spa_length_in_time(mass1=kwds['mass1'], mass2=kwds['mass2'], f_lower=flow, phase_order=-1) maxlen = args.max_signal_length x = numpy.searchsorted(length, maxlen) - 1 l = length[x]