コード例 #1
0
def write_recovery(page, injList):
    """
        Write injection recovery plots to markup.page object page
    """

    th = [''] + injList
    td = []

    plots = ['sky_error_time', 'sky_error_mchirp', 'sky_error_distance']
    text = { 'sky_error_time':'Sky error vs time',\
                      'sky_error_mchirp':'Sky error vs mchirp',\
                      'sky_error_distance':'Sky error vs distance' }

    for row in plots:
        pTag = text[row]
        d = [pTag]
        for inj in injList:
            plot = markup.page()
            plot = markup.page()
            p = "%s/efficiency_OFFTRIAL_1/found_%s.png" % (inj, row)
            plot.a(href=p, title=pTag)
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    page = write_table(page, th, td)

    return page
コード例 #2
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_recovery(page, injList):

    """
        Write injection recovery plots to markup.page object page
    """

    th = ['']+injList
    td = []

    plots = ['sky_error_time','sky_error_mchirp','sky_error_distance']
    text = { 'sky_error_time':'Sky error vs time',\
                      'sky_error_mchirp':'Sky error vs mchirp',\
                      'sky_error_distance':'Sky error vs distance' }

    for row in plots:
        pTag = text[row]
        d = [pTag]
        for inj in injList:
            plot = markup.page()
            plot = markup.page()
            p = "%s/efficiency_OFFTRIAL_1/found_%s.png" % (inj, row)
            plot.a(href=p, title=pTag)
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    page = write_table(page, th, td)

    return page
コード例 #3
0
ファイル: legacy_grb.py プロジェクト: SergeiOssokine/pycbc
def write_loudest_events(page, bins, onsource=False):

    """
        Write injection chisq plots to markup.page object page
    """

    th = ['']+['Mchirp %s - %s' % tuple(bin) for bin in bins]
    td = []

    plots = ['BestNR','SNR']

    if onsource:
        trial = 'ONSOURCE'
    else:
        trial = 'OFFTRIAL_1'

    for pTag in plots:
        row = pTag.lower()
        d = [pTag]
        for bin in bins:
            b = '%s_%s' % tuple(bin)
            plot = markup.page()
            p = "%s/efficiency/%s_vs_fap_%s.png" % (trial, row, b)
            plot.a(href=p, title="FAP versus %s" % pTag)
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    row = 'snruncut'
    d = ['SNR after cuts <br> have been applied']
    for bin in bins:
        b = '%s_%s' % tuple(bin)
        plot = markup.page()
        p = "%s/efficiency/%s_vs_fap_%s.png" % (trial, row, b)
        plot.a(href=p, title="FAP versus %s" % pTag)
        plot.img(src=p)
        plot.a.close()
        d.append(plot())
    td.append(d)

    page = write_table(page, th, td)

    page.add('For more details on the loudest offsource events see')
    page.a(href='%s/efficiency/loudest_offsource_trigs.html' % (trial))
    page.add('here.')
    page.a.close()


    return page
コード例 #4
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_loudest_events(page, bins, onsource=False):

    """
        Write injection chisq plots to markup.page object page
    """

    th = ['']+['Mchirp %s - %s' % tuple(bin) for bin in bins]
    td = []

    plots = ['BestNR','SNR']

    if onsource:
        trial = 'ONSOURCE'
    else:
        trial = 'OFFTRIAL_1'

    for pTag in plots:
        row = pTag.lower()
        d = [pTag]
        for bin in bins:
            b = '%s_%s' % tuple(bin)
            plot = markup.page()
            p = "%s/efficiency/%s_vs_fap_%s.png" % (trial, row, b)
            plot.a(href=p, title="FAP versus %s" % pTag)
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    row = 'snruncut'
    d = ['SNR after cuts <br> have been applied']
    for bin in bins:
        b = '%s_%s' % tuple(bin)
        plot = markup.page()
        p = "%s/efficiency/%s_vs_fap_%s.png" % (trial, row, b)
        plot.a(href=p, title="FAP versus %s" % pTag)
        plot.img(src=p)
        plot.a.close()
        d.append(plot())
    td.append(d)

    page = write_table(page, th, td)

    page.add('For more details on the loudest offsource events see')
    page.a(href='%s/efficiency/loudest_offsource_trigs.html' % (trial))
    page.add('here.')
    page.a.close()


    return page
コード例 #5
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_chisq(page, injList, grbtag):

    """
        Write injection chisq plots to markup.page object page
    """

    if injList:
        th = ['']+injList + ['OFFSOURCE']
    else:
        th= ['','OFFSOURCE']
        injList = ['OFFSOURCE']
    td = []

    plots = ['bank_veto','auto_veto','chi_square', 'mchirp']

    for test in plots:
        pTag = test.replace('_',' ').title()
        d = [pTag]
        for inj in injList + ['OFFSOURCE']:
            plot = markup.page()
            p = "%s/plots_clustered/GRB%s_%s_vs_snr_zoom.png" % (inj, grbtag,
                                                                 test)
            plot.a(href=p, title="%s %s versus SNR" % (inj, pTag))
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
  
        td.append(d)

    page = write_table(page, th, td)

    return page
コード例 #6
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_inj_snrs(page, ifos, injList, grbtag):

    """
        Write injection chisq plots to markup.page object page
    """

    if injList:
        th = ['']+injList + ['OFFSOURCE']
    else:
        th= ['','OFFSOURCE']
        injList = ['OFFSOURCE']
    td = []

    ifos = [ifos[i:i+2] for i in range(0, len(ifos), 2)]
    plots = ['null_stat2']+['%s_snr' % ifo for ifo in ifos]

    for row in plots:
        pTag = row.replace('_',' ').title()
        d = [pTag]
        for inj in injList + ['OFFSOURCE']:
            plot = markup.page()
            p = "%s/plots_clustered/GRB%s_%s_vs_snr_zoom.png" % (inj, grbtag,
                                                                 row)
            plot.a(href=p, title="%s %s versus SNR" % (inj, pTag))
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    page = write_table(page, th, td)

    return page
コード例 #7
0
def write_inj_snrs(page, ifos, injList, grbtag):
    """
        Write injection chisq plots to markup.page object page
    """

    if injList:
        th = [''] + injList + ['OFFSOURCE']
    else:
        th = ['', 'OFFSOURCE']
        injList = ['OFFSOURCE']
    td = []

    ifos = [ifos[i:i + 2] for i in range(0, len(ifos), 2)]
    plots = ['null_stat2'] + ['%s_snr' % ifo for ifo in ifos]

    for row in plots:
        pTag = row.replace('_', ' ').title()
        d = [pTag]
        for inj in injList + ['OFFSOURCE']:
            plot = markup.page()
            p = "%s/plots_clustered/GRB%s_%s_vs_snr_zoom.png" % (inj, grbtag,
                                                                 row)
            plot.a(href=p, title="%s %s versus SNR" % (inj, pTag))
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    page = write_table(page, th, td)

    return page
コード例 #8
0
def write_chisq(page, injList, grbtag):
    """
        Write injection chisq plots to markup.page object page
    """

    if injList:
        th = [''] + injList + ['OFFSOURCE']
    else:
        th = ['', 'OFFSOURCE']
        injList = ['OFFSOURCE']
    td = []

    plots = ['bank_veto', 'auto_veto', 'chi_square', 'mchirp']

    for test in plots:
        pTag = test.replace('_', ' ').title()
        d = [pTag]
        for inj in injList + ['OFFSOURCE']:
            plot = markup.page()
            p = "%s/plots_clustered/GRB%s_%s_vs_snr_zoom.png" % (inj, grbtag,
                                                                 test)
            plot.a(href=p, title="%s %s versus SNR" % (inj, pTag))
            plot.img(src=p)
            plot.a.close()
            d.append(plot())

        td.append(d)

    page = write_table(page, th, td)

    return page
コード例 #9
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def initialize_page(title, style, script, header=None):
    """
    A function that returns a markup.py page object with the required html
    header.
    """

    page = markup.page(mode="strict_html")
    page._escape = False
    page.init(title=title, css=style, script=script, header=header)

    return page
コード例 #10
0
def initialize_page(title, style, script, header=None):
    """
    A function that returns a markup.py page object with the required html
    header.
    """

    page = markup.page(mode="strict_html")
    page._escape = False
    page.init(title=title, css=style, script=script, header=header)

    return page
コード例 #11
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_offsource(page, args, grbtag, onsource=False):

    """
        Write offsource SNR versus time plots to markup.page object page
    """

    th = ['Re-weighted SNR', 'Coherent SNR']

    if onsource:
        dir = 'ALL_TIMES'
    else:
        dir = 'OFFSOURCE'

    plot = markup.page()
    p = "%s/plots_clustered/GRB%s_bestnr_vs_time_noinj.png" % (dir, grbtag)
    plot.a(href=p, title="Coherent SNR versus time")
    plot.img(src=p)
    plot.a.close()
    td = [ plot() ]

    plot = markup.page()
    p = "%s/plots_clustered/GRB%s_triggers_vs_time_noinj.png" % (dir, grbtag)
    plot.a(href=p, title="Coherent SNR versus time")
    plot.img(src=p)
    plot.a.close()
    td.append(plot())

    ifos = [args.ifo_tag[i:i+2] for i in range(0, len(args.ifo_tag), 2)]
    for ifo in ifos:
        th.append('%s SNR' % ifo)
        plot = markup.page()
        p = "%s/plots_clustered/GRB%s_%s_triggers_vs_time_noinj.png"\
            % (dir, grbtag, ifo)
        plot.a(href=p, title="%s SNR versus time" % ifo)
        plot.img(src=p)
        plot.a.close()
        td.append(plot())

    page = write_table(page, th, td)

    return page
コード例 #12
0
ファイル: legacy_grb.py プロジェクト: SergeiOssokine/pycbc
def write_offsource(page, args, grbtag, onsource=False):

    """
        Write offsource SNR versus time plots to markup.page object page
    """

    th = ['Re-weighted SNR', 'Coherent SNR']

    if onsource:
        dir = 'ALL_TIMES'
    else:
        dir = 'OFFSOURCE'

    plot = markup.page()
    p = "%s/plots_clustered/GRB%s_bestnr_vs_time_noinj.png" % (dir, grbtag)
    plot.a(href=p, title="Coherent SNR versus time")
    plot.img(src=p)
    plot.a.close()
    td = [ plot() ]

    plot = markup.page()
    p = "%s/plots_clustered/GRB%s_triggers_vs_time_noinj.png" % (dir, grbtag)
    plot.a(href=p, title="Coherent SNR versus time")
    plot.img(src=p)
    plot.a.close()
    td.append(plot())

    ifos = [args.ifo_tag[i:i+2] for i in range(0, len(args.ifo_tag), 2)]
    for ifo in ifos:
        th.append('%s SNR' % ifo)
        plot = markup.page()
        p = "%s/plots_clustered/GRB%s_%s_triggers_vs_time_noinj.png"\
            % (dir, grbtag, ifo)
        plot.a(href=p, title="%s SNR versus time" % ifo)
        plot.img(src=p)
        plot.a.close()
        td.append(plot())

    page = write_table(page, th, td)

    return page
コード例 #13
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_found_missed(page, args, injList):

    """
        Write injection found/missed plots to markup.page object page
    """

    th = ['']+injList
    td = []

    #FIXME: Work out a way to make externals calls safely
    #d = ['Number of injections']
    #for inj in injList:
    #    cmmnd = 'lwtprint ../*' + inj + '*MISSED*xml -t sim_inspiral | wc -l'
    #    output,status = make_external_call(cmmnd, shell=True)
    #    numInjs = int(output)
    #    cmmnd = 'lwtprint ../*' + inj + '*FOUND*xml -t sim_inspiral | wc -l'
    #    output,status = make_external_call(cmmnd, shell=True)
    #    numInjs += int(output)
    #    d.append(str(numInjs))
    #td.append(d)

    plots = []
    text  = {}
    ifos = [args.ifo_tag[i:i+2] for i in range(0, len(args.ifo_tag), 2)]
    plots.extend(['dist', 'dist_time'])
    text['dist'] = 'Dist vs Mchirp'
    text['dist_time'] = 'Dist vs Time'
    for ifo in ifos:
        plots.extend(['effdist_%s' % ifo[0].lower(),\
                      'effdist_time_%s' % ifo[0].lower()])
        text['effdist_%s' % ifo[0].lower()] = 'Eff. dist. %s vs Mchirp' % ifo
        text['effdist_time_%s' % ifo[0].lower()] = 'Eff. dist %s vs Time' % ifo

    for row in plots:
        pTag = text[row]
        d = [pTag]
        for inj in injList:
            plot = markup.page()
            p = "%s/efficiency_OFFTRIAL_1/found_missed_injections_%s.png"\
                % (inj, row)
            plot.a(href=p, title=pTag)
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    td.append(['Close injections without FAP = 0']+\
              ['<a href="%s/efficiency_OFFTRIAL_1/quiet_found_triggers.html"> '
               'here</a>' % inj for inj in injList])

    page = write_table(page, th, td)

    return page
コード例 #14
0
ファイル: legacy_grb.py プロジェクト: SergeiOssokine/pycbc
def write_found_missed(page, args, injList):

    """
        Write injection found/missed plots to markup.page object page
    """

    th = ['']+injList
    td = []

    #FIXME: Work out a way to make externals calls safely
    #d = ['Number of injections']
    #for inj in injList:
    #    cmmnd = 'lwtprint ../*' + inj + '*MISSED*xml -t sim_inspiral | wc -l'
    #    output,status = make_external_call(cmmnd, shell=True)
    #    numInjs = int(output)
    #    cmmnd = 'lwtprint ../*' + inj + '*FOUND*xml -t sim_inspiral | wc -l'
    #    output,status = make_external_call(cmmnd, shell=True)
    #    numInjs += int(output)
    #    d.append(str(numInjs))
    #td.append(d)

    plots = []
    text  = {}
    ifos = [args.ifo_tag[i:i+2] for i in range(0, len(args.ifo_tag), 2)]
    plots.extend(['dist', 'dist_time'])
    text['dist'] = 'Dist vs Mchirp'
    text['dist_time'] = 'Dist vs Time'
    for ifo in ifos:
        plots.extend(['effdist_%s' % ifo[0].lower(),\
                      'effdist_time_%s' % ifo[0].lower()])
        text['effdist_%s' % ifo[0].lower()] = 'Eff. dist. %s vs Mchirp' % ifo
        text['effdist_time_%s' % ifo[0].lower()] = 'Eff. dist %s vs Time' % ifo

    for row in plots:
        pTag = text[row]
        d = [pTag]
        for inj in injList:
            plot = markup.page()
            p = "%s/efficiency_OFFTRIAL_1/found_missed_injections_%s.png"\
                % (inj, row)
            plot.a(href=p, title=pTag)
            plot.img(src=p)
            plot.a.close()
            d.append(plot())
        td.append(d)

    td.append(['Close injections without FAP = 0']+\
              ['<a href="%s/efficiency_OFFTRIAL_1/quiet_found_triggers.html"> '
               'here</a>' % inj for inj in injList])

    page = write_table(page, th, td)

    return page
コード例 #15
0
def write_banner(title, text='&nbsp;'):
    """
    Write html <title> tag into markup.page object
    """

    page = markup.page(mode="strict_html")
    page._escape = False

    page.div(id="header")
    page.h1()
    page.add(title)
    page.h1.close()
    page.h3()
    page.add(text)
    page.h3.close()

    page.hr(class_="short")
    page.hr(class_="long")

    page.div.close()

    page.div(id="container")

    return page
コード例 #16
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_banner(title, text='&nbsp;'):
    """
    Write html <title> tag into markup.page object
    """

    page = markup.page(mode="strict_html")
    page._escape = False

    page.div(id="header")
    page.h1()
    page.add(title)
    page.h1.close()
    page.h3()
    page.add(text)
    page.h3.close()

    page.hr(class_="short")
    page.hr(class_="long")

    page.div.close()

    page.div(id="container")

    return page
コード例 #17
0
def write_antenna(page, args, seg_plot=None, grid=False, ipn=False):
    """
    Write antenna factors to merkup.page object page and generate John's
    detector response plot.
    """
    from pylal import antenna

    page.h3()
    page.add('Antenna factors and sky locations')
    page.h3.close()

    th = []
    td = []
    th2 = []
    td2 = []

    ifos = [args.ifo_tag[i:i + 2] for i in range(0, len(args.ifo_tag), 2)]

    if ipn:
        antenna_ifo = {}
        ra = []
        dec = []
        # FIXME: Remove hardcoding here and show this in all cases
        search_file = open('../../../S5IPN_GRB%s_search_180deg.txt' %
                           args.grb_name)
        for line in search_file:
            ra.append(line.split()[0])
            dec.append(line.split()[1])
        for ifo in ifos:
            antenna_ifo[ifo] = []
            for k, l in zip(ra, dec):
                _, _, _, f_q = antenna.response(args.start_time, float(k),
                                                float(l), 0.0, 0.0, 'degree',
                                                ifo)
                antenna_ifo[ifo].append(round(f_q, 3))
        dectKeys = antenna_ifo.keys()

        for elements in range(len(antenna_ifo.values()[0])):
            newDict = {}
            for detectors in range(len(antenna_ifo.keys())):
                newDict[dectKeys[detectors]] = antenna_ifo[\
                                               dectKeys[detectors]][elements]
            for key in newDict.keys():
                th.append(key)
            td.append(newDict.values())
        page = write_table(page, list(set(th)), td)
    for ifo in ifos:
        _, _, _, f_q = antenna.response(args.start_time, args.ra, args.dec,
                                        0.0, 0.0, 'degree', ifo)
        th.append(ifo)
        td.append(round(f_q, 3))

    #FIXME: Work out a way to make these external calls safely
    #cmmnd = 'projectedDetectorTensor --gps-sec %d --ra-deg %f --dec-deg %f' \
    #         % (args.start_time,args.ra, args.dec)
    #for ifo in ifos:
    #    if ifo == 'H1':
    #        cmmnd += ' --display-lho'
    #    elif ifo == 'L1':
    #        cmmnd += ' --display-llo'
    #    elif ifo == 'V1':
    #        cmmnd += ' --display-virgo'
    #status = make_external_call(cmmnd)

    page = write_table(page, th, td)

    #    plot = markup.page()
    #    p = "projtens.png"
    #    plot.a(href=p, title="Detector response and polarization")
    #    plot.img(src=p)
    #    plot.a.close()
    #    th2 = ['Response Diagram']
    #    td2 = [plot() ]

    # FIXME: Add these in!!
    #    plot = markup.page()
    #    p = "ALL_TIMES/plots_clustered/GRB%s_search.png"\
    #        % args.grb_name
    #    plot.a(href=p, title="Error Box Search")
    #    plot.img(src=p)
    #    plot.a.close()
    #    th2.append('Error Box Search')
    #    td2.append(plot())

    #    plot = markup.page()
    #    p = "ALL_TIMES/plots_clustered/GRB%s_simulations.png"\
    #        % args.grb_name
    #    plot.a(href=p, title="Error Box Simulations")
    #    plot.img(src=p)
    #    plot.a.close()
    #    th2.append('Error Box Simulations')
    #    td2.append(plot())

    if seg_plot is not None:
        plot = markup.page()
        p = os.path.basename(seg_plot)
        plot.a(href=p, title="Science Segments")
        plot.img(src=p)
        plot.a.close()
        th2.append('Science Segments')
        td2.append(plot())

    plot = markup.page()
    p = "ALL_TIMES/plots_clustered/GRB%s_sky_grid.png"\
            % args.grb_name
    plot.a(href=p, title="Sky Grid")
    plot.img(src=p)
    plot.a.close()
    th2.append('Sky Grid')
    td2.append(plot())

    #    plot = markup.page()
    #    p = "GRB%s_inspiral_horizon_distance.png"\
    #            % args.grb_name
    #    plot.a(href=p, title="Inspiral Horizon Distance")
    #    plot.img(src=p)
    #    plot.a.close()
    #    th2.append('Inspiral Horizon Distance')
    #    td2.append(plot())

    page = write_table(page, th2, td2)

    return page
コード例 #18
0
def write_exclusion_distances(page,
                              trial,
                              injList,
                              massbins,
                              reduced=False,
                              onsource=False):
    file = open('%s/efficiency/loud_numbers.txt' % (trial), 'r')
    FAPS = []
    for line in file:
        line = line.replace('\n', '')
        if float(line) == -2:
            FAPS.append('No event')
        else:
            FAPS.append(float(line))

    file.close()

    th = [''] + ['Mchirp %s - %s' % tuple(bin) for bin in massbins]
    td = ['FAP'] + FAPS
    page = write_table(page, th, td)
    page.add('For more details on the loudest onsource events see')
    page.a(href='%s/efficiency/loudest_events.html' % (trial))
    page.add('here.')
    page.a.close()

    if reduced or not injList:
        return page

    page.h3()
    page.add('Detection efficiency plots - injections louder than loudest '
             'background trigger')
    page.h3.close()

    th = injList
    td = []
    d = []
    for inj in injList:
        plot = markup.page()
        p = "%s/efficiency_%s/BestNR_max_efficiency.png" % (inj, trial)
        plot.a(href=p, title="Detection efficiency")
        plot.img(src=p)
        plot.a.close()
        d.append(plot())
    td.append(d)

    page = write_table(page, th, td)

    page.h3()
    page.add('Exclusion distance plots - injections louder than loudest '
             'foreground trigger')
    page.h3.close()

    th = injList
    td = []
    d = []
    for inj in injList:
        plot = markup.page()
        p = "%s/efficiency_%s/BestNR_on_efficiency.png" % (inj, trial)
        plot.a(href=p, title="Exclusion efficiency")
        plot.img(src=p)
        plot.a.close()
        d.append(plot())
    td.append(d)

    page = write_table(page, th, td)

    for percentile in [90, 50]:
        page.h3()
        page.add('%d%% confidence exclusion distances (Mpc)' % percentile)
        th = injList
        td = []
        d = []
        for inj in injList:
            file = open(
                '%s/efficiency_%s/exclusion_distance_%d.txt' %
                (inj, trial, percentile), 'r')
            for line in file:
                line = line.replace('\n', '')
                excl_dist = float(line)
            d.append(excl_dist)
            file.close()
        td.append(d)
        page = write_table(page, th, td)

    page.h3.close()

    return page
コード例 #19
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_exclusion_distances(page , trial, injList, massbins, reduced=False,
                              onsource=False):
    file = open('%s/efficiency/loud_numbers.txt' % (trial), 'r')
    FAPS = []
    for line in file:
        line = line.replace('\n','')
        if line == "-2":
            FAPS.append('No event')
        else:
            FAPS.append(line)

    file.close()

    th = ['']+['Mchirp %s - %s' % tuple(bin) for bin in massbins]
    td = ['FAP']+FAPS
    page = write_table(page, th, td)
    page.add('For more details on the loudest onsource events see')
    page.a(href='%s/efficiency/loudest_events.html' % (trial))
    page.add('here.')
    page.a.close()

    if reduced or not injList:
        return page  

    page.h3()
    page.add('Detection efficiency plots - injections louder than loudest '
             'background trigger')
    page.h3.close()

    th = injList
    td = []
    d = []
    for inj in injList:
        plot = markup.page()
        p = "%s/efficiency_%s/BestNR_max_efficiency.png" % (inj, trial)
        plot.a(href=p, title="Detection efficiency")
        plot.img(src=p)
        plot.a.close()
        d.append(plot())
    td.append(d)

    page = write_table(page, th, td)

    page.h3()
    page.add('Exclusion distance plots - injections louder than loudest '
             'foreground trigger')
    page.h3.close()

    th = injList
    td = []
    d = []
    for inj in injList:
        plot = markup.page()
        p = "%s/efficiency_%s/BestNR_on_efficiency.png" % (inj, trial)
        plot.a(href=p, title="Exclusion efficiency")
        plot.img(src=p)
        plot.a.close()
        d.append(plot())
    td.append(d)

    page = write_table(page, th, td)

    for percentile in [90, 50]:
        page.h3()
        page.add('%d%% confidence exclusion distances (Mpc)' % percentile)
        th = injList
        td = []
        d = []
        for inj in injList:
            file = open('%s/efficiency_%s/exclusion_distance_%d.txt'
                        % (inj, trial, percentile), 'r')
            for line in file:
                line = line.replace('\n','')
                excl_dist = float(line)
            d.append(excl_dist)
            file.close()
        td.append(d)
        page = write_table(page, th, td)

    page.h3.close()

    return page
コード例 #20
0
ファイル: legacy_grb.py プロジェクト: cmbiwer/pycbc
def write_antenna(page, args, seg_plot=None, grid=False, ipn=False):

    """
    Write antenna factors to merkup.page object page and generate John's
    detector response plot.
    """
    from pylal import antenna

    page.h3()
    page.add('Antenna factors and sky locations')
    page.h3.close()

    th = []
    td = []
    th2 = []
    td2 = []

    ifos = [args.ifo_tag[i:i+2] for i in range(0, len(args.ifo_tag), 2)]

    if ipn:
        antenna_ifo = {}
        ra = []
        dec = []
        # FIXME: Remove hardcoding here and show this in all cases
        search_file = open('../../../S5IPN_GRB%s_search_180deg.txt'
                           % args.grb_name)
        for line in search_file:
            ra.append(line.split()[0])
            dec.append(line.split()[1])
        for ifo in ifos:
            antenna_ifo[ifo] = []
            for k, l in zip(ra, dec):
                _, _, _, f_q = antenna.response(args.start_time, float(k),
                                                float(l), 0.0, 0.0, 'degree',
                                                ifo)
                antenna_ifo[ifo].append(round(f_q,3))
        dectKeys = antenna_ifo.keys()

        for elements in range(len(antenna_ifo.values()[0])):
            newDict={}
            for detectors in range(len(antenna_ifo.keys())):
                newDict[dectKeys[detectors]] = antenna_ifo[\
                                               dectKeys[detectors]][elements]
            for key in newDict.keys():
                th.append(key)
            td.append(newDict.values())        
        page = write_table(page, list(set(th)), td)
    for ifo in ifos:
        _, _, _, f_q = antenna.response(args.start_time, args.ra, args.dec,
                                        0.0, 0.0, 'degree',ifo)
        th.append(ifo)
        td.append(round(f_q, 3))

    #FIXME: Work out a way to make these external calls safely
    #cmmnd = 'projectedDetectorTensor --gps-sec %d --ra-deg %f --dec-deg %f' \
    #         % (args.start_time,args.ra, args.dec)
    #for ifo in ifos:
    #    if ifo == 'H1':
    #        cmmnd += ' --display-lho'
    #    elif ifo == 'L1':
    #        cmmnd += ' --display-llo'
    #    elif ifo == 'V1':
    #        cmmnd += ' --display-virgo'
    #status = make_external_call(cmmnd)

    page = write_table(page, th, td)

#    plot = markup.page()
#    p = "projtens.png"
#    plot.a(href=p, title="Detector response and polarization")
#    plot.img(src=p)
#    plot.a.close()
#    th2 = ['Response Diagram']
#    td2 = [plot() ]

        # FIXME: Add these in!!
#    plot = markup.page()
#    p = "ALL_TIMES/plots_clustered/GRB%s_search.png"\
#        % args.grb_name
#    plot.a(href=p, title="Error Box Search")
#    plot.img(src=p)
#    plot.a.close()
#    th2.append('Error Box Search')
#    td2.append(plot())

#    plot = markup.page()
#    p = "ALL_TIMES/plots_clustered/GRB%s_simulations.png"\
#        % args.grb_name
#    plot.a(href=p, title="Error Box Simulations")
#    plot.img(src=p)
#    plot.a.close()
#    th2.append('Error Box Simulations')
#    td2.append(plot())

    if seg_plot is not None:
        plot = markup.page()
        p = os.path.basename(seg_plot)
        plot.a(href=p, title="Science Segments")
        plot.img(src=p)
        plot.a.close()
        th2.append('Science Segments')
        td2.append(plot())

    plot = markup.page()
    p = "ALL_TIMES/plots_clustered/GRB%s_sky_grid.png"\
            % args.grb_name
    plot.a(href=p, title="Sky Grid")
    plot.img(src=p)
    plot.a.close()
    th2.append('Sky Grid')
    td2.append(plot())

#    plot = markup.page()
#    p = "GRB%s_inspiral_horizon_distance.png"\
#            % args.grb_name
#    plot.a(href=p, title="Inspiral Horizon Distance")
#    plot.img(src=p)
#    plot.a.close()
#    th2.append('Inspiral Horizon Distance')
#    td2.append(plot())

    page = write_table(page, th2, td2)

    return page