TODO: Write a project description
TODO: Describe the installation process
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 |
# 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 |
""" | |
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 |
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] |