Ejemplo n.º 1
0
def main():

    parser = ArgumentParser()
    parser.add_argument('--group',
                        choices=['first', 'second', 'everything'],
                        default='everything')
    parser.add_argument('--area')
    parser.add_argument('-t', '--type', choices=['first', 'second'])
    add_date_arg(parser,
                 help='first release to use',
                 default=earliest_vaccination)
    add_date_arg(parser,
                 '--to-date',
                 default=find_latest('vaccination_cum_*')[1])
    parser.add_argument('--duration', type=float, default=0.2)
    parser.add_argument('--raise-errors', action='store_true')
    args = parser.parse_args()

    if args.type:
        to_show = tuple_product_array(
            [' '.join(w.capitalize() for w in args.area.split('-'))],
            args.type.capitalize())
        name = f'{args.area}_{args.type}'
    else:
        to_show = selection_mapping(args.from_date)[args.group]
        name = args.group

    dates = pd.date_range(args.from_date, args.to_date)
    parallel_render(f'animated_vaccinations_{name}',
                    partial(render_plots, to_show, args.to_date),
                    dates,
                    duration=args.duration,
                    raise_errors=args.raise_errors)
Ejemplo n.º 2
0
def main():
    parser = ArgumentParser()
    parser.add_argument('left', type=series_from_string)
    parser.add_argument('right', type=series_from_string)
    parser.add_argument('--lf')
    parser.add_argument('--rf')
    parser.add_argument('--dpi', type=int, default=Map.dpi)
    parser.add_argument('--width', type=int, default=15)
    parser.add_argument('--height', type=int, default=2)
    add_parallel_args(parser, default_output='none')
    args = parser.parse_args()

    df, data_date = summary_data(args.left + args.right)

    earliest_date = data_start
    latest_date = df.index.max().date()
    to_date = parallel_to_date(args, latest_date)
    dates = pd.date_range(args.from_date, to_date)

    figsize = (args.width, args.height)
    render = partial(render_dt, data_date, earliest_date, latest_date,
                     args.dpi, figsize, args.left, args.right, args.lf,
                     args.rf)

    parallel_render(f'animated_summary_{args.width}_{args.height}', render,
                    dates, **parallel_params(args))
Ejemplo n.º 3
0
def main():
    parser = ArgumentParser()
    add_date_arg(parser, help='first release to use', default=earliest_testing)
    add_parallel_args(parser,
                      default_duration=0.1,
                      default_output='gif',
                      from_date=False)
    parser.add_argument('config', choices=BARS.keys())
    add_date_arg(parser,
                 '--earliest',
                 help='min for x-axis',
                 default=second_wave)
    parser.add_argument('--diff-log-scale', action='store_true')
    parser.add_argument('--diff-no-lims', action='store_true')
    parser.add_argument('--ylim', type=float)
    parser.add_argument('--y-max-factor', type=float, default=1.02)
    args = parser.parse_args()

    config = Bars.get(args.config, earliest=args.earliest)

    from_date = max(args.from_date, args.earliest)
    dates = available_dates(config.metric,
                            config.data_file_stem,
                            earliest=from_date)
    to_date = parallel_to_date(args, dates[0])
    if to_date != dates[0]:
        dates = [d for d in dates if d <= to_date]

    latest_date = dates[0]

    max_metric = config.data_for(latest_date)[0].sum(
        axis=1).max() * args.y_max_factor

    params = {}

    if args.diff_no_lims:
        params['diff_ylims'] = None

    lines = config.lines_for(latest_date)
    if lines:
        params['line_ylim'] = max(l.data.max()
                                  for l in lines) * args.y_max_factor

    parallel_render(
        f'animated_{args.config}',
        partial(plot_bars,
                config=config,
                ylim=args.ylim or max_metric,
                diff_log_scale=args.diff_log_scale,
                show_title=True,
                to_date=date.today(),
                **params), dates,
        **parallel_params(args, item_is_timestamp=False))
Ejemplo n.º 4
0
def main():
    parser = ArgumentParser()
    parser.add_argument('name')
    parser.add_argument('text')
    parser.add_argument('--fontsize', type=int, default=20)
    parser.add_argument('--color', default='black')
    add_parallel_args(parser, default_output='none')
    args = parser.parse_args()

    render = partial(render_text, args.text, args.fontsize, args.color)

    to_date = parallel_to_date(args, date.today())
    dates = pd.date_range(args.from_date, to_date)

    params = parallel_params(args)
    parallel_render(f'animated_text_{args.name}', render, dates, **params)
Ejemplo n.º 5
0
def main():
    parser = ArgumentParser()
    add_parallel_args(parser, default_output='gif', from_date='2020-03-15')
    parser.add_argument('--data-date', default='*')
    add_choices_arg(
        parser, '--series', {
            'cases': 'cases_demographics',
            'deaths': 'deaths_demographics_for_comparison',
        })
    add_choices_arg(parser, '--type', {
        'abs': False,
        'pct': True,
    })
    args = parser.parse_args()

    data_dates = set()
    dates = None
    maxes = {}
    for s in args.series:
        for t in args.type:
            data, data_date, _ = data_for(args.data_date,
                                          s,
                                          earliest=args.from_date,
                                          pct=t)
            data_dates.add(data_date)
            dates = data.index.values
            maxes[s, t] = max(data.max())

    if len(data_dates) != 1:
        parser.error('--data-date, pick one: ' +
                     ', '.join(str(d) for d in sorted(data_dates)))

    name = 'animated_demographics'
    parallel_render(
        name,
        partial(
            plot_date,
            series=args.series,
            types=args.type,
            maxes=maxes,
            from_date=args.from_date,
            data_date=args.data_date,
        ), dates, **parallel_params(args, dates))
Ejemplo n.º 6
0
def main():
    parser = ArgumentParser()
    add_parallel_args(parser,
                      default_duration=0.1,
                      default_output='gif',
                      from_date=False)
    parser.add_argument('--max-cases', type=float, default=1_200_000)
    parser.add_argument('--max-hospital', type=float, default=35_000)
    args = parser.parse_args()

    _, latest_date = load_data()
    dates = pd.date_range('2021-02-19', latest_date)

    parallel_render(
        f'animated_prevalence',
        partial(plot_prevalence,
                max_cases=args.max_cases,
                max_hospital=args.max_hospital,
                latest=latest_date), dates, **parallel_params(args))
Ejemplo n.º 7
0
def main():
    parser = ArgumentParser()
    parser.add_argument('area_type', choices=MAPS.keys())
    parser.add_argument('map')
    parser.add_argument('--bare', action='store_true', help='just the map')
    parser.add_argument('--no-legend', dest='legend', action='store_false', default=True)
    parser.add_argument('--title', help='override title template')
    parser.add_argument('--view', choices=views.keys())
    parser.add_argument('--dpi', type=int)
    parser.add_argument('--top', type=int, help='label the top n areas')
    add_parallel_args(parser, default_duration='slowing')
    args = parser.parse_args()

    map = get_map(args.area_type, args.map)
    view = args.view or map.default_view
    views[view].check()

    df, data_date = map.data

    to_date = parallel_to_date(args, df.index.max().date(), map.default_exclude)
    earliest_date = df.index.min().date()
    dates = pd.date_range(args.from_date, to_date)

    dpi = args.dpi or map.dpi

    render = partial(
        render_dt, data_date, earliest_date, args.area_type, args.map, view,
        args.bare, args.legend, args.title, args.top, dpi
    )

    if args.raise_errors:
        warnings.filterwarnings('error', category=UserWarning)
        os.environ['PYTHONWARNINGS'] = 'error::UserWarning'

    parallel_render(f'animated_map_{map.area_type}_{args.map}_{view}',
                    render, dates, **parallel_params(args, dates))