Skip to content

Commit

Permalink
Release v2.1.6 (#4701)
Browse files Browse the repository at this point in the history
* SNR optimizer option types (#4650)

* SNR optimizer option types

Fix issue in non-default settings for some options that Max complained about

* Use standard verbosity argument

---------

Co-authored-by: maxtrevor <[email protected]>

* Need to use atol for isclose here (#4655)

* Update how live fitting deals with invalid values (#4653)

* Update how live fitting deals with invalid values

* TDC comments

* Tito's fixes

* Add check for nan trigger fit values in the singles IFAR calculation

* Properly fix ASD plot minimum value (#4671)

* Properly fix ASD plot minimum value

Rather than a hard coded minimum use the minimum value we are going to plot.  Also put the calculation of the asd we are plotting on a single line rather than splitting over 2

* Fix bug and grid

* ignore samples above minimum freq rather than above 0

* curr_psd does exist !

* specify an older branch of BBHx in tox.ini (#4672) (#4674)

* specify an older branch of BBHx in tox.ini

* Update tox.ini

Co-authored-by: Shichao Wu <[email protected]>

---------

Co-authored-by: Shichao Wu <[email protected]>

* Modify logging in pycbc_optimize_snr to avoid dependencies

* Add live singles significance fitting supervision script to github repo (#4687)

* tidy up code before adding to github repo

* log starting fitting script

* Fix IndexError in PyCBC Live's followup code (#4676)

* Draft fix for followup indexing error

* Use a nonzero min required lookback, better variable names

* Alex's comment on td_samples vs delta_f

* Add docstring for `followup_event_significance`

* Docstring fixes

* Work on comments

* Try to fix Sphinx error

* Simplify definition of strain buffer length

* Explicit kwarg name

Co-authored-by: maxtrevor <[email protected]>

* Simplify `from_cli()` args

* Fix error

* Update example

---------

Co-authored-by: maxtrevor <[email protected]>

* Supervision script typo (#4696)

* increment version

* Fix import broken by change in lscsoft-glue (#4662)

* Drop lscsoft-glue dependency

* Glue still needed, do not drop it!

* Fix bug from scipy version changing (#4683)

---------

Co-authored-by: Thomas Dent <[email protected]>
Co-authored-by: Ian Harry <[email protected]>
Co-authored-by: Gareth S Cabourn Davies <[email protected]>
Co-authored-by: Shichao Wu <[email protected]>
Co-authored-by: Tito Dal Canton <[email protected]>
  • Loading branch information
6 people authored Apr 19, 2024
1 parent 4dc8cec commit 8b33176
Show file tree
Hide file tree
Showing 20 changed files with 838 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,43 @@ for ifo in args.ifos:
logging.info(ifo)
fout_ifo = fout.create_group(ifo)
l_times = np.array(live_times[ifo])
fout_ifo.attrs['live_time'] = l_times.sum()
total_time = l_times.sum()
fout_ifo.attrs['live_time'] = total_time

fout_ifo['separate_fits/live_times'] = l_times[ad_order]
fout_ifo['separate_fits/start_time'] = trigger_file_starts[ad_order]
fout_ifo['separate_fits/end_time'] = trigger_file_ends[ad_order]

for counter, a_c_u_l in enumerate(zip(alphas_bin[ifo],
counts_bin[ifo], bu, bl)):
a, c, u, l = a_c_u_l
for counter, (a, c) in enumerate(zip(alphas_bin[ifo],
counts_bin[ifo])):
# Sort alpha and counts by date
a = np.array(a)[ad_order]
c = np.array(c)[ad_order]
invalphan = c / a
mean_alpha = c.mean() / invalphan.mean()
cons_alpha = np.percentile(a, 100 - args.conservative_percentile)

# ignore anything with the 'invalid' salient values
valid = c > 0

fout_ifo[f'separate_fits/bin_{counter:d}/fit_coeff'] = a
fout_ifo[f'separate_fits/bin_{counter:d}/counts'] = c

if not any(valid):
cons_alphas_out[ifo][counter] = np.nan
alphas_out[ifo][counter] = np.nan
cons_counts_out[ifo][counter] = np.nan
counts_out[ifo][counter] = np.nan
continue

invalphan = c[valid] / a[valid]
mean_alpha = c[valid].mean() / invalphan.mean()
cons_alpha = np.percentile(a[valid], 100 - args.conservative_percentile)
cons_alphas_out[ifo][counter] = cons_alpha
alphas_out[ifo][counter] = mean_alpha

# To get the count values, we need to convert to rates and back again
r = c / l_times[ad_order]
r = c[valid]/ l_times[ad_order][valid]
cons_rate = np.percentile(r, args.conservative_percentile)
cons_counts_out[ifo][counter] = cons_rate * l_times[ad_order].sum()
counts_out[ifo][counter] = np.mean(r) * l_times[ad_order].sum()

fout_ifo[f'separate_fits/bin_{counter:d}/fit_coeff'] = a
fout_ifo[f'separate_fits/bin_{counter:d}/counts'] = c
cons_counts_out[ifo][counter] = cons_rate * total_time
counts_out[ifo][counter] = np.mean(r) * total_time

# Output the mean average values
fout_ifo['mean/fit_coeff'] = alphas_out[ifo]
Expand All @@ -188,17 +200,18 @@ for ifo in args.ifos:
fout_ifo['conservative/fit_coeff'] = cons_alphas_out[ifo]
fout_ifo['conservative/counts'] = cons_counts_out[ifo]

# Take some averages for plotting and summary values
overall_invalphan = counts_out[ifo] / alphas_out[ifo]
overall_meanalpha = counts_out[ifo].mean() / overall_invalphan.mean()

# For the fixed version, we just set this to 1
fout_ifo['fixed/counts'] = [1] * len(counts_out[ifo])
fout_ifo['fixed/fit_coeff'] = [0] * len(alphas_out[ifo])

# Take some averages for plotting and summary values
overall_invalphan = counts_out[ifo] / alphas_out[ifo]
overall_meanalpha = np.nanmean(counts_out[ifo]) \
/ np.nanmean(overall_invalphan)

# Add some useful info to the output file
fout_ifo.attrs['mean_alpha'] = overall_meanalpha
fout_ifo.attrs['total_counts'] = counts_out[ifo].sum()
fout_ifo.attrs['total_counts'] = np.nansum(counts_out[ifo])

fout.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ for ifo in ifos:
continue

l_times = separate_times[ifo]
rate = counts / l_times
with np.errstate(divide='ignore'):
rate = counts / l_times

ma = mean_alpha[ifo][i]
ca = cons_alpha[ifo][i]
Expand All @@ -151,7 +152,8 @@ for ifo in ifos:
bin_colour = plt.get_cmap(args.colormap)(bin_prop)
bin_label = f"duration {bl:.2f}-{bu:.2f}"
alpha_lines += ax_alpha.plot(separate_starts[ifo], alphas, c=bin_colour,
label=bin_label)
label=bin_label, marker='.',
markersize=10)
alpha_lines.append(ax_alpha.axhline(ma,
label="total fit = %.2f" % ma,
c=bin_colour, linestyle='--',))
Expand All @@ -161,14 +163,22 @@ for ifo in ifos:
label=alpha_lab))

count_lines += ax_count.plot(separate_starts[ifo], rate, c=bin_colour,
label=bin_label)
label=bin_label, marker='.',
markersize=10)

if mr < 1e-3:
mlab = f"mean = {mr:.3e}"
clab = f"{conservative_percentile:d}th %ile = {cr:.3e}"
else:
mlab = f"mean = {mr:.3f}"
clab = f"{conservative_percentile:d}th %ile = {cr:.3f}"

count_lines.append(ax_count.axhline(mr,
c=bin_colour, linestyle='--',
label=f"mean = {mr:.3f}"))
count_lab = f"{conservative_percentile:d}th %ile = {cr:.3f}"
label=mlab))
count_lines.append(ax_count.axhline(cr,
c=bin_colour, linestyle=':',
label=count_lab))
label=clab))

alpha_labels = [l.get_label() for l in alpha_lines]
ax_alpha.legend(alpha_lines, alpha_labels, loc='lower center',
Expand Down
File renamed without changes.
Loading

0 comments on commit 8b33176

Please sign in to comment.