def write_round(round_, context): """Write the HTML summary for a specific round Parameters ---------- round_ : `HvetoRound` the analysis round object context : `str` context for bootstrap objects, default: info Returns ------- page : `~MarkupPy.markup.page` the formatted HTML for this round """ page = markup.page() page.div(class_='card card-%s mb-3 shadow-sm' % context) # -- make heading page.div(class_='card-header pb-0') # heading page.h5('Round %d, Winner = %s, window = %s, SNR thresh = %s' % (round_.n, round_.winner.name, round_.winner.window, round_.winner.snr), class_='card-title', id_='hveto-round-%d' % round_.n) page.div.close() # card-header pb-0 # -- make body page.div(class_='card-body') page.ul(class_='list-group') page.li(class_='list-group-item flex-column align-items-start') page.div(class_='row') # summary information page.div(class_='col-md-3', id_='hveto-round-%d-summary' % round_.n) page.add(bold_param('Winner', round_.winner.name)) page.add(bold_param('SNR threshold', round_.winner.snr)) page.add(bold_param('Window', round_.winner.window)) page.add(bold_param('Significance', '%.2f' % round_.winner.significance)) for desc, tag in zip([ 'Veto segments', 'Veto triggers', 'Vetoed primary triggers', 'Unvetoed primary triggers' ], ['VETO_SEGS', 'WINNER', 'VETOED', 'RAW']): if isinstance(round_.files[tag], str): files = [round_.files[tag]] else: files = round_.files[tag] link = ' '.join([ gwhtml.html_link(f, '[%s]' % os.path.splitext(f)[1].strip('.'), style='color: inherit;') for f in files ]) page.add(bold_param(desc, link)) # link omega scans if generated if round_.scans is not None: page.p('<b>Omega scans:</b>') for t in round_.scans: page.p() page.a('%s [SNR %.1f]' % (t['time'], t[round_.rank]), href='./scans/%s/' % t['time'], **{ 'class_': 'fancybox', 'style': 'color: inherit;', 'target': '_blank' }) for c, tag in zip([round_.primary, round_.winner.name], ['Primary', 'Auxiliary']): caption = 'Omega scan of %s at %s' % (c, t['time']) png = ('./scans/%s/plots/%s-qscan_whitened-1.png' % (t['time'], c.replace('-', '_').replace(':', '-'))) page.a('[%s]' % tag[0].lower(), class_='fancybox', href=png, title=caption, style='color: inherit;', **{ 'data-fancybox-group': 'omega-preview', 'data-fancybox': 'gallery' }) page.p.close() page.div.close() # col # plots page.div(class_='col-md-9', id_='hveto-round-%d-plots' % round_.n) page.add(gwhtml.scaffold_plots(round_.plots[:-1], nperrow=4)) # add significance drop plot at end page.div(class_='row') page.div(class_='col-sm-12') page.add(gwhtml.fancybox_img(round_.plots[-1], lazy=True)) page.div.close() # col-sm-12 page.div.close() # row page.div.close() # col-md-8 page.div.close() # row page.li.close() # list-group-item flex-column align-items-start page.ul.close() # list-group # close and return page.div.close() # card-body page.div.close() # card return page()
def write_round(round): """Write the HTML summary for a specific round Parameters ---------- round : `HvetoRound` the analysis round object Returns ------- page : `~MarkupPy.markup.page` the formatted HTML for this round """ page = markup.page() page.div(class_='panel panel-info', id_='hveto-round-%d' % round.n) # -- make heading page.div(class_='panel-heading clearfix') # link to top of page page.div(class_='pull-right') page.a("<small>[top]</small>", href='#') page.div.close() # pull-right # heading page.h3('Round %d, Winner = %s, window = %s, SNR thresh = %s' % (round.n, round.winner.name, round.winner.window, round.winner.snr), class_='panel-title') page.div.close() # panel-heading # -- make body page.div(class_='panel-body') page.div(class_='row') # summary information page.div(class_='col-md-3', id_='hveto-round-%d-summary' % round.n) page.add(bold_param('Winner', round.winner.name)) page.add(bold_param('SNR threshold', round.winner.snr)) page.add(bold_param('Window', round.winner.window)) page.add(bold_param('Significance', '%.2f' % round.winner.significance)) for desc, tag in zip( ['Veto segments', 'Veto triggers', 'Vetoed primary triggers', 'Unvetoed primary triggers'], ['VETO_SEGS', 'WINNER', 'VETOED', 'RAW']): if isinstance(round.files[tag], str): files = [round.files[tag]] else: files = round.files[tag] link = ' '.join([gwhtml.html_link( f, '[%s]' % os.path.splitext(f)[1].strip('.')) for f in files]) page.add(bold_param(desc, link)) # link omega scans if generated if round.scans is not None: page.p('<b>Omega scans:</b>') for t in round.scans: page.p() page.a('%s [SNR %.1f]' % (t['time'], t['snr']), href='./scans/%s/' % t['time'], **{ 'class_': 'fancybox', 'data-fancybox-group': 'hveto-image', 'target': '_blank', }) for c, tag in zip([round.primary, round.winner.name], ['Primary', 'Auxiliary']): caption = 'Omega scan of %s at %s' % (c, t['time']) png = ('./scans/%s/plots/%s-qscan_whitened-1.png' % (t['time'], c.replace('-', '_').replace(':', '-'))) page.a('[%s]' % tag[0].lower(), class_='fancybox', href=png, title=caption, **{'data-fancybox-group': 'omega-preview'}) page.p.close() page.div.close() # col # plots page.div(class_='col-md-9', id_='hveto-round-%d-plots' % round.n) page.add(gwhtml.scaffold_plots(round.plots[:-1], nperrow=4)) # add significance drop plot at end page.div(class_='row') page.div(class_='col-sm-12') page.add(gwhtml.fancybox_img(round.plots[-1])) page.div.close() # col-sm-12 page.div.close() # row page.div.close() # col-md-8 page.div.close() # row # close and return page.div.close() # panel-body page.div.close() # panel return page()
def write_summary(rounds, plots=[], header='Summary', plotsperrow=4, tableclass='table table-sm table-hover'): """Write the Hveto analysis summary HTML Parameters ---------- rounds : `list` of `HvetoRound` the `list` of round objects produced by this analysis plots : `list` of `str`, optional the `list` of summary plots to display underneath the summary table header : `str`, optional the text for the section header (``<h2``>) plotsperrow : `int`, optional the number of plots to display in each row tableclass : `str`, optional the ``class`` for the summary ``<table>`` Returns ------- page : `~MarkupPy.markup.page` the formatted markup object containing the analysis summary table, and images """ page = markup.page() page.h2(header, class_='mt-4') page.table(class_=tableclass) page.caption("Summary of this HierarchichalVeto analysis.") # make header page.thead() page.tr() for header in [ 'Round', 'Winner', 'Twin [s]', 'SNR Thresh', 'Significance', 'Use [%]', 'Efficiency [%]', 'Deadtime [%]', 'Cum. efficiency [%]', 'Cum. deadtime [%]' ]: page.th(header, scope='row') page.tr.close() page.thead.close() # make body page.tbody() for r in rounds: page.tr() # link round down page page.td( gwhtml.html_link( '#hveto-round-%d' % r.n, r.n, target=None, title="Jump to round %d details" % r.n, style='color: inherit;', )) # link name to CIS page.td(gwhtml.cis_link(r.winner.name)) for attr in ['window', 'snr', 'significance']: v = getattr(r.winner, attr) if isinstance(v, float): page.td('%.2f' % v) else: page.td(str(v)) for attr in [ 'use_percentage', 'efficiency', 'deadtime', 'cum_efficiency', 'cum_deadtime' ]: a, b = getattr(r, attr) try: pc = a / b * 100. except ZeroDivisionError: pc = 0. if attr.endswith('deadtime'): page.td('%.2f<br><small>[%.2f/%.2f]</small>' % (pc, a, b)) else: page.td('%.2f<br><small>[%d/%d]</small>' % (pc, a, b)) page.tr.close() page.tbody.close() page.table.close() # scaffold plots if plots: page.div(class_='card border-light card-body scaffold shadow-sm') page.add(gwhtml.scaffold_plots(plots, nperrow=plotsperrow)) page.div.close() # card border-light card-body scaffold shadow-sm return page()
def write_summary( rounds, plots=[], header='Summary', plotsperrow=4, tableclass='table table-condensed table-hover table-responsive'): """Write the Hveto analysis summary HTML Parameters ---------- rounds : `list` of `HvetoRound` the `list` of round objects produced by this analysis plots : `list` of `str`, optional the `list` of summary plots to display underneath the summary table header : `str`, optional the text for the section header (``<h2``>) plotsperrow : `int`, optional the number of plots to display in each row tableclass : `str`, optional the ``class`` for the summary ``<table>`` Returns ------- page : `~MarkupPy.markup.page` the formatted markup object containing the analysis summary table, and images """ page = markup.page() page.h2(header) page.table(class_=tableclass) page.caption("Summary of this HierarchichalVeto analysis.") # make header page.thead() page.tr() for header in ['Round', 'Winner', 'Twin [s]', 'SNR Thresh', 'Significance', 'Use [%]', 'Efficiency [%]', 'Deadtime [%]', 'Cum. efficiency [%]', 'Cum. deadtime [%]']: page.th(header, scope='row') page.tr.close() page.thead.close() # make body page.tbody() for r in rounds: page.tr() # link round down page page.td(gwhtml.html_link('#hveto-round-%d' % r.n, r.n, target=None, title="Jump to round %d details" % r.n)) # link name to CIS page.td(gwhtml.cis_link(r.winner.name)) for attr in ['window', 'snr', 'significance']: v = getattr(r.winner, attr) if isinstance(v, float): page.td('%.2f' % v) else: page.td(str(v)) for attr in ['use_percentage', 'efficiency', 'deadtime', 'cum_efficiency', 'cum_deadtime']: a, b = getattr(r, attr) try: pc = a/b * 100. except ZeroDivisionError: pc = 0. if attr.endswith('deadtime'): page.td('%.2f<br><small>[%.2f/%.2f]</small>' % (pc, a, b)) else: page.td('%.2f<br><small>[%d/%d]</small>' % (pc, a, b)) page.tr.close() page.tbody.close() page.table.close() # scaffold plots if plots: page.add(gwhtml.scaffold_plots(plots, nperrow=plotsperrow)) return page()