Skip to content

Instantly share code, notes, and snippets.

@kuchaale
kuchaale / Recover_data_with_known_colourmap.ipynb
Created September 14, 2022 14:39 — forked from kwinkunks/Recover_data_with_known_colourmap.ipynb
Demo of recovering data from an image with a known colourmap. Thank you to David Johnstone (Manchester) for the data example.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuchaale
kuchaale / style.css
Created October 13, 2021 23:19 — forked from rougier/style.css
Jupyter stylesheet
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400&family=Source+Code+Pro:wght@300;400&display=swap');
.rendered_html h1,
.rendered_html h2,
.rendered_html h3,
.rendered_html h4 {
color: #000099;
font-weight: 400;
}
@kuchaale
kuchaale / sherman.py
Created January 4, 2021 16:07 — forked from 0x0L/sherman.py
Fast moving window regressions
import numba
import numpy as np
@numba.jit(nopython=True, fastmath=True)
def move_regress(X, Y, w, fit_intercept=True):
"""Moving window multi-regressions
Solves the least-squares problems `Y[t-w+1:t+1] = X[t-w+1:t+1] @ B[t] + A[t]`
for `B` and `A` for all `t` in `[w-1, len(Y)-1]`.
@kuchaale
kuchaale / globaltemp.R
Created December 11, 2020 14:23 — forked from jrnold/globaltemp.R
Kalman filter in Stan
library(KFAS)
library(rstan)
data(GlobalTemp)
model_dlm1a <- stan_model("../stan/dlm1a.stan")
y <- as.matrix(GlobalTemp)
data <-
within(list(),
{
@kuchaale
kuchaale / bootstrap_threshold_parallel.ipynb
Created October 15, 2020 14:38 — forked from aaronspring/bootstrap_threshold_parallel.ipynb
bootstrap threshold in parallel with dask
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuchaale
kuchaale / wrf_python_extraction.py
Created October 15, 2020 10:51 — forked from jthielen/wrf_python_extraction.py
Use wrf-python, xarray, and pyproj to post-process WRF output
from wrf import getvar
from netCDF4 import Dataset
import xarray as xr
import pyproj
# Extract the variables of interest at time index 17
ds = Dataset('../wrfout_d02_2015-07-12_1200.nc')
variables = [getvar(ds, var, 17) for var in ('z', 'dbz', 'pressure', 'ter', 'ua',
'va', 'wa', 'temp', 'rh')]
data = xr.merge(variables)
@kuchaale
kuchaale / nexrad_composites.py
Created September 25, 2018 05:59 — forked from tristanwietsma/nexrad_composites.py
Downloader for NEXRAD GeoTIFF composites
from sys import exit, argv
import datetime, zipfile
import requests
def dlhook(r, *args, **kwargs):
print('GET %s'%str(r.url))
base_url = "http://mesonet.agron.iastate.edu/request/gis/n0r2gtiff.php?dstr=%s"
def fetch(tme):
@kuchaale
kuchaale / metamodelling.ipynb
Created June 4, 2018 06:26 — forked from JiaweiZhuang/metamodelling.ipynb
Performance of different ML algorithms for fitting functions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuchaale
kuchaale / hide_code_pdf.md
Created March 16, 2018 11:32 — forked from macoj/hide_code_pdf.md
Hiding code when exporting jupyter notebook to pdf
@kuchaale
kuchaale / eblow.py
Created March 16, 2018 09:53 — forked from calippo/eblow.py
[scikit-learn/sklearn, pandas] Plot percent of variance explained for KMeans (Elbow Method)
import pandas as pd
import matplotlib.pyplot as plt
import seaborn
from sklearn.cluster import KMeans
import numpy as np
from scipy.spatial.distance import cdist, pdist
def eblow(df, n):
kMeansVar = [KMeans(n_clusters=k).fit(df.values) for k in range(1, n)]
centroids = [X.cluster_centers_ for X in kMeansVar]