From 3c8a089fe0f634bf0895a989a0a04849a42687ee Mon Sep 17 00:00:00 2001 From: GarethDaviesGW Date: Wed, 8 Jan 2025 14:06:29 +0000 Subject: [PATCH] codes in bin --- bin/pycbc_banksim_combine_banks | 4 +--- bin/pycbc_banksim_skymax | 9 ++++----- bin/pycbc_compress_bank | 5 ----- bin/pycbc_convertinjfiletohdf | 3 +-- bin/pycbc_create_injections | 3 --- bin/pycbc_data_store | 1 - bin/pycbc_faithsim_collect_results | 2 +- bin/pycbc_get_ffinal | 3 +-- bin/pycbc_hdf5_splitbank | 2 -- bin/pycbc_inspiral | 5 ++--- bin/pycbc_inspiral_skymax | 4 ++-- bin/pycbc_live | 4 +--- bin/pycbc_make_faithsim | 1 - bin/pycbc_make_html_page | 4 ---- bin/pycbc_make_skymap | 5 ++--- bin/pycbc_merge_inj_hdf | 1 - bin/pycbc_multi_inspiral | 1 - bin/pycbc_randomize_inj_dist_by_optsnr | 1 - bin/pycbc_source_probability_offline | 1 - 19 files changed, 15 insertions(+), 44 deletions(-) diff --git a/bin/pycbc_banksim_combine_banks b/bin/pycbc_banksim_combine_banks index 3a547d71aa4..3dcb10ec207 100644 --- a/bin/pycbc_banksim_combine_banks +++ b/bin/pycbc_banksim_combine_banks @@ -22,10 +22,8 @@ files. It is assumed that input files have analysed the same set of injections. Concatenation of injections is done separately. """ -from os.path import isfile import argparse -import logging -from numpy import * +from numpy import dtype, array import pycbc diff --git a/bin/pycbc_banksim_skymax b/bin/pycbc_banksim_skymax index f93fdfa006b..b5abcb9e056 100644 --- a/bin/pycbc_banksim_skymax +++ b/bin/pycbc_banksim_skymax @@ -17,9 +17,8 @@ """Calculate the fitting factors of simulated signals with a template bank.""" -import sys import logging -from numpy import complex64, float32, sqrt, argmax, real, array +from numpy import complex64, sqrt, argmax, real, array from argparse import ArgumentParser from math import ceil, log from tqdm import tqdm @@ -27,14 +26,14 @@ from tqdm import tqdm from ligo.lw import utils as ligolw_utils from ligo.lw import lsctables -from pycbc.pnutils import mass1_mass2_to_mchirp_eta, f_SchwarzISCO +from pycbc.pnutils import mass1_mass2_to_mchirp_eta from pycbc.pnutils import nearest_larger_binary_number from pycbc.pnutils import mass1_mass2_to_tau0_tau3 from pycbc.waveform import get_td_waveform, get_fd_waveform, td_approximants, fd_approximants from pycbc.waveform.utils import taper_timeseries from pycbc import DYN_RANGE_FAC -from pycbc.types import FrequencySeries, TimeSeries, zeros, real_same_precision_as, complex_same_precision_as -from pycbc.filter import match, sigmasq, resample_to_delta_t +from pycbc.types import FrequencySeries, TimeSeries, zeros, complex_same_precision_as +from pycbc.filter import sigmasq from pycbc.filter import overlap_cplx, matched_filter from pycbc.filter import compute_max_snr_over_sky_loc_stat from pycbc.filter import compute_max_snr_over_sky_loc_stat_no_phase diff --git a/bin/pycbc_compress_bank b/bin/pycbc_compress_bank index 0d98bbffc75..42172d64bf4 100755 --- a/bin/pycbc_compress_bank +++ b/bin/pycbc_compress_bank @@ -28,17 +28,12 @@ hdf file.""" import argparse import numpy -import h5py import logging import pycbc -from pycbc import psd, DYN_RANGE_FAC from pycbc.waveform import compress from pycbc import waveform from pycbc.types import FrequencySeries, real_same_precision_as -from pycbc import pnutils -from pycbc import filter - parser = argparse.ArgumentParser(description=__description__) pycbc.add_common_pycbc_options(parser) diff --git a/bin/pycbc_convertinjfiletohdf b/bin/pycbc_convertinjfiletohdf index 5b983673ade..a9835523acc 100755 --- a/bin/pycbc_convertinjfiletohdf +++ b/bin/pycbc_convertinjfiletohdf @@ -25,8 +25,7 @@ import numpy import shutil import pycbc -from pycbc.inject import InjectionSet, CBCHDFInjectionSet -from pycbc.types import float64, float32 +from pycbc.inject import CBCHDFInjectionSet from pycbc.io.record import FieldArray from pycbc.io.hdf import HFile diff --git a/bin/pycbc_create_injections b/bin/pycbc_create_injections index 6b388a34ad1..604a0f62935 100644 --- a/bin/pycbc_create_injections +++ b/bin/pycbc_create_injections @@ -113,7 +113,6 @@ import sys import argparse import logging import numpy -import h5py from numpy.random import uniform import pycbc @@ -121,8 +120,6 @@ from pycbc.inject import InjectionSet from pycbc import distributions from pycbc import transforms from pycbc.distributions import JointDistribution -from pycbc.io import record -from pycbc.waveform import parameters from pycbc.workflow import configuration from pycbc.workflow import WorkflowConfigParser diff --git a/bin/pycbc_data_store b/bin/pycbc_data_store index 087b18fb87d..69f373b29e9 100755 --- a/bin/pycbc_data_store +++ b/bin/pycbc_data_store @@ -3,7 +3,6 @@ """ import logging import argparse -import numpy import pycbc import pycbc.strain diff --git a/bin/pycbc_faithsim_collect_results b/bin/pycbc_faithsim_collect_results index a574e5e0415..88a167678fa 100755 --- a/bin/pycbc_faithsim_collect_results +++ b/bin/pycbc_faithsim_collect_results @@ -8,7 +8,7 @@ computing the match between them and creating a .dat file with the results. import argparse import numpy as np -from ligo.lw import utils, table, lsctables +from ligo.lw import utils, lsctables from pycbc import add_common_pycbc_options, init_logging from pycbc.io.ligolw import LIGOLWContentHandler diff --git a/bin/pycbc_get_ffinal b/bin/pycbc_get_ffinal index a5767a198d3..b273550b656 100644 --- a/bin/pycbc_get_ffinal +++ b/bin/pycbc_get_ffinal @@ -7,14 +7,13 @@ the duration of time domain waveforms. __prog__ = 'pycbc_get_ffinal' __author__ = 'Collin Capano ' -import os, sys +import sys import numpy import argparse import pycbc from pycbc import waveform -from ligo.lw import lsctables from ligo.lw import utils as ligolw_utils from ligo.lw import table from ligo.lw.utils import process diff --git a/bin/pycbc_hdf5_splitbank b/bin/pycbc_hdf5_splitbank index ad50d57aed9..1a51fcbe848 100755 --- a/bin/pycbc_hdf5_splitbank +++ b/bin/pycbc_hdf5_splitbank @@ -23,7 +23,6 @@ smaller banks where the number of smaller banks is a user input import argparse import numpy -import h5py import logging from numpy import random @@ -92,7 +91,6 @@ if args.random_sort: tmplt_bank.table = templates if args.mchirp_sort: - from pycbc import pnutils mcsort = numpy.argsort(templates.mchirp) templates = templates[mcsort] tmplt_bank.table = templates diff --git a/bin/pycbc_inspiral b/bin/pycbc_inspiral index 24193310714..8e66bdc713b 100644 --- a/bin/pycbc_inspiral +++ b/bin/pycbc_inspiral @@ -22,15 +22,14 @@ import copy import logging import argparse import numpy -import itertools import time from pycbc.pool import BroadcastPool as Pool import pycbc from pycbc import vetoes, psd, waveform, strain, scheme, fft, DYN_RANGE_FAC, events from pycbc.vetoes.sgchisq import SingleDetSGChisq -from pycbc.filter import MatchedFilterControl, make_frequency_series, qtransform -from pycbc.types import TimeSeries, FrequencySeries, zeros, float32, complex64 +from pycbc.filter import MatchedFilterControl, qtransform +from pycbc.types import zeros, float32, complex64 import pycbc.opt import pycbc.inject diff --git a/bin/pycbc_inspiral_skymax b/bin/pycbc_inspiral_skymax index 2f2c477f72d..bc1972e7968 100755 --- a/bin/pycbc_inspiral_skymax +++ b/bin/pycbc_inspiral_skymax @@ -24,8 +24,8 @@ import numpy from pycbc import vetoes, psd, waveform, events, strain, scheme, fft from pycbc.vetoes.sgchisq import SingleDetSGChisq from pycbc import DYN_RANGE_FAC -from pycbc.filter import MatchedFilterSkyMaxControl, make_frequency_series, MatchedFilterSkyMaxControlNoPhase -from pycbc.types import TimeSeries, FrequencySeries, zeros, float32, complex64 +from pycbc.filter import MatchedFilterSkyMaxControl, MatchedFilterSkyMaxControlNoPhase +from pycbc.types import zeros, float32, complex64 import pycbc.fft.fftw import pycbc.opt diff --git a/bin/pycbc_live b/bin/pycbc_live index 52a0de2433a..54e5f896677 100755 --- a/bin/pycbc_live +++ b/bin/pycbc_live @@ -10,12 +10,11 @@ launched with mpirun. See https://arxiv.org/abs/1805.11174 for an overview.""" import sys -import argparse, numpy, pycbc, logging, cProfile, h5py, lal, json +import argparse, numpy, pycbc, logging, cProfile, h5py, json import os.path import itertools import platform import subprocess -import multiprocessing from multiprocessing.dummy import threading from matplotlib import use use('agg') @@ -43,7 +42,6 @@ from pycbc.detector import ppdets from pycbc.filter import resample from pycbc.psd import estimate from pycbc.psd import variation -from pycbc.live import snr_optimizer from pycbc import conversions as conv # Use cached class-based FFTs in the resample and estimate module diff --git a/bin/pycbc_make_faithsim b/bin/pycbc_make_faithsim index 552b767297d..f9294cd5e85 100644 --- a/bin/pycbc_make_faithsim +++ b/bin/pycbc_make_faithsim @@ -52,7 +52,6 @@ def mkdir(dir_name): pass def matches_in_list(slist, match): - import re matches = [] for st in slist: if st.startswith(match): diff --git a/bin/pycbc_make_html_page b/bin/pycbc_make_html_page index 452663978c6..424a272b8df 100644 --- a/bin/pycbc_make_html_page +++ b/bin/pycbc_make_html_page @@ -19,17 +19,13 @@ import argparse import os import stat -import random import shutil import zipfile import codecs from jinja2 import Environment, FileSystemLoader -import igwn_segments as segments - import pycbc.results from pycbc.results.render import get_embedded_config, render_workflow_html_template, setup_template_render -from pycbc.workflow import segment def examine_dir(cwd): """ diff --git a/bin/pycbc_make_skymap b/bin/pycbc_make_skymap index c71344cfac9..df33bbc9743 100755 --- a/bin/pycbc_make_skymap +++ b/bin/pycbc_make_skymap @@ -18,14 +18,13 @@ from matplotlib import use as mpl_use_backend mpl_use_backend('agg') import numpy as np -import h5py from ligo.gracedb.rest import GraceDb import pycbc from pycbc.filter import sigmasq from pycbc.io import gracedb as pycbc_gracedb, WaveformArray -from pycbc.types import (TimeSeries, FrequencySeries, load_timeseries, +from pycbc.types import (load_timeseries, load_frequencyseries, MultiDetMultiColonOptionAction, MultiDetOptionAction, MultiDetOptionAppendAction) from pycbc.pnutils import nearest_larger_binary_number @@ -605,4 +604,4 @@ if __name__ == '__main__': segment_source=opt.segment_source, segment_server=opt.segment_server, veto_definer=opt.veto_definer, injection_file=opt.injection_file, fake_strain=opt.fake_strain, fake_strain_from_file=opt.fake_strain_from_file, fake_strain_seed=opt.fake_strain_seed, - rescale_loglikelihood=opt.rescale_loglikelihood) \ No newline at end of file + rescale_loglikelihood=opt.rescale_loglikelihood) diff --git a/bin/pycbc_merge_inj_hdf b/bin/pycbc_merge_inj_hdf index b09b0dce1a2..0d47e3dc627 100755 --- a/bin/pycbc_merge_inj_hdf +++ b/bin/pycbc_merge_inj_hdf @@ -23,7 +23,6 @@ Merge hdf injection files import logging import argparse import numpy as np -import h5py import pycbc import pycbc.inject diff --git a/bin/pycbc_multi_inspiral b/bin/pycbc_multi_inspiral index 8abc9d961c3..0d2c92a8c4c 100755 --- a/bin/pycbc_multi_inspiral +++ b/bin/pycbc_multi_inspiral @@ -44,7 +44,6 @@ from pycbc import ( add_common_pycbc_options, ) from pycbc.events import ranking, coherent as coh, EventManagerCoherent -from pycbc.io.hdf import HFile from pycbc.filter import MatchedFilterControl from pycbc.types import zeros, float32, complex64, angle_as_radians from pycbc.vetoes import sgchisq diff --git a/bin/pycbc_randomize_inj_dist_by_optsnr b/bin/pycbc_randomize_inj_dist_by_optsnr index c3b3a334209..3b6c3b78ed6 100644 --- a/bin/pycbc_randomize_inj_dist_by_optsnr +++ b/bin/pycbc_randomize_inj_dist_by_optsnr @@ -13,7 +13,6 @@ from argparse import ArgumentParser from ligo.lw import lsctables from ligo.lw import utils as ligolw_utils -from ligo.lw import table import pycbc from pycbc.io.ligolw import LIGOLWContentHandler diff --git a/bin/pycbc_source_probability_offline b/bin/pycbc_source_probability_offline index 3baafbb3324..e79614ce167 100755 --- a/bin/pycbc_source_probability_offline +++ b/bin/pycbc_source_probability_offline @@ -3,7 +3,6 @@ Compute source probabilities using mchirp estimation method for all events in a chunk with an IFAR above certain threshold. """ -import h5py import json import tqdm import argparse