Skip to content

Commit

Permalink
Some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GarethCabournDavies committed Nov 23, 2023
1 parent 5adacf4 commit 6eb809c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions bin/minifollowups/pycbc_page_snglinfo
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pycbc.init_logging(args.verbose)

# Get the single-ifo triggers
sngl_file = hdf.SingleDetTriggers(
args.single_trigger_file,
args.instrument,
bank_file=args.bank_file,
veto_file=args.veto_file,
Expand Down
4 changes: 3 additions & 1 deletion bin/minifollowups/pycbc_plot_trigger_timeseries
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ for ifo in args.single_trigger_files.keys():
group=ifo,
indices_only=True
)
data_mask = np.zeros(data[ifo]['snr'].size, dtype=bool)
data_mask[idx] = True

if not len(idx):
# No triggers in this window, add to the legend and continue
Expand All @@ -80,7 +82,7 @@ for ifo in args.single_trigger_files.keys():
trigs = SingleDetTriggers(
args.single_trigger_files[ifo],
ifo,
premask=idx
premask=data_mask
)

any_data = True
Expand Down
2 changes: 1 addition & 1 deletion bin/plotting/pycbc_plot_hist
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pycbc.init_logging(args.verbose)
f = h5py.File(args.trigger_file, 'r')
ifo = tuple(f.keys())[0]

# Apply presort if we can, if we cant, load everything but it may be
# Apply presort if we can; if we can't, load everything but it may be
# inefficient
xv = args.x_var if args.x_var in ranking.required_datasets else None
xt = args.x_min if args.x_var in ranking.required_datasets else None
Expand Down
27 changes: 14 additions & 13 deletions bin/plotting/pycbc_plot_singles_vs_params
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ if opts.min_snr:
idx = trig_file.select(
lambda snr: snr >= opts.min_snr,
'snr',
group=opts.detector
group=opts.detector,
indices_only=True,
)
logging.info('%d triggers after snr mask', idx.size)
data_mask = np.zeros(n_triggers_orig, dtype=bool)
data_mask[idx] = True
else:
idx = None
data_mask = None

if opts.z_var == 'density' or opts.min_z is None:
filter_rank = None
Expand All @@ -116,7 +117,7 @@ trigs = pycbc.io.SingleDetTriggers(
veto_file=opts.veto_file,
segment_name=opts.segment_name,
premask=data_mask,
filter_func=opt.filter_string,
filter_func=opts.filter_string,
filter_rank=filter_rank,
filter_threshold=filter_thresh
)
Expand All @@ -126,16 +127,16 @@ trigs = pycbc.io.SingleDetTriggers(
x = getattr(trigs, opts.x_var)
y = getattr(trigs, opts.y_var)

mask = np.ones(len(x), dtype=bool)
if opts.min_x is not None:
mask = np.logical_and(mask, x >= opts.min_x)
if opts.max_x is not None:
mask = np.logical_and(mask, x <= opts.max_x)
if opts.min_y is not None:
mask = np.logical_and(mask, y >= opts.min_y)
if opts.max_y is not None:
mask = np.logical_and(mask, y <= opts.max_y)
x = x[mask]
mask = np.ones(len(x), dtype=bool)
if opts.min_x is not None:
mask = np.logical_and(mask, x >= opts.min_x)
if opts.max_x is not None:
mask = np.logical_and(mask, x <= opts.max_x)
if opts.min_y is not None:
mask = np.logical_and(mask, y >= opts.min_y)
if opts.max_y is not None:
mask = np.logical_and(mask, y <= opts.max_y)
x = x[mask]
y = y[mask]

hexbin_style = {
Expand Down
2 changes: 1 addition & 1 deletion pycbc/io/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def __init__(self, trig_file, detector, bank_file=None, veto_file=None,
self.bank = {}

# Apply some masks to start off with - here we should try and apply
# them in the order which cuts our the most things earliest.
# them in the order which cuts most things earliest.
self.mask = premask

if filter_rank:
Expand Down

0 comments on commit 6eb809c

Please sign in to comment.