예제 #1
0
def plot_all_Bundeslaender(ts, bnn, dates, datacolumns, ifPrint=True):
    ts_BuLa, Bundeslaender = dataMangling.join_tables_for_and_aggregate_Bundeslaender(
        ts, bnn)
    filenames, population = [], 0
    done = []
    for BL in Bundeslaender.index.tolist():
        print(BL, end=" ")
        daily, cumulative, title, filename, pop_BL = dataMangling.get_BuLa(
            Bundeslaender, BL, datacolumns)
        if BL == "Deutschland":
            filename = filename.replace("bundesland_", "")
        plot_timeseries(datacolumns,
                        dates,
                        daily,
                        cumulative,
                        title,
                        filename=filename,
                        ifShow=False)
        filenames.append(filename)
        population += pop_BL
        if ifPrint:
            print(title, filename)
        done.append((title, filename))
    print("\nTotal population covered:", population)
    if ifPrint:
        print("%d filenames written: %s" % (len(filenames), filenames))
    return done
예제 #2
0
def Bundeslaender_alle(Bundeslaender, ts, ts_sorted, datacolumns, bnn,
                       distances, cmap, km, haupt):
    print("Creating HTML files for all 'Bundeslaender'")
    filenames, population = [], 0
    rootpath = os.path.abspath(dataFiles.REPO_PATH)

    for BL_name in Bundeslaender.index.tolist():
        # for BL_name in ["Dummyland"]:
        if BL_name == "Deutschland":
            continue
        print(BL_name, end=" ")
        daily, cumulative, title, filename_PNG, pop_BL = dataMangling.get_BuLa(
            Bundeslaender, BL_name, datacolumns)
        filename_HTML = filename_PNG.replace(".png", ".html")
        filename_HTML = filename_HTML.replace("bundesland_", "")

        fn = bundesland(BL_name, filename_PNG, title, pop_BL, cumulative,
                        filename_HTML, ts, ts_sorted, datacolumns, bnn,
                        distances, cmap, km, haupt)
        fn_abs = os.path.abspath(fn).replace(rootpath, "")

        filenames.append((BL_name, fn_abs))
        population += pop_BL
    print("\nTotal population covered:", population)
    print("%d filenames written: %s" % (len(filenames), filenames))

    return filenames
예제 #3
0
def test_plot_Bundesland(ts, bnn, dates, datacolumns, Bundesland="Hessen"):
    ## Bundesland
    # Bundesland = "Dummyland"

    ts_BuLa, Bundeslaender = dataMangling.join_tables_for_and_aggregate_Bundeslaender(
        ts, bnn)
    daily, cumulative, title, filename, population = dataMangling.get_BuLa(
        Bundeslaender, Bundesland, datacolumns)
    plot_timeseries(datacolumns,
                    dates,
                    daily,
                    cumulative,
                    title,
                    filename=filename)
예제 #4
0
def BuLas_to_HTML_table(Bundeslaender,
                        datacolumns,
                        BL_names,
                        cmap,
                        table_filename="bundeslaender_Germany.html",
                        rolling_window_size=3,
                        header=PAGE % "Bundeslaender",
                        footer=PAGE_END,
                        divEnveloped=True):

    # total_max_cum, digits = maxdata(ts_sorted)

    tid = "table_bundeslaender"
    page = header
    if divEnveloped:
        page += '<div class="tablearea" id="tablediv_bundeslaender">'
    page += '<table id="%s" class="tableFixHead">\n' % tid
    caption = "Click on column header name, to sort by that column; click again for other direction."
    page += '<caption style="text-align:right;">%s</caption>' % caption
    page += "<tr>"

    for col in datacolumns:
        page += "<th><span>%s</span></th>" % col
    colcount = len(datacolumns)

    cols = [
        "7days new cases", "Bundesland", "info", "Prev. p.1mio",
        "7days Incid.p.1mio", "Population", "expectation day", "Reff_4_7"
    ]

    for i, colName in enumerate(cols):
        cellid = "\'%shc%d\'" % (tid, i + colcount)
        page += '<th onclick="sortTable(\'%s\', %d, %s)" id=%s>%s</th>' % (
            tid, i + colcount, cellid, cellid, colName)
    page += "</tr>"

    for name_BL in BL_names:
        labels = []
        daily, cumulative, title, filename, pop_BL = dataMangling.get_BuLa(
            Bundeslaender, name_BL, datacolumns)
        labels += ['%d' % (Bundeslaender["new_last7days"][name_BL])]
        labels += [bulaLink(name_BL)]
        labels += [flag_image(name_BL)]
        labels += [
            "%d" % prevalence(datatable=Bundeslaender,
                              row_index=name_BL,
                              datacolumns=datacolumns,
                              population=pop_BL)
        ]
        labels += [
            '%d' % (1000000 * Bundeslaender["new_last7days"][name_BL] / pop_BL)
        ]
        labels += ['{:,}'.format(pop_BL)]
        labels += ["%.2f" % (Bundeslaender["centerday"][name_BL])]
        labels += ["%.2f" % (Bundeslaender["Reff_4_7_last"][name_BL])]
        page += toHTMLRow(Bundeslaender,
                          name_BL,
                          datacolumns,
                          cmap,
                          labels,
                          rolling_window_size=rolling_window_size) + "\n"

    page += "</table>"
    if divEnveloped:
        page += " </div>"
    page += ATTRIBUTION + footer

    fn = None
    if table_filename:
        fn = os.path.join(dataFiles.PAGES_PATH, table_filename)
        with open(fn, "w") as f:
            f.write(page)

    return fn, page