ov = {'x': [], 'y': []}

date_range = brondata.getDateRange(metenisweten)
lastDays = arguments.lastDays()
if (lastDays > 0):
    date_range = date_range[-lastDays:]

for d in date_range:
    datum = d.strftime("%Y-%m-%d")

    if datum not in metenisweten:
        continue

    value = metenisweten[datum]['mobiliteit']['rijden']
    if value:
        rijden['x'].append(dateCache.parse(datum))
        rijden['y'].append(value)

    if 'OV' in metenisweten[datum]['mobiliteit']:
        value = metenisweten[datum]['mobiliteit']['OV']
        if value:
            ov['x'].append(dateCache.parse(datum))
            ov['y'].append(value)

    value = metenisweten[datum]['mobiliteit']['lopen']
    if value:
        lopen['x'].append(dateCache.parse(datum))
        lopen['y'].append(value)

rijden['y'] = brondata.double_savgol(rijden['y'], 1, 13, 1)
#ov['y'] = brondata.smooth(ov['y'])
totaaltests = {'x': [], 'y': [], 'total': 0}

positief_percentage = {'x': [], 'y': []}

date_range = brondata.getDateRange(metenisweten)

lastDays = arguments.lastDays()
if (lastDays > 0):
    date_range = date_range[-lastDays:]

for d in date_range:
    datum = d.strftime("%Y-%m-%d")

    # --------------------------------- Normale grafieken (exclusief data van vandaag want dat is altijd incompleet)
    if datum in metenisweten and dateCache.parse(datum).date() <= (
            dateCache.today()):
        # positief['x'].append(dateCache.parse(datum))
        # positief['y'].append(metenisweten[datum]['positief'])

        if 'rivm_totaal_tests' in metenisweten[datum] and metenisweten[datum][
                'rivm_totaal_tests']:
            totaaltests['x'].append(dateCache.parse(datum))
            totaaltests['y'].append(metenisweten[datum]['rivm_totaal_tests'])
            totaaltests['total'] += int(
                metenisweten[datum]['rivm_totaal_tests'])
        elif 'rivm_totaal_personen_getest' in metenisweten[
                datum] and metenisweten[datum]['rivm_totaal_personen_getest']:
            totaaltests['x'].append(dateCache.parse(datum))
            totaaltests['y'].append(
                metenisweten[datum]['rivm_totaal_personen_getest'])
Beispiel #3
0
        'yellow',
        'limegreen',
    ),
    baseline='zero')

totaal_prikken = decimalstring(vaccins_delta['totaal'][-1])

ax1.plot(vaccins_delta['x'],
         vaccins_delta['totaal'],
         color='black',
         label='Totaal per dag (nu: %s)' % totaal_prikken)

graphname = 'vaccins'
for event in events:
    if graphname in event \
        and dateCache.parse(event[graphname][0]) > date_range[0]\
        and (len(event[graphname]) <= 2 or len(date_range) <= event[graphname][2]):
        anotate(ax1, vaccins_delta['x'], vaccins_delta['totaal'],
                event['date'], event['event'], event[graphname][0],
                event[graphname][1])

# Put vertical line at current day
plt.text(x=dateCache.today(),
         y=0,
         s=datetime.now().strftime("%d"),
         color="white",
         fontsize=8,
         ha="center",
         va="center",
         bbox=dict(boxstyle='round,pad=0.1',
                   facecolor='red',
ic_voorspeld = {'x': [], 'y': [], 'avgsize': 3}

besmettingsgraad = {'x': [], 'y': []}

date_range = brondata.getDateRange(metenisweten)

lastDays = arguments.lastDays()
if (lastDays > 0):
    date_range = date_range[-lastDays:]

for d in date_range:
    datum = d.strftime("%Y-%m-%d")

    # ------------ Totaal positief en laatste meetdatum
    if datum in metenisweten and dateCache.parse(
            datum).date() <= dateCache.today():
        totaal_positief = metenisweten[datum]['totaal_positief']

        if metenisweten[datum]['rivm-datum']:
            filedate = metenisweten[datum]['rivm-datum']

    # --------------- Opname en IC data van vandaag en gisteren zijn niet compleet, niet tonen
    if datum in metenisweten and dateCache.parse(datum).date() <= (
            dateCache.today() - datetime.timedelta(days=3)):
        if 'nu_op_ic' in metenisweten[datum] and metenisweten[datum][
                'nu_op_ic']:
            ic['x'].append(dateCache.parse(datum))
            ic['y'].append(metenisweten[datum]['nu_op_ic'])

            if len(ic['y']) > 1:
                ic['rc'].append(ic['y'][-1] - ic['y'][-2])
Beispiel #5
0
# The heatmap data is already in metenisweten, we can optimze. Complete this:
# metenisweten = brondata.readjson('../cache/daily-stats.json')
# print("Converting records to x/y data")
# for date_statistics in metenisweten:
#     if date_statistics > startdate:
#         for age in metenisweten[date_statistics]['besmettingleeftijd']:
#             datax = (date_statistics - startdate).days
#             datay = metenisweten[date_statistics]['besmettingleeftijd']

datelog = []

with open('../cache/COVID-19_casus_landelijk.json', 'r') as json_file:
    data = json.load(json_file)
    print("Converting records to x/y data")
    for record in data:
        date_statistics = dateCache.parse(record['Date_statistics'])
        if date_statistics >= startdate:
            datelog.append(date_statistics)
            try:
                datax = (date_statistics - startdate).days
                datay = int(record['Agegroup'].split('-')[0].split('+')[0])+5
                filedate = record['Date_file']
                x.append(datax)
                y.append(datay)

                # if datax not in weightsmap:
                #     weightsmap[datax] = 1
                # else:
                #     weightsmap[datax] = weightsmap[datax] + 1

            except ValueError:
Beispiel #6
0
#!/usr/bin/env python3
#
from matplotlib import pyplot as plt

from modules.brondata import dateCache


datestr ='2021-06-19'
print(datestr)
print(dateCache.parse(datestr))

Beispiel #7
0
lastDays = arguments.lastDays()
if (lastDays>0):
    date_range = date_range[-lastDays:]

print('Generating Rt graph...')

Rt_avg = {    'x':[],    'y':[]}
Rt_low = {    'x':[],    'y':[]}
Rt_up  = {    'x':[],    'y':[]}

for d in date_range:
    datum = d.strftime("%Y-%m-%d")

    if datum in metenisweten and metenisweten[datum]['Rt_avg'] is not None:
        Rt_avg['x'].append(dateCache.parse(datum))
        Rt_avg['y'].append(float(metenisweten[datum]['Rt_avg']))
    if datum in metenisweten and metenisweten[datum]['Rt_up'] is not None:
        Rt_up['x'].append(dateCache.parse(datum))
        Rt_up['y'].append(float(metenisweten[datum]['Rt_up']))
    if datum in metenisweten and metenisweten[datum]['Rt_low'] is not None:
        Rt_low['x'].append(dateCache.parse(datum))
        Rt_low['y'].append(float(metenisweten[datum]['Rt_low']))


plt.figure(figsize=(10,3))
plt.subplots_adjust(bottom=0.2, left=0.09, right=0.91)
plt.grid(which='both', axis='both', linestyle='-.',
         color='gray', linewidth=1, alpha=0.3)
plt.plot(Rt_avg['x'], Rt_avg['y'], color='black', label='Rt_avg')
plt.plot(Rt_up['x'], Rt_up['y'], color='gray', linestyle='--', alpha=0.3)
Beispiel #8
0
outputdir = '../docs'

metenisweten = brondata.readjson('../cache/daily-stats.json')

dates = []

gemiddeldeleeftijdarray = []
# Assumes last records are newest
for date in metenisweten:
    dates.append(date)

    totaal_positief = metenisweten[date]['totaal_positief']
    totaal_positief_datum = date

    if date in metenisweten \
       and dateCache.parse(date).date() <= (dateCache.today() - datetime.timedelta(days=3))\
       and 'nu_op_ic' in metenisweten[date] and metenisweten[date]['nu_op_ic']:

        # print(str(date)+' '+str(metenisweten[date]['nu_op_ic']))
        nu_op_ic = metenisweten[date]['nu_op_ic']
        nu_op_ic_datum = date

    if date in metenisweten \
       and dateCache.parse(date).date() <= (dateCache.today() - datetime.timedelta(days=3))\
       and 'nu_opgenomen' in metenisweten[date] and metenisweten[date]['nu_opgenomen']:

        # print(str(date)+' '+str(metenisweten[date]['nu_opgenomen']))
        nu_opgenomen = metenisweten[date]['nu_opgenomen']
        nu_opgenomen_datum = date

    if metenisweten[date]['rivm_schatting_besmettelijk']['value']:
    d = record['Date_of_statistics_week_start']
    c = record['Variant_code']

    if d not in varianten_map:
        varianten_map[d] = {}

    if c not in varianten_map[d]:
        varianten_map[d][c] = {}

    varianten_map[d][c]['cases'] = record['Variant_cases']
    varianten_map[d][c]['size'] = record['Sample_size']

# Take al variant percentages and multiply them with the actual number of sick people on that day
for key in varianten_map:
    varianten_totaal['x'].append(dateCache.parse(key))

    # For each variant, determine the number of sick people (variant percentage times estimate)
    geschat_ziek = metenisweten[key]['rolf_besmettelijk']
    totaal_percentage = 0
    for variantcode in variantcodes.keys():
        if variantcode == 'onbekend':
            continue

        if variantcode in varianten_map[key]:
            percentage = varianten_map[key][variantcode][
                'cases'] / varianten_map[key][variantcode]['size']
        else:
            percentage = 0
        totaal_percentage += percentage
        varianten_totaal[variantcode].append(percentage * geschat_ziek)