From 6666632c9f2f03e095da4f48f4c3aa034cc0acc6 Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Thu, 25 Jul 2024 06:34:39 -0700 Subject: [PATCH 1/6] Revert to maks_n_clustered in sngls_minifollowup [v23_ branch] --- bin/minifollowups/pycbc_sngl_minifollowup | 55 +++++++++-------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/bin/minifollowups/pycbc_sngl_minifollowup b/bin/minifollowups/pycbc_sngl_minifollowup index 4005802d08d..3057ea8d97d 100644 --- a/bin/minifollowups/pycbc_sngl_minifollowup +++ b/bin/minifollowups/pycbc_sngl_minifollowup @@ -249,50 +249,39 @@ if args.maximum_duration is not None: logging.info('Finding loudest clustered events') rank_method = stat.get_statistic_from_opts(args, [args.instrument]) -extra_kwargs = {} -for inputstr in args.statistic_keywords: - try: - key, value = inputstr.split(':') - extra_kwargs[key] = value - except ValueError: - err_txt = "--statistic-keywords must take input in the " \ - "form KWARG1:VALUE1 KWARG2:VALUE2 KWARG3:VALUE3 ... " \ - "Received {}".format(args.statistic_keywords) - raise ValueError(err_txt) - -logging.info("Calculating statistic for %d triggers", len(trigs.snr)) -sds = rank_method.single(trigs) -stat = rank_method.rank_stat_single((args.instrument, sds), **extra_kwargs) -logging.info("Clustering events over %.3fs window", args.cluster_window) -cid = coinc.cluster_over_time(stat, trigs.end_time, - args.cluster_window) -trigs.apply_mask(cid) -stat = stat[cid] -if len(trigs.snr) < num_events: - num_events = len(trigs.snr) - -logging.info("Finding the loudest triggers") -loudest_idx = sorted(numpy.argsort(stat)[::-1][:num_events]) -trigs.apply_mask(loudest_idx) -stat = stat[loudest_idx] +trigs.mask_to_n_loudest_clustered_events( + rank_method, + n_loudest=num_events, + cluster_window=args.cluster_window, +) times = trigs.end_time -tids = trigs.template_id +trig_stat = trigs.stat +trig_snrs = trigs.snr + +if isinstance(trigs.mask, numpy.ndarray) and trigs.mask.dtype == bool: + trigger_ids = numpy.flatnonzero(trigs.mask) +else: + trigger_ids = trigs.mask # loop over number of loudest events to be followed up -order = stat.argsort()[::-1] +order = trig_stat.argsort()[::-1] for rank, num_event in enumerate(order): - logging.info('Processing event: %s', num_event) + logging.info('Processing event: %s', rank) files = wf.FileList([]) time = times[num_event] ifo_time = '%s:%s' %(args.instrument, str(time)) - if isinstance(trigs.mask, numpy.ndarray) and trigs.mask.dtype == bool: - tid = numpy.flatnonzero(trigs.mask)[num_event] - else: - tid = trigs.mask[num_event] + tid = trigger_ids[num_event] ifo_tid = '%s:%s' %(args.instrument, str(tid)) + print(num_event) + print(tid) + print(trig_stat[num_event]) + print(trig_snrs[num_event]) + print(time) + print('\n'*2) + layouts += (mini.make_sngl_ifo(workflow, sngl_file, tmpltbank_file, tid, args.output_dir, args.instrument, statfiles=statfiles, From 97f21f3a5591d63a1e4a28738486531ed4f9d035 Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Mon, 29 Jul 2024 02:02:22 -0700 Subject: [PATCH 2/6] REquire pre-numpy 2.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4857c0aa9d5..8ca8bac06b5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ Mako>=1.0.1 scipy>=0.16.0,<1.14.0 matplotlib>=2.0.0 # Remove the upper bound ASAP, this is a temporary fix!!!!!! -numpy>=1.16.0,!=1.19.0,<1.24.0 +numpy>=1.16.0,!=1.19.0,<2.0.0 pillow h5py>=3.0.0,!=3.7.0 jinja2 From d7ac90953b348065402b50ab91dc31c103829f13 Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Mon, 29 Jul 2024 02:33:32 -0700 Subject: [PATCH 3/6] Revert "REquire pre-numpy 2.0" This reverts commit 839f4ec2a39191144d1d9561639062097dcd0f67. --- .github/workflows/distribution.yml | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/distribution.yml b/.github/workflows/distribution.yml index 122f01ae03d..183c2451604 100644 --- a/.github/workflows/distribution.yml +++ b/.github/workflows/distribution.yml @@ -22,7 +22,7 @@ jobs: with: python-version: 3.8 - name: Install cibuildwheel - run: python -m pip install cibuildwheel + run: python -m pip install cibuildwheel==2.3.1 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse env: diff --git a/pyproject.toml b/pyproject.toml index 94964ac07d0..350410ec5ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = ["setuptools", "wheel", - "cython>=3.0.0", + "cython>=0.29.21", "numpy==1.16.0; python_version <= '3.7'", "numpy==1.17.3; python_version == '3.8'", "numpy==1.19.3; python_version == '3.9'", diff --git a/requirements.txt b/requirements.txt index 8ca8bac06b5..4857c0aa9d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ Mako>=1.0.1 scipy>=0.16.0,<1.14.0 matplotlib>=2.0.0 # Remove the upper bound ASAP, this is a temporary fix!!!!!! -numpy>=1.16.0,!=1.19.0,<2.0.0 +numpy>=1.16.0,!=1.19.0,<1.24.0 pillow h5py>=3.0.0,!=3.7.0 jinja2 From 58c6ce5cbd842c47177b9958f3af141e491addc3 Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Mon, 29 Jul 2024 04:50:31 -0700 Subject: [PATCH 4/6] Trig_dict must have an IFO --- pycbc/io/hdf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pycbc/io/hdf.py b/pycbc/io/hdf.py index 6c6284fc971..3168da9398c 100644 --- a/pycbc/io/hdf.py +++ b/pycbc/io/hdf.py @@ -483,7 +483,7 @@ def checkbank(self, param): % param) def trig_dict(self): - """Returns dict of the masked trigger valuse """ + """Returns dict of the masked trigger values """ mtrigs = {} for k in self.trigs: if len(self.trigs[k]) == len(self.trigs['end_time']): @@ -491,6 +491,7 @@ def trig_dict(self): mtrigs[k] = self.trigs[k][self.mask] else: mtrigs[k] = self.trigs[k][:] + mtrigs['ifo'] = self.ifo return mtrigs @classmethod From adfdf81652362bfdd2d34553067d464745f7d2c9 Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Mon, 29 Jul 2024 05:37:36 -0700 Subject: [PATCH 5/6] Remove testing printing --- bin/minifollowups/pycbc_sngl_minifollowup | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bin/minifollowups/pycbc_sngl_minifollowup b/bin/minifollowups/pycbc_sngl_minifollowup index 3057ea8d97d..a33a7ce1eac 100644 --- a/bin/minifollowups/pycbc_sngl_minifollowup +++ b/bin/minifollowups/pycbc_sngl_minifollowup @@ -275,13 +275,6 @@ for rank, num_event in enumerate(order): tid = trigger_ids[num_event] ifo_tid = '%s:%s' %(args.instrument, str(tid)) - print(num_event) - print(tid) - print(trig_stat[num_event]) - print(trig_snrs[num_event]) - print(time) - print('\n'*2) - layouts += (mini.make_sngl_ifo(workflow, sngl_file, tmpltbank_file, tid, args.output_dir, args.instrument, statfiles=statfiles, From aeb9a6d22a7f4f2eee2bc653e0e9d0b4c3ef324a Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Thu, 8 Aug 2024 02:00:32 -0700 Subject: [PATCH 6/6] Errors uring rebase --- .github/workflows/distribution.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/distribution.yml b/.github/workflows/distribution.yml index 183c2451604..122f01ae03d 100644 --- a/.github/workflows/distribution.yml +++ b/.github/workflows/distribution.yml @@ -22,7 +22,7 @@ jobs: with: python-version: 3.8 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.3.1 + run: python -m pip install cibuildwheel - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse env: diff --git a/pyproject.toml b/pyproject.toml index 350410ec5ee..94964ac07d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = ["setuptools", "wheel", - "cython>=0.29.21", + "cython>=3.0.0", "numpy==1.16.0; python_version <= '3.7'", "numpy==1.17.3; python_version == '3.8'", "numpy==1.19.3; python_version == '3.9'",