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