Exemplo n.º 1
0
def main(country):
    cases, counties = select_country_specific_objects(country)

    def funfig(obj, fig, axes):

        kwargs = subplots[0].read_sliders(obj)

        for subplot in subplots[1:]:

            kwargs.update(subplot.read_sliders(obj))

        if len(subplots) == 1:
            axes = [axes]
        else:
            axes = np.reshape(axes, -1)

        for (subplot, ax) in zip(subplots, axes):

            subplot.plot(ax, cases, counties, **kwargs)

    fig = PlotPyQt.Figure(
        funfig,
        nrows,
        ncols,
        figsize=(5 * ncols, 4.5 * nrows),
    )  #, tight=True, **kwargs)

    for subplot in subplots:

        subplot.add_sliders(fig, cases, counties)

    fig.show()
def main(country):

    from utils import select_country_specific_objects

    cases, counties = select_country_specific_objects(country)

   
    for data in ["infected","cured","deceased"]:
    
        fig, axes = plt.subplots(1, 1, figsize=(6, 4.5))
        
        plot(axes,
             cases,
             counties,
             data,
#             county="Suceava",
             per_capita = True,
             show_mean = True,
             show_new = True,
             show_countrylim="DE",
#             title="",
             )
        
        
        fig.tight_layout()
        
        break
    
    plt.show()
    
    plt.close()
Exemplo n.º 3
0
def main(country):

    from utils import select_country_specific_objects

    cases, counties = select_country_specific_objects(country)
    
   

    for data in ["infected","cured","deceased"]:


        fig, axes = plt.subplots(1, 1, figsize=(6, 4.5))

        for (ax, cmap, new_total) in zip([axes],["YlGnBu",  "viridis"], ["New", "Total"]):
   
            
            P = plot(   ax,
                        cases,
                        counties,
                        new_total,
                        data,
                        prevdays=1,
                        per_capita = True,
                        cmap = cmap,
#                        title = "data",
#                        cbarlabel = "totalnew day popfactor",
                        )
            
            
        fig.tight_layout()
            
        plt.show()
    
        plt.close()

    
        exit()    
Exemplo n.º 4
0
def main(country):
    cases, counties = select_country_specific_objects(country)
    
    start = 13

    folder0 = counties.country_code+"_fig/"
   
    def folder1(task):

        Q = task[0]["totalnew"] if "totalnew" in task[0].keys() else "both"

        return folder0 + task[0]["data"] + "-" + Q

    def prefix_(task):
    
        Q = task[0]["totalnew"] if "totalnew" in task[0].keys() else "both"

        return folder1(task) + "/" + task[0]["data"] + "-" + Q

    def fname_(task,i):
    
        return prefix_(task) + "_" + str(i+50).zfill(3)+".png"
    
    
    
    tasks = [[{ "data": "infected", "totalnew": tn,
                "per_capita": True, "prevdays": 14,
                "window":5},
  
                [10.5,5],       # figsize

                (121,plot_newtotal_vsTime,{"linewidth":4.5}),

                (122,plot_map,{"cmap" : cmap,
                            "vminmax" : [0, vM],
                            "show_colorbar":True}),

            ] for (cmap,tn,vM) in []#("viridis","new",10),("cool","total",800)]

            ]+[
            [ { "data": "infected", 
                "per_capita": True, "prevdays": 14,
                "window":5},
  
                [8.5,5.7],        # figsize

                (224,plot_map,{"cmap" : "plasma", "totalnew": "new",
                            "vminmax" : [0, 10],
                            "title" : "totalnew",
                            "cbarlabel": "",
                            }),

                (211,plot_newtotal_vsTime,
                    {"linewidth":3.7,
                        "title": "Nr. data in county popfactor \n day"
                    }),


                (223,plot_map,{"cmap" : "plasma", "totalnew": "total",
                            "vminmax" : [0, 800],
                            "cbarlabel": "",
                            "title" : "totalnew"}),



            ]]
    
    
    if len(sys.argv) > 1:
        try:
    	    tasks = [tasks[i] for i in map(int, sys.argv[1: ]) if i in range(len(tasks))]
        except:
            pass
    	 # in case sys.argv not provided or cannot be parsed to int
    
    
    for task in filter(lambda t:len(t)>0,tasks):
    
        prefix = prefix_(task)
  
        common_params,figsize,*subplots = task

        for i in cases.get_indices_all_days()[start:]:
    
            fname = fname_(task,i)
   
            print(i-start)

            plt.figure(num=i,figsize=figsize)
            for (ax,subplot,params) in subplots:

            
                plt.subplot(ax)
    
                subplot.plot(plt.gca(), cases, counties, day=cases.get_day(i),
                            **common_params, **params)
    
            plt.tight_layout()
            
            plt.savefig(fname, dpi=300, format="png")
            
            plt.close()
    
    
    
    
    
        for i in range(1,start_padding+1):
    
            cmd = " ".join(["cp",fname_(task,start),fname_(task,start-i)])
    
            os.system(cmd)
    
        for i in range(1,end_padding+1):
    
            cmd = " ".join(["cp", fname_(task, cases.get_dayindex()),
                fname_(task, i + cases.get_dayindex())])
    
    
            os.system(cmd)
    
    
    
    
        cmd = f"ffmpeg -y -f image2 -r {framerate} -pattern_type glob -i '{prefix}_*.png' {folder1(task)}.mp4"
    
        print(cmd)
    
        os.system(cmd)
    
        print()