Skip to content

Instantly share code, notes, and snippets.

View vilhelmp's full-sized avatar

Magnus Vilhelm Persson vilhelmp

View GitHub Profile
@vilhelmp
vilhelmp / ecdc_covid-19_data.py
Last active March 21, 2020 11:32
Quick Python script to download and do initial parsing of COVID-19 dataset from ECDC (https://www.ecdc.europa.eu/en/publications-data/download-todays-data-geographic-distribution-covid-19-cases-worldwide).
from datetime import datetime, timedelta
import pandas as pd
import seaborn as sns
DATE = datetime.today()
DATE_STR = DATE.strftime("%Y-%m-%d")
BASE_URL = f'https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-{DATE_STR}.xlsx'
print(f'Downloading for {DATE_STR}')
while True:
try:
@vilhelmp
vilhelmp / tensorboard_logging.py
Created February 28, 2020 16:01 — forked from gyglim/tensorboard_logging.py
Logging to tensorboard without tensorflow operations. Uses manually generated summaries instead of summary ops
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: BSD License 2.0
"""
__author__ = "Michael Gygli"
import tensorflow as tf
from StringIO import StringIO
import matplotlib.pyplot as plt
import numpy as np
@vilhelmp
vilhelmp / uval.py
Created July 7, 2017 14:37 — forked from pkgw/uval.py
"The worst possible way to propagate uncertainties."
"""
The worst possible way to propagate uncertainties.
"""
import numpy as np
from scipy.stats import scoreatpercentile as sap
n = 1024
uplaces = 1 # the argument is that you generally only know your uncerts to 1 place
udtype = np.double
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))