def process_state(self, state, *args, **kwargs): config = kwargs.get('config', None) # first get all of the segments if self.segmentfile: get_segments(self.flags, state, config=config, cache=self.segmentfile, return_=False) segs = get_segments(self.metaflag, state, padding=self.padding, config=config, query=False) kwargs['segmentcache'] = Cache() else: segs = get_segments(self.metaflag, state, config=config, segdb_error=kwargs.get('segdb_error', 'raise'), padding=self.padding) # then get all of the triggers if self.channel: cache = kwargs.pop('trigcache', None) before = get_triggers(str(self.channel), self.etg, state, config=config, cache=cache, format=self.etgformat) else: before = None # then apply all of the metrics self.results[state] = evaluate_flag( segs, triggers=before, metrics=self.metrics, injections=None, minduration=self.minseglength, vetotag=str(state), channel=str(self.channel), etg=self.etg)[0] vprint(" Veto evaluation results:\n") for metric, val in self.results[state].iteritems(): vprint(' %s: %s\n' % (metric, val)) # then pass to super to make the plots kwargs['trigcache'] = Cache() return super(FlagTab, self).process_state(state, *args, **kwargs)
def write_state_html(self, state): # write results table performance = [(str(m), '%.2f %s' % (r.value, r.unit), m.description.split('\n')[0]) for (m, r) in self.results[state].iteritems()] pre = markup.page() pre.div(class_='scaffold well') pre.strong('Flag performance summary') pre.add( str(data_table(['Metric', 'Result', 'Description'], performance))) pre.div.close() pre.h2('Figures of Merit') # write configuration table post = markup.page() def add_config_entry(title, entry): post.tr() post.th(title) post.td(entry) post.tr.close() post.h2('Analysis configuration') post.div() post.table(class_='table table-condensed table-hover') add_config_entry('Flags', '<br>'.join(map(str, self.flags))) if len(self.flags) > 1 and self.intersection: add_config_entry('Flag combination', 'Intersection (logical AND)') elif len(self.flags) > 1: add_config_entry('Flag combination', 'Union (logical OR)') add_config_entry( 'Analysis start time', '%s (%s)' % (str(Time(float(self.start), format='gps', scale='utc').iso), self.start)) add_config_entry( 'Analysis end time', '%s (%s)' % (str(Time(float(self.end), format='gps', scale='utc').iso), self.end)) add_config_entry('Event trigger channel', str(self.channel)) add_config_entry('Event trigger generator', str(self.etg)) post.table.close() post.div.close() post.h2('Segment information') post.div(class_='panel-group', id="accordion") for i, flag in enumerate([self.metaflag] + self.flags): flag = get_segments(flag, state.active, query=False, padding=self.padding).copy() post.div(class_='panel well panel-primary') post.div(class_='panel-heading') post.a(href='#flag%d' % i, **{ 'data-toggle': 'collapse', 'data-parent': '#accordion' }) if i == 0: post.h4(self.intersection and 'Intersection' or 'Union', class_='panel-title') elif self.labels[i - 1] != str(flag): post.h4('%s (%s)' % (flag.name, self.labels[i - 1]), class_='panel-title') else: post.h4(flag.name, class_='panel-title') post.a.close() post.div.close() post.div(id_='flag%d' % i, class_='panel-collapse collapse') post.div(class_='panel-body') # write segment summary post.p('This flag was defined and had a known state during ' 'the following segments:') post.add(self.print_segments(flag.known)) # write segment table post.p('This flag was active during the following segments:') post.add(self.print_segments(flag.active)) post.div.close() post.div.close() post.div.close() post.div.close() # then write standard data tab return super(get_tab('default'), self).write_state_html(state, plots=True, pre=pre, post=post)
def write_state_html(self, state): # write results table performance = [(str(m), '%.2f %s' % (r.value, r.unit), m.description.split('\n')[0]) for (m, r) in self.results[state].iteritems()] pre = html.markup.page() pre.div(class_='scaffold well') pre.strong('Flag performance summary') pre.add(str(html.table(['Metric', 'Result', 'Description'], performance))) pre.div.close() pre.h2('Figures of Merit') # write configuration table post = html.markup.page() def add_config_entry(title, entry): post.tr() post.th(title) post.td(entry) post.tr.close() post.h2('Analysis configuration') post.div() post.table(class_='table table-condensed table-hover') add_config_entry('Flags', '<br>'.join(map(str, self.flags))) if len(self.flags) > 1 and self.intersection: add_config_entry('Flag combination', 'Intersection (logical AND)') elif len(self.flags) > 1: add_config_entry('Flag combination', 'Union (logical OR)') add_config_entry('Analysis start time', '%s (%s)' % ( str(Time(float(self.start), format='gps', scale='utc').iso), self.start)) add_config_entry('Analysis end time', '%s (%s)' % ( str(Time(float(self.end), format='gps', scale='utc').iso), self.end)) add_config_entry('Event trigger channel', str(self.channel)) add_config_entry('Event trigger generator', str(self.etg)) post.table.close() post.div.close() post.h2('Segment information') post.div(class_='panel-group', id="accordion") for i, flag in enumerate([self.metaflag] + self.flags): flag = get_segments(flag, state.active, query=False, padding=self.padding).copy() post.div(class_='panel well panel-primary') post.div(class_='panel-heading') post.a(href='#flag%d' % i, **{'data-toggle': 'collapse', 'data-parent': '#accordion'}) if i == 0: post.h4(self.intersection and 'Intersection' or 'Union', class_='panel-title') elif self.labels[i-1] != str(flag): post.h4('%s (%s)' % (flag.name, self.labels[i-1]), class_='panel-title') else: post.h4(flag.name, class_='panel-title') post.a.close() post.div.close() post.div(id_='flag%d' % i, class_='panel-collapse collapse') post.div(class_='panel-body') # write segment summary post.p('This flag was defined and had a known state during ' 'the following segments:') post.add(self.print_segments(flag.known)) # write segment table post.p('This flag was active during the following segments:') post.add(self.print_segments(flag.active)) post.div.close() post.div.close() post.div.close() post.div.close() # then write standard data tab return super(get_tab('default'), self).write_state_html( state, plots=True, pre=pre, post=post)
def write_state_html(self, state): """Write the content of inner HTML for the given state """ def format_result(res): fmt = '%d' if ( res.value < 0.01 or (res.unit == Unit('%') and res.value > 99.99)) else '%.2f' return ''.join([fmt % res.value, str(res.unit)]) def add_config_entry(page, title, entry): page.tr() page.th(title) page.td(entry) page.tr.close() # write results table performance = [( str(m), format_result(r), m.description.split('\n')[0], ) for (m, r) in self.results[state].items()] pre = markup.page() pre.p(self.foreword) pre.h4('Flag performance summary', class_='mt-4') pre.add( str( gwhtml.table(['Metric', 'Result', 'Description'], performance, id=self.title))) pre.h2('Figures of Merit', class_='mt-4 mb-2') # write configuration table post = markup.page() post.h2('Analysis configuration', class_='mt-4') post.div() post.table(class_='table table-sm table-hover') add_config_entry(post, 'Flags', '<br>'.join(list(map(str, self.flags)))) if len(self.flags) > 1 and self.intersection: add_config_entry(post, 'Flag combination', 'Intersection (logical AND)') elif len(self.flags) > 1: add_config_entry(post, 'Flag combination', 'Union (logical OR)') add_config_entry( post, 'Analysis start time', '%s (%s)' % (str(Time(float(self.start), format='gps', scale='utc').iso), self.start)) add_config_entry( post, 'Analysis end time', '%s (%s)' % (str(Time(float(self.end), format='gps', scale='utc').iso), self.end)) add_config_entry(post, 'Event trigger channel', str(self.channel)) add_config_entry(post, 'Event trigger generator', str(self.etg)) post.table.close() post.div.close() post.h2('Segment information', class_='mt-4') post.div(class_='mt-2', id="accordion") for i, flag in enumerate([self.metaflag] + self.flags): flag = get_segments(flag, state.active, query=False, padding=self.padding).copy() post.div(class_='card border-info mb-1 shadow-sm') post.div(class_='card-header text-white bg-info') if i == 0: title = self.intersection and 'Intersection' or 'Union' elif self.labels[i - 1] != str(flag): title = '%s (%s)' % (flag.name, self.labels[i - 1]) else: title = flag.name post.a(title, class_='card-link cis-link collapsed', href='#flag%d' % i, **{ 'data-toggle': 'collapse', 'aria-expanded': 'false' }) post.div.close() # card-header post.div(id_='flag%d' % i, class_='collapse', **{'data-parent': '#accordion'}) post.div(class_='card-body') # write segment summary post.p('This flag was defined and had a known state during ' 'the following segments:') post.add(self.print_segments(flag.known)) # write segment table post.p('This flag was active during the following segments:') post.add(self.print_segments(flag.active)) post.div.close() # card-body post.div.close() # collapse post.div.close() # card post.div.close() # then write standard data tab return super(get_tab('default'), self).write_state_html(state, plots=True, pre=pre, post=post)