Esempio n. 1
0
def createPage(droneurl):
    req = Request(droneurl, headers={"X-Api-Key" : apikey})
    try:
        response = urlopen(req)
    except HTTPError as e:
        page.div('HTTPError:' + str(e.code),class_="show")
        writeout(config.get('output', 'filename') + '.html',str(page))  
    except URLError as e:
        page.div('URLError: ' + str(e.reason),class_="show")
        writeout(config.get('output', 'filename') + '.html',str(page))  
    else:
        try:
            data = loads(response.read())
        except ValueError as e:
            page.div('ValueError: ' + str(e),class_="show")
            writeout(config.get('output', 'filename') + '.html',str(page))  
        else:
            if len(data) == 0:
                page.div("Uh oh! Doesn't look like you have any shows today! :(\nAdd more " + nest.a("here!",href=ndbaseurl),class_="show")
                writeout(config.get('output', 'filename') + '.html',str(page))            
            else:
                page.div(config.get('output', 'head'),id="head")
                for x in range(len(data)):
                    title = data[x]['title'].encode('utf-8')
                    series = data[x]['series']['title'].encode('utf-8')
                    airtime = data[x]['series']['airTime'].encode('utf-8')
                    overview = data[x]['overview'].encode('utf-8')
                    banner = data[x]['series']['images'][0]['url'].encode('utf-8')
                    if overview:
                        page.div(nest.img(src=banner,class_="roundimg") + nest.div(series + ": " + title, class_="title") + nest.div(airtime, class_="airtime") + nest.div(overview, class_="overview"), class_="show")
                    else:
                        page.div(nest.img(src=banner,class_="roundimg") + nest.div(series + ": " + title, class_="title") + nest.div(airtime, class_="airtime"), class_="show")
                writeout(config.get('output', 'filename') + '.html',str(page))       
Esempio n. 2
0
    def display(self):
        '''This method serves the Component class and the make_html
        function defined in the cmf_models module.  It returns an html
        description of self and writes a plot to 'eos.jpg'.
        '''
        # Write file named eos.jpg
        fig = plt.figure('eos',figsize=(7,5))
        ax = fig.add_subplot(1,1,1)
        ax.set_xlabel(r'$x/{\rm cm}$')
        ax.set_ylabel(r'$f/{\rm dyn}$')
        x = np.linspace(.4,4,100)
        y = self(x)
        ax.plot(x,y)
        fig.savefig('eos.jpg', format='jpg')

        # Make an html formated return value
        html = oneliner.p('''
        Table of coefficients for spline representation of force
        as a function of position along the barrel''')
        html += oneliner.p(self.get_c().__str__())
        html += oneliner.p('''
        Plot of force as a function of position along the barrel''')
        html += oneliner.img(
            width=700, height=500, alt='plot of eos', src='eos.jpg')
        return html
Esempio n. 3
0
def createPage(droneurl):
    req = Request(droneurl, headers={"X-Api-Key": apikey})
    try:
        response = urlopen(req)
    except HTTPError as e:
        page.div('HTTPError:' + str(e.code), class_="show")
        writeout(config.get('output', 'filename') + '.html', str(page))
    except URLError as e:
        page.div('URLError: ' + str(e.reason), class_="show")
        writeout(config.get('output', 'filename') + '.html', str(page))
    else:
        try:
            data = loads(response.read())
        except ValueError as e:
            page.div('ValueError: ' + str(e), class_="show")
            writeout(config.get('output', 'filename') + '.html', str(page))
        else:
            if len(data) == 0:
                page.div(
                    "Uh oh! Doesn't look like you have any shows today! :(\nAdd more "
                    + nest.a("here!", href=ndbaseurl),
                    class_="show")
                writeout(config.get('output', 'filename') + '.html', str(page))
            else:
                page.div(config.get('output', 'head'), id="head")
                for x in range(len(data)):
                    title = data[x]['title'].encode('utf-8')
                    series = data[x]['series']['title'].encode('utf-8')
                    airtime = data[x]['series']['airTime'].encode('utf-8')
                    overview = data[x]['overview'].encode('utf-8')
                    banner = data[x]['series']['images'][0]['url'].encode(
                        'utf-8')
                    if overview:
                        page.div(
                            nest.img(src=banner, class_="roundimg") +
                            nest.div(series + ": " + title, class_="title") +
                            nest.div(airtime, class_="airtime") +
                            nest.div(overview, class_="overview"),
                            class_="show")
                    else:
                        page.div(
                            nest.img(src=banner, class_="roundimg") +
                            nest.div(series + ": " + title, class_="title") +
                            nest.div(airtime, class_="airtime"),
                            class_="show")
                writeout(config.get('output', 'filename') + '.html', str(page))
Esempio n. 4
0
def putResultsTable(p, b, data, id):
    # p -> page
    # data -> html_filename, pathwayName, summary dictionary (one row per pathway)
    r = data[0]
    summaryVals = r[2]
    header = summaryVals["order"]

    p.table(border=b, id=id, class_='tablesorter')
    p.thead()
    p.tr()
    p.th("Image")
    p.th("Name")
    p.th(header, class_="{sorter:'digit'}")
    p.tr.close()
    p.thead.close()

    p.tbody()
    rowCount = 0
    rowSum = [0 for h in header]
    for r in data:
        htmlFile = r[0]
        pathwayName = r[1]
        summaryVals = r[2]
        p.tr()

        base = os.path.basename(htmlFile)
        #plot of ipls
        p.td(o.a(o.img(src=pngBase + base[:-5] + ".png", width=100),
                 href=base))
        #link to pathway details page
        p.td(o.a(pathwayName, href=base))

        vals = [round(summaryVals[h], 3) for h in header]
        #additional columns of data
        p.td(vals)

        i = 0
        #add data to totals for bottom of page
        for h in header:
            rowSum[i] += summaryVals[h]
            i += 1

        #end of row
        p.tr.close()

    p.tbody.close()
    p.tbody()
    p.tr()
    p.td('')
    p.td('Total')
    # last row in table is sums
    p.td(rowSum)
    p.tr.close()
    p.tbody.close()

    p.table.close()
Esempio n. 5
0
def putResultsTable(p, b, data, id):
    r = data[0]
    summaryVals = r[2]
    header = summaryVals["order"]

    p.table(border=b, id=id, class_='tablesorter')
    p.thead()
    p.tr()
    p.th("Image")
    p.th("Name")
    p.th(header, class_="{sorter:'digit'}")
    p.tr.close()
    p.thead.close()

    p.tbody()
    rowCount = 0
    rowSum = [0 for h in header]
    for r in data:
        htmlFile = r[0]
        pathwayName = r[1]
        summaryVals = r[2]
        p.tr()

        base = os.path.basename(htmlFile)
        p.td(o.a(o.img(src=pngDir + base[:-5] + ".png", width=100), href=base))
        p.td(o.a(pathwayName, href=base))

        vals = [round(summaryVals[h], 3) for h in header]
        p.td(vals)

        i = 0
        for h in header:
            rowSum[i] += summaryVals[h]
            i += 1

        p.tr.close()

    p.tbody.close()
    p.tbody()
    p.tr()
    p.td('')
    p.td('Total')
    p.td(rowSum)
    p.tr.close()
    p.tbody.close()

    p.table.close()
Esempio n. 6
0
def theme_footer(links, noendbody=None):
    print "</table></table>"

##    foot_table = TableLite(border=0, width="100%", align="center",
##                           cellspacing=0, cellpadding=0, bgcolor="#6696bc")
##    cont = Container()

    cont = markup.page()
    cont.table(border=0,width="100%", align="center",
                     cellspacing=0, cellpadding=0, bgcolor="#6696bc")
    cont.tr()
    cont.td()
    

    for i in range(len(links)):
        uri, uritxt = links[i]
        if "/" == uri:
            uri = "/?cat=%s" % module_info["category"]
        elif "" == uri and module_name:
            uri = "/%s" % module_name
        elif "?" == uri[0] and module_name:
            uri = "/%s/%s" % (module_name, uri)
        if 0 == i:
##            cont.append("&nbsp;",
##                             Href(uri, IMG("/images/arrow.jpg",
##                                           align="middle", border="0",
##                                           alt="<-")))
            cont.add("&nbsp;")
            cont.a(e.img(src="/images/arrow.jpg", alt="&lt;-", border="0", align="middle"),href=uri)
            
        else:
            cont.add("&nbsp;")

##        cont.append("&nbsp;", Href(uri, textsub("main_return", uritxt)))
        cont.add("&nbsp;")
        cont.a(textsub("main_return", uritxt),href=uri)
        

##    foot_table.append(TR(TD(cont)))
    cont.td.close()
    cont.tr.close()
    cont.table.close()

    print cont
Esempio n. 7
0
#!/usr/bin/env python

import inspect, os, errno, markup
path = os.path.dirname(os.path.abspath(inspect.getfile(
    inspect.currentframe()))) + '/www/img/'  # script directory
print path

counter = 1
el = len(os.listdir(path))

for f in os.listdir(path):
    if f[0] is ".":
        continue
    page = markup.page()
    page.init(charset="UTF-8")
    from markup import oneliner as e
    if counter + 1 == el:
        page.a(e.img(src='img/' + f, width=1024), href='index1.html')
    else:
        page.a(e.img(src='img/' + f, width=1024),
               href='index' + str(counter + 1) + '.html')
    final = open('www/index' + str(counter) + '.html', 'w')
    counter = counter + 1
    final.write(str(page))
    final.close()
Esempio n. 8
0
def putResultsTable(p, b, data, id):
    # p -> page
    # data -> html_filename, pathwayName, summary dictionary (one row per pathway)
    r = data[0]
    summaryVals = r[2]
    header = summaryVals["order"]

    p.table(border=b, id=id, class_='tablesorter')
    p.thead()
    p.tr()
    p.th("Image")
    p.th("Name")
    p.th(header, class_="{sorter:'digit'}")
    p.tr.close()
    p.thead.close()

    summary_tsv = open(rootDir + '/summary.tsv', 'wb')
    summary_tsv.write(
        "Pathway\tAvg num Alterations\tTotal alterations\tnum genes\tmin mean truth\tmax mean truth\tmin mean any\tmax mean any\tnormalized activity\n"
    )
    p.tbody()
    rowCount = 0
    rowSum = [0 for h in header]
    for r in data:
        htmlFile = r[0]
        pathwayName = r[1]
        summaryVals = r[2]
        p.tr()

        base = os.path.basename(htmlFile)
        #plot of ipls
        p.td(o.a(o.img(src=pngBase + base[:-5] + ".png", width=100),
                 href=base))
        #link to pathway details page
        p.td(o.a(pathwayName, href=base))
        summary_tsv.write(pathwayName + '\t')

        vals = [round(summaryVals[h], 3) for h in header]
        for v in vals:
            summary_tsv.write(str(v) + '\t')
        #additional columns of data
        p.td(vals)

        i = 0
        #add data to totals for bottom of page
        for h in header:
            rowSum[i] += summaryVals[h]
            i += 1

        #end of row
        summary_tsv.write('\n')
        p.tr.close()

    summary_tsv.close()
    p.tbody.close()
    p.tbody()
    p.tr()
    p.td('')
    p.td('Total')
    # last row in table is sums
    p.td(rowSum)
    p.tr.close()
    p.tbody.close()

    p.table.close()
Esempio n. 9
0
def htmloutput(ind_run_name,accuracy,uniquetarget_tr,recall,precision,score,clf,col_names,plots_col_cont_outnames\
,plots_col_cont_true_outnames,plots_col_rad_outnames,plots_bandvprob_outnames,plots_feat_outname\
,plots_feat_per_class_outname,plots_colourvprob_outnames,image_IDs,feat_names,plots_mic_outnames,plots_pearson_outnames\
,plots_mic_contributions_outnames,results_dict,decision_boundaries_outnames,plots_depth_acc_outnames):
        # Make index html
    os.chdir(settings.programpath)
    html_title='Results for run: %s' %ind_run_name
    page = markup.page()
    page.init(title=html_title)
    page.p(page.h3("Results for run: %s" %ind_run_name))
    page.a( "Home",href="index.html")
    page.a( "Example Tree",href="trees.html")
    page.a( "Plots",href="plots.html")
    page.a( "Images",href="images.html")
    page.p( "Accuracy: %s" %accuracy)
    page.p("")
    
    #TABLES
    for j in range(len(results_dict)):
        page.table(border=1)
        page.tr(),page.th(results_dict[j]['run_name'])
        for i in range(len(results_dict[j]['uniquetarget_tr'])):
            page.th(results_dict[j]['uniquetarget_tr'][0][i])
        page.tr.close()
        page.tr(),page.td(),page.b("Recall"),page.td.close()
        for i in range(len(results_dict[j]['recall'])):
            page.td(round(results_dict[j]['recall'][i],5))
        page.tr.close()
        page.tr(),page.td(),page.b("Precision"),page.td.close()
        for i in range(len(results_dict[j]['precision'])):
            page.td(round(results_dict[j]['precision'][i],5))
        page.tr.close()
        page.tr(),page.td(),page.b("F1 Score"),page.td.close()
        for i in range(len(results_dict[j]['score'])):
            page.td(round(results_dict[j]['score'][i],5))
        page.tr.close()
        page.table.close()
    
    # Write out settings
    html_settings=("Number of training objects: %s" %settings.traindatanum,"Number of prediction objects: %s" %settings.predictdatanum\
    ,"","Random Forest Settings:",clf\
    ,"","Features:","    Filters: %s" %settings.filters, "    Colours: %s" %col_names, "    Other: %s" %settings.othertrain)
    page.p(html_settings)
    
    # Save html
    html_file= open("index.html","w")
    html_file.write(page())
    html_file.close()
    
    # Create tree page
    page_tree = markup.page()
    page_tree.init(title=html_title+" Example Tree")
    page_tree.p(page_tree.h3("Results for run: %s Example Tree" %ind_run_name))
    page_tree.a( "Home",href="index.html")
    page_tree.a( "Example Tree",href="trees.html")
    page_tree.a( "Plots",href="plots.html")
    page_tree.a( "Images",href="images.html")
    page_tree.p("Example Tree")
    page_tree.img(src="plots/tree_example.png")
    
    html_file= open("trees.html","w")
    html_file.write(page_tree())
    html_file.close()
    
    # Create pages for plots
    page_plots = markup.page()
    
    page_plots.init(title=html_title+" Plots")
    page_plots.p(page_plots.h3("Results for run: %s Plots" %ind_run_name))
    page_plots.a( "Home",href="index.html")
    page_plots.a( "Example Tree",href="trees.html")
    page_plots.a( "Plots",href="plots.html")
    page_plots.a( "Images",href="images.html")
    page_plots.p("")
    
    page_plots_col_cont = markup.page()
    page_plots_col_cont.init(title=html_title+" Plots_col_cont")
    page_plots_col_cont.p(page_plots_col_cont.h3("Results for run: %s Plots_col_cont" %ind_run_name))
    page_plots_col_cont.a( "Home",href="index.html")
    page_plots_col_cont.a( "Example Tree",href="trees.html")
    page_plots_col_cont.a( "Plots",href="plots.html")
    page_plots_col_cont.a( "Images",href="images.html")
    page_plots_col_cont.p("")
    page_plots_col_cont.a( "plot_col_cont",href="plots_col_cont.html")
    page_plots_col_cont.a( "plot_col_rad",href="plots_col_rad.html")
    page_plots_col_cont.p("")
    
    for i in range(len(plots_col_cont_outnames)):
        page_plots_col_cont.div(style='width: 2000px; height: 600px;',id='cc%s' %i)
        page_plots_col_cont.p(["",plots_col_cont_outnames[i]]),page_plots_col_cont.p(["",plots_col_cont_true_outnames[i]])
        page_plots_col_cont.img(src=plots_col_cont_outnames[i]),page_plots_col_cont.img(src=plots_col_cont_true_outnames[i])
        page_plots_col_cont.div.close()
    
    page_plots_col_rad = markup.page()
    page_plots_col_rad.init(title=html_title+" Plots_col_rad")
    page_plots_col_rad.p(page_plots_col_rad.h3("Results for run: %s Plots_col_rad" %ind_run_name))
    page_plots_col_rad.a( "Home",href="index.html")
    page_plots_col_rad.a( "Example Tree",href="trees.html")
    page_plots_col_rad.a( "Plots",href="plots.html")
    page_plots_col_rad.a( "Images",href="images.html")
    page_plots_col_rad.p("")
    page_plots_col_rad.a( "plot_col_cont",href="plots_col_cont.html")
    page_plots_col_rad.a( "plot_col_rad",href="plots_col_rad.html")
    page_plots_col_rad.p("")
    
    for i in range(len(plots_col_rad_outnames)):
        page_plots_col_rad.p(["",plots_col_rad_outnames[i]])
        page_plots_col_rad.img(src=plots_col_rad_outnames[i])
    
    page_plots.a( "plot_col_cont",href="plots_col_cont.html")
    page_plots.a( "plot_col_rad",href="plots_col_rad.html")
    page_plots.p("")
    page_plots.p("Overall Feature Importance")
    page_plots.img(src=plots_feat_outname)
    page_plots.p("")
    if settings.one_vs_all == 1:
        page_plots.p("Feature importance per class")
        page_plots.img(src=plots_feat_per_class_outname)
    if (settings.plot_mic ==1 and settings.plot_pearson == 1 and settings.plot_mic_cont == 1):
        page_plots.p("Maximal Information Coefficients")    
        for i in range(len(plots_mic_outnames)):
            page_plots.div(style='width: 2000px; height: 600px;')
            page_plots.p(plots_mic_outnames[i]),page_plots.p(plots_pearson_outnames[i])
            page_plots.img(src=plots_mic_outnames[i]),page_plots.img(src=plots_pearson_outnames[i])
            page_plots.div.close()
        
        for i in range(len(plots_mic_contributions_outnames)):
            page_plots.p("MIC of Contribution to P(%s) for each feature"%uniquetarget_tr[0][i])
            page_plots.img(src=plots_mic_contributions_outnames[i])
    if settings.plot_depth_acc == 1:
        for i in range(len(plots_depth_acc_outnames)):
            page_plots.p("Depth Accuracy DERED_R")
            page_plots.img(src=plots_depth_acc_outnames[i])
    if settings.plot_decision_boundaries == 1:
        for i in range(len(decision_boundaries_outnames)):
            page_plots.p("Decision Boundary %s"%i)
            page_plots.img(src=decision_boundaries_outnames[i])
    allfiltplots= [s for s in plots_bandvprob_outnames if 'allfilt' in s]
    for i in range(len(allfiltplots)):
        page_plots.p(["",allfiltplots[i]])
        page_plots.img(src=allfiltplots[i])
    
    allfiltplots_cols= [s for s in plots_colourvprob_outnames if 'allfilt' in s]
    for i in range(len(allfiltplots_cols)):
        page_plots.p(["",allfiltplots_cols[i]])
        page_plots.img(src=allfiltplots_cols[i])
    
    html_file= open("plots.html","w")
    html_file.write(page_plots())
    html_file.close()
    html_file= open("plots_col_rad.html","w")
    html_file.write(page_plots_col_rad())
    html_file.close()
    html_file= open("plots_col_cont.html","w")
    html_file.write(page_plots_col_cont())
    html_file.close()
    # Create pages for images
    page_images = markup.page()
    page_images.init(title=html_title+" Images")
    page_images.p(page_images.h3("Results for run: %s Images" %ind_run_name))
    page_images.a( "Home",href="index.html")
    page_images.a( "Example Tree",href="trees.html")
    page_images.a( "Plots",href="plots.html")
    page_images.a( "Images",href="images.html")
    page_images.p("")
    
    for k in range(len(image_IDs)):
        for j in range(len(image_IDs[k]['good_url'])):
            page_images.p("")
            page_images.table(border=1)
            page_images.tr(),page_images.td(),page_images.a( e.img( src=image_IDs[k]['good_url'][j]), href=image_IDs[k]['good_url_objid'][j]),page_images.td.close(),page_images.td(),page_images.a( e.img( src=image_IDs[k]['good_spectra'][j]),width=200,height=143,href=image_IDs[k]['good_url_objid'][j]),page_images.td.close(),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Class'),page_images.td.close(),page_images.td(str(uniquetarget_tr[0][image_IDs[k]['class']])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Predicted Class'),page_images.td.close(),page_images.td(str(uniquetarget_tr[0][image_IDs[k]['good_result'][j]])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('ObjID'),page_images.td.close(),page_images.td(str(image_IDs[k]['good_ID'][j])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Redshift'),page_images.td.close(),page_images.td(str(image_IDs[k]['good_specz'][j])),page_images.tr.close()
            page_images.table.close()
            
            page_images.table(border=1)
            page_images.tr(),page_images.th("")
            for num in range(len(uniquetarget_tr)):
                page_images.th(uniquetarget_tr[0][num])
            page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b("Probability"),page_images.td.close(),
            for num in range(len(uniquetarget_tr)):            
                page_images.td(str(image_IDs[k]['good_probs'][j][num]))
            page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b("Bias"),page_images.td.close()
            for num in range(len(uniquetarget_tr)):
                page_images.td(str(image_IDs[k]['good_tiresult'][j][1][0][num]))
            page_images.tr.close()
            page_images.table.close()
            page_images.p("Contributions to Probability")
            page_images.table(border=1)
            page_images.tr(),page_images.th(""),page_images.td("Values")
            for num in range(len(uniquetarget_tr)):
                page_images.th(uniquetarget_tr[0][num])
            page_images.tr.close()
            for i in range(len(feat_names)):
                page_images.tr()
                page_images.td(feat_names[i]),page_images.td(str(image_IDs[k]['good_values'][j][i])),
                for num in range(len(uniquetarget_tr)):                
                    page_images.td(round(image_IDs[k]['good_tiresult'][j][2][0][:,num][i],5))
                page_images.tr.close()
    
    for k in range(len(image_IDs)):
        for j in range(len(image_IDs[k]['ok_url'])):
            page_images.p("")
            page_images.table(border=1)
            page_images.tr(),page_images.td(),page_images.a( e.img( src=image_IDs[k]['ok_url'][j]), href=image_IDs[k]['ok_url_objid'][j]),page_images.td.close(),page_images.td(),page_images.a( e.img( src=image_IDs[k]['ok_spectra'][j]),width=200,height=143, href=image_IDs[k]['ok_url_objid'][j]),page_images.td.close(),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Class'),page_images.td.close(),page_images.td(str(uniquetarget_tr[0][image_IDs[k]['class']])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Predicted Class'),page_images.td.close(),page_images.td(str(uniquetarget_tr[0][image_IDs[k]['ok_result'][j]])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('ObjID'),page_images.td.close(),page_images.td(str(image_IDs[k]['ok_ID'][j])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Redshift'),page_images.td.close(),page_images.td(str(image_IDs[k]['ok_specz'][j])),page_images.tr.close()
            page_images.table.close()
            
            page_images.table(border=1)
            page_images.tr(),page_images.th("")
            for num in range(len(uniquetarget_tr)):
                page_images.th(uniquetarget_tr[0][num])
            page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b("Probability"),page_images.td.close(),
            for num in range(len(uniquetarget_tr)):
                page_images.td(str(image_IDs[k]['ok_probs'][j][num]))
            page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b("Bias"),page_images.td.close()
            for num in range(len(uniquetarget_tr)):            
                page_images.td(str(image_IDs[k]['ok_tiresult'][j][1][0][num]))
            page_images.tr.close()
            page_images.table.close()
            page_images.p("Contributions to Probability")       
            page_images.table(border=1)
            page_images.tr(),page_images.th(""),page_images.td("Values")
            for num in range(len(uniquetarget_tr)):
                page_images.th(uniquetarget_tr[0][num])
            page_images.tr.close()
            for i in range(len(feat_names)):
                page_images.tr()
                page_images.td(feat_names[i]),page_images.td(str(image_IDs[k]['ok_values'][j][i]))
                for num in range(len(uniquetarget_tr)):
                    page_images.td(round(image_IDs[k]['ok_tiresult'][j][2][0][:,num][i],5))
                page_images.tr.close()
    
    for k in range(len(image_IDs)):
        for j in range(len(image_IDs[k]['bad_url'])):
            page_images.p("")
            page_images.table(border=1)
            page_images.tr(),page_images.td(),page_images.a( e.img( src=image_IDs[k]['bad_url'][j]), href=image_IDs[k]['bad_url_objid'][j]),page_images.td.close(),page_images.td(),page_images.a( e.img( src=image_IDs[k]['bad_spectra'][j]),width=200,height=143, href=image_IDs[k]['bad_url_objid'][j]),page_images.td.close(),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Class'),page_images.td.close(),page_images.td(str(uniquetarget_tr[0][image_IDs[k]['class']])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Predicted Class'),page_images.td.close(),page_images.td(str(uniquetarget_tr[0][image_IDs[k]['bad_result'][j]])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('ObjID'),page_images.td.close(),page_images.td(str(image_IDs[k]['bad_ID'][j])),page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b('Redshift'),page_images.td.close(),page_images.td(str(image_IDs[k]['bad_specz'][j])),page_images.tr.close()
            page_images.table.close()
            
            page_images.table(border=1)
            page_images.tr(),page_images.th("")
            for num in range(len(uniquetarget_tr)):
                page_images.th(uniquetarget_tr[0][num])
            page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b("Probability"),page_images.td.close()
            for num in range(len(uniquetarget_tr)):
                page_images.td(str(image_IDs[k]['bad_probs'][j][num]))
            page_images.tr.close()
            page_images.tr(),page_images.td(),page_images.b("Bias"),page_images.td.close()
            for num in range(len(uniquetarget_tr)):
                page_images.td(str(image_IDs[k]['bad_tiresult'][j][1][0][num]))
            page_images.tr.close()
            page_images.table.close()
            page_images.p("Contributions to Probability")
            page_images.table(border=1)
            page_images.tr(),page_images.th(""),page_images.td("Values")
            for num in range(len(uniquetarget_tr)):
                page_images.th(uniquetarget_tr[0][num])
            page_images.tr.close()
            for i in range(len(feat_names)):
                page_images.tr()
                page_images.td(feat_names[i]),page_images.td(str(image_IDs[k]['bad_values'][j][i]))
                for num in range(len(uniquetarget_tr)):                
                    page_images.td(round(image_IDs[k]['bad_tiresult'][j][2][0][:,num][i],5))
                page_images.tr.close()
    
    html_file= open("images.html","w")
    html_file.write(page_images())
    html_file.close()
Esempio n. 10
0
#!/usr/bin/env python

import inspect, os, errno, markup
path =  os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))+'/www/img/' # script directory
print path

counter = 1
el = len(os.listdir(path))

for f in os.listdir(path):
	if f[0] is ".":
		continue
	page = markup.page()
	page.init(charset="UTF-8")
	from markup import oneliner as e
	if counter+1 == el:
		page.a(e.img(src='img/'+f, width=1024), href='index1.html')
	else:
		page.a(e.img(src='img/'+f, width=1024), href='index'+str(counter+1)+'.html')
	final = open('www/index'+str(counter)+'.html','w')
	counter = counter + 1
	final.write(str(page))
	final.close()
	

Esempio n. 11
0
def theme_header(title, image=None, help=None, config=None, nomodule=None, nowebmin=None,
                 rightside="", header=None, body=None, below=None):
    acl = read_acl()

    for l in list_languages():
        if l["lang"] == current_lang:
            lang = l    

    if force_charset:
        charset = force_charset
    elif lang.has_key("charset"):
        charset = lang["charset"]
    else:
        charset = "iso-8859-1"    

    print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n\"http://www.w3.org/TR/REC-html40/loose.dtd\">"

    if gconfig.has_key("real_os_type"):
        os_type = gconfig["real_os_type"]
    else:
        os_type = gconfig["os_type"]

    if gconfig.has_key("real_os_version"):
        os_version = gconfig["real_os_version"]
    else:
        os_version = gconfig["os_version"]

    print "<html>\n<head>"
    if (charset):
        print "<meta http-equiv=\"Content-Type\" "\
              "content=\"text/html; charset=%s\">" % charset
    
    print "<link rel='icon' href='images/webmin_icon.png' type='image/png'>"

    if gconfig.get("sysinfo") == 1:
        print "<title>%s : %s on %s (%s %s)</title>" % \
              (title, remote_user, get_system_hostname(), os_type, os_version)
    else:
        print "<title>%s</title>" % title

    if header:
        print header

    # Where does gconfig["sysinfo"] come from? 
    if gconfig.get("sysinfo") == 0 and remote_user:
        print "<SCRIPT LANGUAGE=\"JavaScript\">"
        if os.environ.has_key("SSL_USER"):
            userstring = " (SSL certified)"
        elif os.environ.has_key("LOCAL_USER"):
            userstring = " (Local user)"
        else:
            userstring = ""
        
        print "defaultStatus=\"%s%s logged into %s %s on %s (%s %s)\";" % \
              (remote_user, userstring, text["programname"], get_webmin_version(), 
               get_system_hostname(), os_type, os_version)
        print "</SCRIPT>"

    msc_modules = get_all_module_infos(module_infos_access)

    print "</head>"

    if theme_no_table:
        print '<body bgcolor="#6696bc" link="#000000" vlink="#000000" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" ', body, '>'

    else:
        print '<body bgcolor="#6696bc" link="#000000" vlink="#000000" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" ', body, '>'
        

    if None != session_id:
        logout = "/session_login.cgi?logout=1"
        loicon = "logout.jpg"
        lowidth = 84
        lotext = text["main_logout"]
    else:
        logout = "switch_user.cgi"
        loicon = "switch.jpg"
        lowidth = 27
        lotext = text["main_switch"]


    hpage = markup.page()    

##    top_table = TableLite(width="100%", border="0", cellspacing="0",
##                          cellpadding="0", background="/images/top_bar/bg.jpg",
##                          height="32")
##    t_body = TR()

    hpage.table(width="100%", border="0", cellspacing="0",
                          cellpadding="0", background="/images/top_bar/bg.jpg",
                          height="32")
    hpage.tr()    
    
##    TDList = [TD(IMG("/images/top_bar/left.jpg", height=32),
##                 width=4, nowrap="nowrap"),
##              TD(Href(pytheme_logo_link,
##                      IMG(pytheme_logo, width=99,
##                          height=32,
##                          border="0", alt=pytheme_logo_alt)),
##                 width="100%", nowrap="nowrap")]

    # TODO (Carsten) : missig auto alt tags for images (really needed ?)
    hpage.td(e.img(src="/images/top_bar/left.jpg", height="32"),width="4", nowrap="nowrap")
    hpage.td(width="100%", nowrap="nowrap")
    hpage.a(e.img(src=pytheme_logo,width=99, height=32,alt=pytheme_logo_alt,border=0),href=pytheme_logo_link)
    hpage.td.close()
    

    if not os.environ.has_key("ANONYMOUS_USER"):
        # XXX: acl.get("feedback") might not be correct
        if gconfig.get("nofeedbackcc") != 2 and acl.get("feedback"):
##            TDList.append(TD(Href("/feedback_form.cgi?module=%s" % module_name,
##                                  IMG("/images/top_bar/feedback.jpg", width=97,
##                                      height=32,
##                                      border="0", alt=text["feedback"]))))
            hpage.td()
            hpage.a(e.img(src="/images/top_bar/feedback.jpg",width=97,height=32,border=0,
                       alt=text["feedback"]),href="/feedback_form.cgi?module=%s" % module_name)
            hpage.td.close()
            
##            TDList.append(TD(IMG("/images/top_bar/top_sep.jpg", width=12,
##                                 height=32)))
            hpage.td(e.img(src="/images/top_bar/top_sep.jpg", width=12, height=32))

##        TDList.append(TD(Href(logout,
##                              IMG("/images/top_bar/"+loicon, width=lowidth,
##                                  height=32,
##                                  alt=lotext, border="0"))))
        hpage.td()
        hpage.a(e.img(src="/images/top_bar/"+loicon,width=lowidth ,height=32,border=0,alt=lotext),href=logout)
        hpage.td.close()

##    TDList.append(TD(Div(IMG("/images/top_bar/right.jpg", width=3, height=32)),
##                     width="3"))
    hpage.td(e.div(e.img(src="/images/top_bar/right.jpg", width="3", height="32")),width=3)
    
##    top_table.append(t_body + TDList)

    hpage.tr.close()
    hpage.table.close()

    # print top_table

    

##    cat_top_table = TableLite(width="100%", border="0", cellspacing="0",
##                           cellpadding="0", height="7")
##
##    
##    cat_top_table.append(TR(TD(IMG("/images/top_bar/shadow.jpg",width=8, height=7),
##                           background="/images/top_bar/shadow_bg.jpg",
##                           nowrap="nowrap")))

    hpage.table(width="100%", border="0", cellspacing="0",
                           cellpadding="0", height="7")
    hpage.tr()
    hpage.td(e.img(src="/images/top_bar/shadow.jpg",width=8, height=7),
             background="/images/top_bar/shadow_bg.jpg",nowrap="nowrap")
    hpage.tr.close()
    hpage.table.close()

    # print cat_top_table
    print hpage
   

    catnames = read_file(os.path.join(config_directory, "webmin.catnames"))
    cats = {}

    for module in msc_modules:
        c = module.get("category", "")
        if cats.has_key(c):
            continue
        if catnames.has_key(c):
            cats[c] = catnames[c]
        elif text.has_key("category_%s" % c):
            cats[c] = text["category_%s" % c]
        else:
            mtext = load_language(module["dir"])
            if mtext.has_key("category_%s" % c):
                cats[c] = mtext["category_%s" % c]
            else:
                c = ""
                module["category"] = ""
                cats[c] = text["category_%s" % c]
    sorted_cats = cats.keys()
    sorted_cats.sort()
    sorted_cats.reverse()

    if 0 == len(cats):
        per = 100
    else:
        per = 100.0 / float(len(cats))

    ## Navigation Bar START ##
    # (Carsten) Mode loose_html for the center tag 
    nav_page = markup.page(mode='loose_html')
       
##    nav_table = TableLite(width="100%", border="0", cellspacing="0",
##                          cellpadding="0", height="57",
##                          background="/images/nav/bg.jpg")
    # (Carsten) The background attribute is not in the final html code with HTMLgen
##    nav_table_body = TR(background="/images/nav/bg.jpg")

    nav_page.table(width="100%", border="0", cellspacing="0",
                          cellpadding="0", height="57",
                          background="/images/nav/bg.jpg")
    nav_page.tr(background="/images/nav/bg.jpg")

##    TDList = [TD(IMG("/images/nav/left.jpg", width=3, height=57),
##                 width="6", nowrap="nowrap")]
    nav_page.td(e.img(src="/images/nav/left.jpg", width="3", height="57"),width="6", nowrap="nowrap")

    for cat in sorted_cats:
        uri = "/?cat=%s" % cat
##        cont = Container()
        nav_page.td(nowrap="nowrap")
        nav_page.center()
        nav_page.a(href=uri)
        if cat in available:
            if "" == cat:
##                cont.append(IMG("/images/cats/others.jpg", width=43, height=44,
##                                        border="0", alt=cat))
                nav_page.img(src="/images/cats/others.jpg",width=43, height=44,
                                        border="0", alt=cat)
            else:
##                cont.append(IMG("/images/cats/%s.jpg" % cat, width=43, height=44,
##                                border="0", alt=cat))
                nav_page.img(src="/images/cats/%s.jpg" % cat, width=43, height=44,
                                border="0", alt=cat)

        else:
##            cont.append(IMG("/images/cats/unknown.jpg", width=43, height=44,
##                            border="0", alt=cat))
            nav_page.img(src="/images/cats/unknown.jpg", width=43, height=44,
                            border="0", alt=cat)

##        cont.append(BR())
##        cont.append(chop_font(cats[cat]))
        nav_page.br()
        # (carsten) : str is needed becaus chop_font might return a HTMLgen/markup instance
        nav_page.add(str(chop_font(cats[cat])))
        
                
##        TDList.append(TD(Center(Href(uri, cont)), nowrap="nowrap"))
        nav_page.a.close()
        nav_page.center.close()
        nav_page.td.close()

##        TDList.append(TD(IMG("/images/nav/sep.jpg", width=17, height=57),
##                         width=17))
        nav_page.td(e.img(src="/images/nav/sep.jpg", width=17, height=57),width=17)

##    TDList.append(TD(Container('&nbsp;'), nowrap="nowrap", width="100%"))
    nav_page.td("&nbsp;",nowrap="nowrap", width="100%")

##    nav_table.append(nav_table_body + TDList)

    nav_page.tr.close()
    nav_page.table.close()

    # UGLY!
    # The reason we replace all "\n" with "" is that Mozilla
    # won't render the menu correctly otherwise. GAAAAH!
    # Note (Carsten) : could be done by a simple change in page class
    
    # print str(nav_table).replace("\n", "")
    print str(nav_page).replace("\n", "")
    
    
##    nav_under_table = TableLite(width="100%", border="0", cellspacing="0",
##                                cellpadding="0",
##                                background="/images/nav/bottom_bg.jpg",
##                                height="4")
##
##    nav_under_table.append(TR()+[TD(IMG("/images/nav/bottom_left.jpg",
##                                        width=3, height=4), width="100%")])

##    print nav_under_table

    nav_under_page = markup.page()
    nav_under_page.table(width="100%", border="0", cellspacing="0",cellpadding="0",
                         background="/images/nav/bottom_bg.jpg",height="4")
    nav_under_page.tr()
    nav_under_page.td(e.img(src="/images/nav/bottom_left.jpg",width=3, height=4),width="100%")
    nav_under_page.tr.close()
    nav_under_page.table.close()


##    tab_under_modcats = TableLite(width="100%", border="0",
##                                  cellspacing="0", cellpadding="0",
##                                  background="/images/nav/bottom_shadow2.jpg")
    nav_under_page.table(width="100%", border="0",cellspacing="0",
                         cellpadding="0",background="/images/nav/bottom_shadow2.jpg")

    # ---new/changed display (user) preference tab
##    tab_under_modcats_prefs=None
##    tab_under_modcats_help=None
    ptab_under_modcats_prefs=None
    ptab_under_modcats_help=None
    # woraround because "if ptab_under_modcats_help" causes an error when it is actually not None
    isptab_under_modcats_prefs=False
    isptab_under_modcats_help=False
    
    
    if help:        
        if type(help) == types.ListType:
            helplink =  hlink(text["header_help"], help[0], help[1])
        else:
            helplink = hlink(text["header_help"], help)
##        tab_under_modcats_help = TableLite(border="0",cellspacing="0", cellpadding="0")
##        tab_under_modcats_help.append(TR() + [TD(IMG("/images/tabs/left.jpg", width=12, height="21"),background="/images/tabs/bg.jpg")]+\
##                                [TD(Code(helplink),background="/images/tabs/bg.jpg")]+\
##                                [TD(IMG("/images/tabs/right.jpg", width=15, height="21"),background="/images/tabs/bg.jpg")])    
##        tab_under_modcats_help.append(TR() + [TD(IMG("/images/tabs/right_bottom.jpg", width=12, height="4"))]+\
##                                [TD(IMG("/images/tabs/bottom.jpg", width=17, height="4"),background="/images/tabs/bottom.jpg")]+\
##                                [TD(IMG("/images/tabs/left_bottom.jpg", width=15, height="4"))])

        ptab_under_modcats_help = markup.page()
        ptab_under_modcats_help.table(border="0",cellspacing="0", cellpadding="0")
        ptab_under_modcats_help.tr()
        ptab_under_modcats_help.td(e.img(src="/images/tabs/left.jpg", width=12, height="21"),
                                   background="/images/tabs/bg.jpg")
        # TODO (carsten) : Check what HTMLgen Code(helplink) does - Update: already done?
        ptab_under_modcats_help.td(background="/images/tabs/bg.jpg")
        ptab_under_modcats_help.code(helplink)
        ptab_under_modcats_help.td.close()
        ptab_under_modcats_help.td(e.img(src="/images/tabs/right.jpg", width=15, height="21"),
                                   background="/images/tabs/bg.jpg")
        ptab_under_modcats_help.tr.close()

        ptab_under_modcats_help.tr()
        ptab_under_modcats_help.td(e.img(src="/images/tabs/right_bottom.jpg", width=12, height="4"))
        ptab_under_modcats_help.td(e.img(src="/images/tabs/bottom.jpg", width=17, height="4"),
                                   background="/images/tabs/bottom.jpg")
        ptab_under_modcats_help.td(e.img(src="/images/tabs/left_bottom.jpg", width=15, height="4"))
        ptab_under_modcats_help.tr.close()
        ptab_under_modcats_help.table.close()
        isptab_under_modcats_help = True
        
    
    if config:
        access = get_module_acl();
        if not access.get("noconfig") and not noprefs:
            if user_module_config_directory:
                cprog = "uconfig.cgi"
            else:
                cprog = "config.cgi"            
    
            uri='%s/%s?%s' % (gconfig.get("webprefix", ""), cprog, module_name)	    
##            tab_under_modcats_prefs = TableLite(border="0",cellspacing="0", cellpadding="0")
##            tab_under_modcats_prefs.append(TR() + [TD(IMG("/images/tabs/left.jpg", width=12, height="21"),background="/images/tabs/bg.jpg")]+\
##                                    [TD(Href(uri,text["header_config"]),background="/images/tabs/bg.jpg")]+\
##                                    [TD(IMG("/images/tabs/right.jpg", width=15, height="21"),background="/images/tabs/bg.jpg")])    
##            tab_under_modcats_prefs.append(TR() + [TD(IMG("/images/tabs/right_bottom.jpg", width=12, height="4"))]+\
##                                    [TD(IMG("/images/tabs/bottom.jpg", width=17, height="4"),background="/images/tabs/bottom.jpg")]+\
##                                    [TD(IMG("/images/tabs/left_bottom.jpg", width=15, height="4"))])

            ptab_under_modcats_prefs = markup.page()
            ptab_under_modcats_prefs.table(border="0",cellspacing="0", cellpadding="0")
            ptab_under_modcats_prefs.tr()
            ptab_under_modcats_prefs.td(e.img(src="/images/tabs/left.jpg", width=12, height="21"),
                                        background="/images/tabs/bg.jpg")
            ptab_under_modcats_prefs.td(e.a(text["header_config"],href=uri),background="/images/tabs/bg.jpg")
            ptab_under_modcats_prefs.td(e.img(src="/images/tabs/right.jpg",width=15, height="21"),
                                        background="/images/tabs/bg.jpg")
            ptab_under_modcats_prefs.tr.close()
            ptab_under_modcats_prefs.tr()
            ptab_under_modcats_prefs.td(e.img(src="/images/tabs/right_bottom.jpg", width=12, height="4"))
            ptab_under_modcats_prefs.td(e.img(src="/images/tabs/bottom.jpg", width=17, height="4"),
                                        background="/images/tabs/bottom.jpg")
            ptab_under_modcats_prefs.td(e.img(src="/images/tabs/left_bottom.jpg", width=15, height="4"))
            ptab_under_modcats_prefs.tr.close()
            ptab_under_modcats_prefs.table.close()
            isptab_under_modcats_prefs=True

##    tab_under_modcats_inner = TableLite(width="100%", border="0",
##                                  cellspacing="0", cellpadding="0",
##                                  background="/images/nav/bottom_shadow2.jpg")
##    tab_under_modcats_inner.append(TR() + [TD(IMG("/images/nav/bottom_shadow.jpg", width=43, height="9"))])

    

    # workariund, see above
    # if ptab_under_modcats_prefs or ptab_under_modcats_help:
    if isptab_under_modcats_prefs or isptab_under_modcats_help:
##        tabTR = TR()
        nav_under_page.tr()
        if isptab_under_modcats_help==True:
##            tabTR = tabTR + [TD(tab_under_modcats_help)]
            nav_under_page.td(str(ptab_under_modcats_help))
        if isptab_under_modcats_prefs==True:
##            tabTR = tabTR + [TD(tab_under_modcats_prefs)]
            nav_under_page.td(str(ptab_under_modcats_prefs))            
##        tabTR = tabTR + [TD(tab_under_modcats_inner,background="/images/nav/bottom_shadow2.jpg",width="100%",nowrap="nowarp",valign="top")]
        nav_under_page.td(background="/images/nav/bottom_shadow2.jpg",width="100%",nowrap="nowarp",valign="top")
        # tab_under_modcats_inner 
        nav_under_page.table(width="100%", border="0",cellspacing="0", cellpadding="0",
                         background="/images/nav/bottom_shadow2.jpg")
        nav_under_page.tr()
        nav_under_page.td(e.img(src="/images/nav/bottom_shadow.jpg", width=43, height="9"))
        nav_under_page.tr.close()
        nav_under_page.table.close()
        # end tab_under_modcats_inner
        nav_under_page.td.close()
        nav_under_page.tr.close()

##        tab_under_modcats(tabTR)
        # tab_under_modcats.append(TR() + [TD(tab_under_modcats_prefs)]+ [TD(tab_under_modcats_inner,background="/images/nav/bottom_shadow2.jpg",width="100%",nowrap="nowarp",valign="top")])	
    else:
##        tab_under_modcats.append(TR() + [TD(IMG("/images/nav/bottom_shadow.jpg", width=43, height="9"))])
        nav_under_page.tr()
        nav_under_page.td(e.img(src="/images/nav/bottom_shadow.jpg", width=43, height="9"))
        nav_under_page.tr.close()
    nav_under_page.table.close()
    
##    print tab_under_modcats

    
##    print "<br>"
    nav_under_page.br()
    print nav_under_page
    # ----end new display (user) preference tab


    if not nowebmin:
        title = title.replace("&auml;", "ä")
        title = title.replace("&ouml;", "ö")
        title = title.replace("&uuml;", "ü")
        title = title.replace("&nbsp;", " ")

        print "<!-- ================== New Markup code =================== -->"
##        title_table = TableLite(border=0, cellpadding=0, cellspacing=0,
##                                width="95%", align="center")
##        inr_tt = TableLite(border=0, cellpadding=0, cellspacing=0, height=20)
##        inr_tt_body = TR()
##        inr_tt_TDList = [TD(IMG("/images/tabs/blue_left.jpg", width=13,
##                                height=22), bgcolor="#bae3ff"),
##                         TD(Strong(title), bgcolor="#bae3ff"),
##                         TD(IMG("/images/tabs/blue_right.jpg", width=13,
##                                height=22), bgcolor="#bae3ff")]
##        inr_tt.append(inr_tt_body + inr_tt_TDList)
##        title_table.append(TR(TD(inr_tt)))

        ptitle_table = markup.page()
        ptitle_table.table(border=0, cellpadding=0, cellspacing=0,
                                width="95%", align="center")
        ptitle_table.tr()
        ptitle_table.td()
        ptitle_table.table(border=0, cellpadding=0, cellspacing=0, height=20)
        ptitle_table.tr()
        ptitle_table.td(e.img(src="/images/tabs/blue_left.jpg", width=13,height=22),bgcolor="#bae3ff")
        ptitle_table.td(e.strong(title),bgcolor="#bae3ff")
        ptitle_table.td(e.img(src="/images/tabs/blue_right.jpg", width=13,height=22),bgcolor="#bae3ff")
        ptitle_table.tr.close()
        ptitle_table.table.close()
        ptitle_table.td.close()
        ptitle_table.tr.close()
        ptitle_table.table.close()        

##        print title_table
        print ptitle_table
        print "<!-- ================== New Markup code end =================== -->"
        theme_prebody()
Esempio n. 12
0
def main(initfile, ntop):
    # read configuration options and process
    par = Parameters(initfile)
    gpsb = par.res_param['gpsb']
    gpse = par.res_param['gpse']
    pdir = par.res_param['pdir']
    hdir = par.res_param['hdir']
    data = Data(hdir + 'post_proc_data.dat')

    # relative paths of the stilesheets and javascripts for the results page
    stylesheets = ('general.css', 'table.css', 'modal.css')
    script = 'scripts.js'

    # copy them in the results folder (that should already exist)
    for sheet in stylesheets:
        copy2(os.path.dirname(os.path.abspath(__file__)) + '/' + sheet, hdir)
    copy2(os.path.dirname(os.path.abspath(__file__)) + '/' + script, hdir)

    # Create summary web page
    print "Generating Web Page..."
    page = markup.page()
    page.init(title="NonStatMoni",
              css=stylesheets,
              footer="(2017)" +
              ol.a("Michele Valentini", href='mailto:[email protected]'))

    # best coherences and ccfs summary table generation
    page.button("Auxillary channels summary table", class_="accordion")
    page.div(class_="panel")
    page.input(type="text",
               id="myInput",
               onkeyup="myFunction()",
               placeholder="Search for aux_channel names..")
    page.table(id="t01")
    for aux_name, aux_groups in data.aux_dict.iteritems():
        page.tr()
        page.td()
        page.h4(aux_name)
        page.td.close()
        # Sort the dictionary according to the abs of the values,
        #  from highest to lowest
        ccf_sorted = OrderedDict(
            sorted(data.ccfs[aux_name].iteritems(),
                   key=lambda x: abs(x[1]),
                   reverse=True))
        mean_coh_sorted = OrderedDict(
            sorted(data.mean_cohs[aux_name].iteritems(),
                   key=lambda x: x[1],
                   reverse=True))

        for chan_band, ccf in ccf_sorted.items()[0:4]:
            pagename = 'cohe_{}.html'.format(chan_band.split('_')[0])
            page.td(style="width:10%; font-size :11px;")

            page.add(
                "<a target=_blank href={}#{}>{}</a><br>(ccf={:3f})".format(
                    pagename,
                    aux_name.split(':')[1], chan_band, ccf))
            page.td.close()

        page.td()
        page.add('<a>      ********     </a>')
        page.td.close()

        for chan_band, coh in mean_coh_sorted.items()[0:4]:
            pagename = 'cohe_{}.html'.format(chan_band.split('_')[0])
            page.td(style="width:10%; font-size:11px;")
            page.add(
                '<a target=_blank href={}#{}>{}</a><br>(mncoh={:3f})'.format(
                    pagename,
                    aux_name.split(':')[1], chan_band, coh))
            page.td.close()

        page.tr.close()
    page.table.close()
    page.div.close()

    # build the page menu
    onclick_gen = ("openGroup(event, '{}')".format(group)
                   for group in data.group_dict.keys())
    page.div(ol.button(data.group_dict.keys(),
                       class_='tablinks',
                       onclick=onclick_gen),
             class_='tab')

    # build each group subpage
    for group, g_dict in data.group_dict.iteritems():
        # Build the highest ccf and coherence for this group table
        ccftab = {group: np.zeros(ntop)}
        cohtab = {group: np.zeros(ntop)}
        ccftab_names = {group: np.zeros(ntop, dtype='string')}
        cohtab_names = {group: np.zeros(ntop, dtype='string')}
        cohe_page_name = 'cohe_{}.html'.format(group)
        for aux_n, (aux_name,
                    aux_groups) in enumerate(data.aux_dict.iteritems()):
            if group in aux_groups:
                for band in g_dict['band_list']:
                    if aux_n == 0:
                        ccftab[band] = np.zeros(ntop)
                        cohtab[band] = np.zeros(ntop)
                        ccftab_names[band] = np.zeros(ntop, dtype='string')
                        cohtab_names[band] = np.zeros(ntop, dtype='string')
                    ccf = data.ccfs[aux_name][group + '_' + band]
                    coh = data.mean_cohs[aux_name][group + '_' + band]
                    # todo: build single band tables too
                    if abs(ccf) > min(np.abs(ccftab[band])):
                        ccftab[band] = np.concatenate((ccftab[band], [ccf]))
                        ccftab_names[band] = np.concatenate(
                            (ccftab_names[band], [aux_name]))
                        best_indexes = np.abs(ccftab[band]).argsort()[1:][::-1]
                        ccftab[band] = ccftab[band][best_indexes]
                        ccftab_names[band] = ccftab_names[band][best_indexes]
                    if coh > min(cohtab[band]):
                        cohtab[band] = np.concatenate((cohtab[band], [coh]))
                        cohtab_names[band] = np.concatenate(
                            (cohtab_names[band], [aux_name]))
                        best_indexes = cohtab[band].argsort()[1:][::-1]
                        cohtab[band] = cohtab[band][best_indexes]
                        cohtab_names[band] = cohtab_names[band][best_indexes]

                    # Build the full group best tabs
                    if abs(ccf) > min(np.abs(ccftab[group])):
                        ccftab[group] = np.concatenate((ccftab[group], [ccf]))
                        ccftab_names[group] = np.concatenate(
                            (ccftab_names[group], [aux_name + ' with ' + band
                                                   ]))
                        best_indexes = np.abs(
                            ccftab[group]).argsort()[1:][::-1]
                        ccftab[group] = ccftab[group][best_indexes]
                        ccftab_names[group] = ccftab_names[group][best_indexes]
                    if coh > min(cohtab[group]):
                        cohtab[group] = np.concatenate((cohtab[group], [coh]))
                        cohtab_names[group] = np.concatenate(
                            (cohtab_names[group], [aux_name + ' with ' + band
                                                   ]))
                        best_indexes = cohtab[group].argsort()[1:][::-1]
                        cohtab[group] = cohtab[group][best_indexes]
                        cohtab_names[group] = cohtab_names[group][best_indexes]
        tab = [[" CCF ", "Coherence"]]
        for i in xrange(ntop):
            row = [
                "<a target=_blank href={0}#{1}>{2}</a><br>CCFs = {3:.2f}".
                format(cohe_page_name,
                       ccftab_names[group][i].split(' ')[0].split(':')[1],
                       ccftab_names[group][i], ccftab[group][i]),
                "<a target=_blank href={0}#{1}>{2}</a>"
                "<br>Mean Coher. = {3:.3f}".format(
                    cohe_page_name,
                    cohtab_names[group][i].split(' ')[0].split(':')[1],
                    cohtab_names[group][i], cohtab[group][i])
            ]
            tab.append(row)
        tab_str = OrderedDict({group: tb.tabmaker(tab, True, False)})

        for band in g_dict['band_list']:
            tab = [[" CCF ", "Coherence"]]
            for i in xrange(ntop):
                row = [
                    "<a target=_blank href={0}#{1}>{2}</a><br>CCFs = {3:.2f}".
                    format(cohe_page_name, ccftab_names[band][i].split(':')[1],
                           ccftab_names[band][i], ccftab[band][i]),
                    "<a target=_blank href={0}#{1}>{2}</a>"
                    "<br>Mean Coher. = {3:.3f}".format(
                        cohe_page_name, cohtab_names[band][i].split(':')[1],
                        cohtab_names[band][i], cohtab[band][i])
                ]
                tab.append(row)
            tab_str[band] = tb.tabmaker(tab, True, False)

        # build the rest of the frame
        frame = ol.div(
            ol.h1("NonStatMoni BRMS for {} GPS {:d} - {:d}".format(
                g_dict['channel'], gpsb, gpse),
                  style="display:inline") +
            ol.h3(ol.a("Coherences with slow channels",
                       target='_blank',
                       href=cohe_page_name),
                  style="display:inline"))
        # todo: normalized by what?
        time_title = ol.h2("Normalized BRMS time series")
        time_img = ol.img(class_="myImg",
                          src=pdir + group + "_time.png",
                          alt=group + "Time plot",
                          width="400")
        spec_title = ol.h2("Spectrum of BRMS time series")
        spec_img = ol.img(class_="myImg",
                          src=pdir + group + "_psd.png",
                          alt=group + "PSD plot",
                          width="400")
        frame += ol.div(time_title + time_img + spec_title + spec_img,
                        style="float:left")
        tab_title_gen = (ol.h2("Best Correlations"
                               " and best Coherences for {}".format(c))
                         for c in ([group] + g_dict['band_list']))
        frame += ol.div(
            (title + tbl
             for title, tbl in zip(tab_title_gen, tab_str.values())),
            class_="v_tabcontent",
            id=(['v_' + group] + g_dict['band_list']))
        onclick_gen = ("openBand(event, '{}')".format(band)
                       for band in (['v_' + group] + g_dict['band_list']))

        frame += ol.div(ol.button([group] + g_dict['band_list'],
                                  class_='v_tablinks',
                                  onclick=onclick_gen,
                                  id=['defaultOpen', '']),
                        class_='vertical_tab')

        page.div(frame, id=group, class_='tabcontent')

        # create coherence subpage
        page2 = markup.page()
        page2.init(title="NonStatMoni", css='../style/style.css')
        page2.h1("Coherences with slow channels")
        for aux_name, aux_groups in data.aux_dict.iteritems():
            if group in aux_groups:
                page2.div(ol.img(src=(pdir + group + '_' + 'cohe_' +
                                      aux_name.split(':')[1] + '.png'),
                                 alt=(" No plots for" + aux_name)),
                          id=aux_name.split(':')[1])
        page2.savehtml(hdir + cohe_page_name)

    # create the modal for the plot images
    modal = ol.span("&times;", class_="close")
    modal += ol.img(class_="modal-content", id="img01")
    modal += ol.div('', id="caption")
    page.div(modal, id='myModal', class_="modal")

    page.br()
    page.h2("Contacts")
    page.scripts({script: 'javascript'})
    page.savehtml(hdir + 'index.html')