Beispiel #1
0
    def write_state_html(self, state):
        """Write the '#main' HTML content for this `EventTriggerTab`.
        """
        if self.error.get(state, None):
            level, message = self.error[state]
            # no segments, print warning
            page = html.markup.page()
            page.div(class_='alert alert-%s' % level)
            page.p(message)
            page.p("If you believe this to be an error, please contact %s."
                   % html.markup.oneliner.a('the DetChar group',
                                            class_='alert-link',
                                            href='mailto:[email protected]'))
            page.div.close()
        else:
            # otherwise, carry on...
            page = self.scaffold_plots(state=state)

            # link full results
            if self.url:
                page.hr(class_='row-divider')
                page.div(class_='btn-group')
                page.a('Click here for the full %s results' % self.name,
                       href=self.url, rel='external', target='_blank',
                       class_='btn btn-default btn-info btn-xl')
                page.div.close()
                page.hr(class_='row-divider')

            if self.loudest:
                page.h1('Loudest events')
                page.p('The following table(s) displays the %d loudest events '
                       'as recorded by %s (with at least %s-second '
                       'separation).'
                       % (self.loudest['N'], self.etg, self.loudest['dt']))
                # get triggers
                table = get_triggers(self.channel, self.plots[0].etg, state,
                                     query=False)
                # set table headers
                headers = list(self.loudest['labels'])
                if 'time' in headers[0]:
                    headers.insert(1, 'UTC time')
                    date = True
                else:
                    date = False
                # loop over rank columns
                for rank in self.loudest['rank']:
                    try:
                        rankstr = self.loudest['labels'][
                            self.loudest['columns'].index(rank)]
                    except ValueError:
                        rankstr = repr(rank)
                    page.h3('Loudest events by %s' % rankstr)
                    rank = get_table_column(table, rank).argsort()[::-1]
                    loudest = []
                    i = 0
                    while len(loudest) < self.loudest['N'] and i < rank.size:
                        t = table[rank[i]]
                        if i == 0 or all([
                                abs(float(get_row_value(t, 'time')) -
                                    float(get_row_value(t2, 'time'))) >=
                                self.loudest['dt'] for t2 in loudest]):
                            loudest.append(t)
                        i += 1
                    data = []
                    for row in loudest:
                        data.append([])
                        for column in self.loudest['columns']:
                            data[-1].append(
                                '%.3f' % float(get_row_value(row, column)))
                        if date:
                            data[-1].insert(
                                1,
                                from_gps(get_row_value(
                                    row, self.loudest['columns'][0])).strftime(
                                    '%B %d %Y, %H:%M:%S.%f')[:-3])
                    page.add(str(html.data_table(headers, data, table='data')))

            if self.subplots:
                page.hr(class_='row-divider')
                page.h1('Sub-plots')
                layout = get_mode() == MODE_ENUM['WEEK'] and [7] or [4]
                plist = [p for p in self.subplots if p.state in [state, None]]
                page.add(str(self.scaffold_plots(plots=plist, state=state,
                                                 layout=layout)))

                # link full results
                if self.url:
                    page.hr(class_='row-divider')
                    page.div(class_='btn-group')
                    page.a('Click here for the full %s results' % self.name,
                           href=self.url, rel='external', target='_blank',
                           class_='btn btn-default btn-info btn-xl')
                    page.div.close()
                    page.hr(class_='row-divider')

        # write to file
        idx = self.states.index(state)
        with open(self.frames[idx], 'w') as fobj:
            fobj.write(str(page))
        return self.frames[idx]
Beispiel #2
0
    def write_state_html(self, state):
        """Write the '#main' HTML content for this `EventTriggerTab`.
        """
        if self.error.get(state, None):
            level, message = self.error[state]
            # no segments, print warning
            page = html.markup.page()
            page.div(class_='alert alert-%s' % level)
            page.p(message)
            page.p("If you believe this to be an error, please contact %s." %
                   html.markup.oneliner.a('the DetChar group',
                                          class_='alert-link',
                                          href='mailto:[email protected]'))
            page.div.close()
        else:
            # otherwise, carry on...
            page = self.scaffold_plots(state=state)

            # link full results
            if self.url:
                page.hr(class_='row-divider')
                page.div(class_='btn-group')
                page.a('Click here for the full %s results' % self.name,
                       href=self.url,
                       rel='external',
                       target='_blank',
                       class_='btn btn-default btn-info btn-xl')
                page.div.close()
                page.hr(class_='row-divider')

            if self.loudest:
                page.h1('Loudest events')
                page.p('The following table(s) displays the %d loudest events '
                       'as recorded by %s (with at least %s-second '
                       'separation).' %
                       (self.loudest['N'], self.etg, self.loudest['dt']))
                # get triggers
                table = get_triggers(self.channel,
                                     self.plots[0].etg,
                                     state,
                                     query=False)
                # set table headers
                headers = list(self.loudest['labels'])
                if 'time' in headers[0]:
                    headers.insert(1, 'UTC time')
                    date = True
                else:
                    date = False
                # loop over rank columns
                for rank in self.loudest['rank']:
                    try:
                        rankstr = self.loudest['labels'][
                            self.loudest['columns'].index(rank)]
                    except ValueError:
                        rankstr = repr(rank)
                    page.h3('Loudest events by %s' % rankstr)
                    rank = get_table_column(table, rank).argsort()[::-1]
                    loudest = []
                    i = 0
                    while len(loudest) < self.loudest['N'] and i < rank.size:
                        t = table[rank[i]]
                        if i == 0 or all([
                                abs(
                                    float(get_row_value(t, 'time')) -
                                    float(get_row_value(t2, 'time'))) >=
                                self.loudest['dt'] for t2 in loudest
                        ]):
                            loudest.append(t)
                        i += 1
                    data = []
                    for row in loudest:
                        data.append([])
                        for column in self.loudest['columns']:
                            data[-1].append('%.3f' %
                                            float(get_row_value(row, column)))
                        if date:
                            data[-1].insert(
                                1,
                                from_gps(
                                    get_row_value(
                                        row,
                                        self.loudest['columns'][0])).strftime(
                                            '%B %d %Y, %H:%M:%S.%f')[:-3])
                    page.add(str(html.data_table(headers, data, table='data')))

            if self.subplots:
                page.hr(class_='row-divider')
                page.h1('Sub-plots')
                layout = get_mode() == MODE_ENUM['WEEK'] and [7] or [4]
                plist = [p for p in self.subplots if p.state in [state, None]]
                page.add(
                    str(
                        self.scaffold_plots(plots=plist,
                                            state=state,
                                            layout=layout)))

                # link full results
                if self.url:
                    page.hr(class_='row-divider')
                    page.div(class_='btn-group')
                    page.a('Click here for the full %s results' % self.name,
                           href=self.url,
                           rel='external',
                           target='_blank',
                           class_='btn btn-default btn-info btn-xl')
                    page.div.close()
                    page.hr(class_='row-divider')

        # write to file
        idx = self.states.index(state)
        with open(self.frames[idx], 'w') as fobj:
            fobj.write(str(page))
        return self.frames[idx]
Beispiel #3
0
    def write_state_html(self, state):
        """Write the '#main' HTML content for this `DailyAhopeTab`.
        """
        daydir = os.path.split(self.segmentfile)[0]
        # did it run
        if not os.path.isdir(daydir):
            page = html.markup.page()
            page.div(class_='alert alert-warning')
            page.p("No analysis was performed for this period, "
                   "please try again later.")
            page.p("If you believe these data should have been found, please "
                   "contact %s."
                   % html.markup.oneliner.a('the CBC DQ group',
                                            class_='alert-link',
                                            href='mailto:[email protected]'))
            page.div.close()
        elif (not os.path.isfile(self.segmentfile) or
              len(self.states[0].active) != 0 and
              not os.path.isfile(self.inspiralcachefile)):
            page = html.markup.page()
            page.div(class_='alert alert-danger')
            page.p("This analysis seems to have failed.")
            page.p("If you believe these data should have been found, please "
                   "contact %s."
                   % html.markup.oneliner.a('the CBC DQ group',
                                            class_='alert-link',
                                            href='mailto:[email protected]'))
            page.div.close()
        elif len(self.states[0].active) == 0:
            page = html.markup.page()
            page.div(class_='alert alert-info')
            page.p("This analysis found no segments over which to run.")
            page.p("If you believe this to be an error, please contact %s."
                   % html.markup.oneliner.a('the CBC DQ group',
                                            class_='alert-link',
                                            href='mailto:[email protected]'))
            page.div.close()
        else:
            # otherwise, carry on...
            page = self.scaffold_plots(state=state)

            # link full results
            page.hr(class_='row-divider')
            page.div(class_='btn-group')
            page.a('Click here for the full Daily Ahope results',
                   href=self.ihopepage, rel='external', target='_blank',
                   class_='btn btn-default btn-info btn-xl')
            page.div.close()
            page.hr(class_='row-divider')

            if self.loudest:
                table = get_triggers(self.channel, self.plots[0].etg, state,
                                     query=False)
                rank = get_table_column(
                    table, self.loudest['rank']).argsort()[::-1]
                loudest = []
                i = 0
                while len(loudest) < self.loudest['N'] and i < rank.size:
                    t = table[rank[i]]
                    if i == 0 or all([abs(float(t.get_end()) -
                                          float(t2.get_end())) >=
                                      self.loudest['dt'] for t2 in loudest]):
                        loudest.append(t)
                    i += 1
                page.h1('Loudest events')
                page.p('The following table displays the %d loudest events as '
                       'recorded by Daily Ahope (with at least %s-second '
                       'separation).' % (self.loudest['N'], self.loudest['dt']))
                headers = self.loudest['labels']
                if 'time' in headers[0]:
                    headers.insert(1, 'UTC time')
                    date = True
                else:
                    data = False
                data = []
                for row in loudest:
                    data.append([])
                    for column in self.loudest['columns']:
                        data[-1].append('%.3f' % float(get_row_value(row,
                                                                     column)))
                    if date:
                        data[-1].insert(1, from_gps(row.get_end()).strftime(
                                               '%B %d %Y, %H:%M:%S.%f')[:-3])
                page.add(str(html.data_table(headers, data, table='data')))

            if self.subplots:
                page.hr(class_='row-divider')
                page.h1('Sub-plots')
                layout = get_mode() == MODE_ENUM['WEEK'] and [7] or [4]
                plist = [p for p in self.subplots if p.state in [state, None]]
                page.add(str(self.scaffold_plots(plots=plist, state=state,
                                                 layout=layout)))

                # link full results
                page.hr(class_='row-divider')
                page.div(class_='btn-group')
                page.a('Click here for the full Daily Ahope results',
                       href=self.ihopepage, rel='external', target='_blank',
                       class_='btn btn-default btn-info btn-xl')
                page.div.close()
                page.hr(class_='row-divider')

        # write to file
        idx = self.states.index(state)
        with open(self.frames[idx], 'w') as fobj:
            fobj.write(str(page))
        return self.frames[idx]
Beispiel #4
0
    def write_state_html(self, state):
        """Write the '#main' HTML content for this `DailyAhopeTab`.
        """
        daydir = os.path.split(self.segmentfile)[0]
        # did it run
        if not os.path.isdir(daydir):
            page = html.markup.page()
            page.div(class_='alert alert-warning')
            page.p("No analysis was performed for this period, "
                   "please try again later.")
            page.p("If you believe these data should have been found, please "
                   "contact %s." %
                   html.markup.oneliner.a('the CBC DQ group',
                                          class_='alert-link',
                                          href='mailto:[email protected]'))
            page.div.close()
        elif (not os.path.isfile(self.segmentfile)
              or len(self.states[0].active) != 0
              and not os.path.isfile(self.inspiralcachefile)):
            page = html.markup.page()
            page.div(class_='alert alert-danger')
            page.p("This analysis seems to have failed.")
            page.p("If you believe these data should have been found, please "
                   "contact %s." %
                   html.markup.oneliner.a('the CBC DQ group',
                                          class_='alert-link',
                                          href='mailto:[email protected]'))
            page.div.close()
        elif len(self.states[0].active) == 0:
            page = html.markup.page()
            page.div(class_='alert alert-info')
            page.p("This analysis found no segments over which to run.")
            page.p("If you believe this to be an error, please contact %s." %
                   html.markup.oneliner.a('the CBC DQ group',
                                          class_='alert-link',
                                          href='mailto:[email protected]'))
            page.div.close()
        else:
            # otherwise, carry on...
            page = self.scaffold_plots(state=state)

            # link full results
            page.hr(class_='row-divider')
            page.div(class_='btn-group')
            page.a('Click here for the full Daily Ahope results',
                   href=self.ihopepage,
                   rel='external',
                   target='_blank',
                   class_='btn btn-default btn-info btn-xl')
            page.div.close()
            page.hr(class_='row-divider')

            if self.loudest:
                table = get_triggers(self.channel,
                                     self.plots[0].etg,
                                     state,
                                     query=False)
                rank = get_table_column(table,
                                        self.loudest['rank']).argsort()[::-1]
                loudest = []
                i = 0
                while len(loudest) < self.loudest['N'] and i < rank.size:
                    t = table[rank[i]]
                    if i == 0 or all([
                            abs(float(t.get_end()) - float(t2.get_end())) >=
                            self.loudest['dt'] for t2 in loudest
                    ]):
                        loudest.append(t)
                    i += 1
                page.h1('Loudest events')
                page.p('The following table displays the %d loudest events as '
                       'recorded by Daily Ahope (with at least %s-second '
                       'separation).' %
                       (self.loudest['N'], self.loudest['dt']))
                headers = self.loudest['labels']
                if 'time' in headers[0]:
                    headers.insert(1, 'UTC time')
                    date = True
                else:
                    data = False
                data = []
                for row in loudest:
                    data.append([])
                    for column in self.loudest['columns']:
                        data[-1].append('%.3f' %
                                        float(get_row_value(row, column)))
                    if date:
                        data[-1].insert(
                            1,
                            from_gps(row.get_end()).strftime(
                                '%B %d %Y, %H:%M:%S.%f')[:-3])
                page.add(str(html.data_table(headers, data, table='data')))

            if self.subplots:
                page.hr(class_='row-divider')
                page.h1('Sub-plots')
                layout = get_mode() == MODE_ENUM['WEEK'] and [7] or [4]
                plist = [p for p in self.subplots if p.state in [state, None]]
                page.add(
                    str(
                        self.scaffold_plots(plots=plist,
                                            state=state,
                                            layout=layout)))

                # link full results
                page.hr(class_='row-divider')
                page.div(class_='btn-group')
                page.a('Click here for the full Daily Ahope results',
                       href=self.ihopepage,
                       rel='external',
                       target='_blank',
                       class_='btn btn-default btn-info btn-xl')
                page.div.close()
                page.hr(class_='row-divider')

        # write to file
        idx = self.states.index(state)
        with open(self.frames[idx], 'w') as fobj:
            fobj.write(str(page))
        return self.frames[idx]