Skip to content

Instantly share code, notes, and snippets.

@kuchaale
kuchaale / cartopy_wrap_example.ipynb
Created June 15, 2016 11:13 — forked from darothen/cartopy_wrap_example.ipynb
Example of adding cyclic points to DataArrays for plotting with Cartopy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import xarray as xr
import numpy as np
# create an example dataset
da = xr.DataArray(np.random.rand(10,30,40), dims=['time', 'lat', 'lon'])
# define a function to compute a linear trend of a timeseries
def linear_trend(x):
pf = np.polyfit(x.time, x, 1)
# we need to return a dataarray or else xarray's groupby won't be happy
@kuchaale
kuchaale / MOLA_datashader.ipynb
Created October 6, 2016 21:50 — forked from kidpixo/MOLA_datashader.ipynb
MOLA_datashader.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuchaale
kuchaale / aggregate.py
Created January 27, 2017 08:55 — forked from rabernat/aggregate.py
aggregation routines for coarse graining
# implement my own aggregation downsampling function
from itertools import product
import numpy as np
import xarray as xr
def aggregate(data, factor=2, mean=True):
ndim = data.ndim
shape = data.shape
# promote single value to list
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuchaale
kuchaale / README.md
Created August 14, 2017 09:57 — forked from zenorocha/README.md
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage

@kuchaale
kuchaale / pysom.py
Created August 14, 2017 14:11 — forked from TakuTsuzuki/pysom.py
SOM
"""
pysom.py is a python script for self-organizing map (SOM).
"""
import numpy as np
import matplotlib.pyplot as plt
# learning paras.
loop = 1000 # def: 1000
alpha_base = 1.0 # def: 1.0
@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]