In [22]:
% matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import scipy as sp
import scipy.ndimage as si
import pymks
In [3]:
from pymks.datasets import make_cahn_hilliard
from pymks.bases import LegendreBasis
In [6]:
t_steps = 10
size =(50, 50)
Data = np.zeros(size + (t_steps,))
#for ii in range(t_steps):
In [77]:
X, y = make_cahn_hilliard(50, (50, 50))
In [78]:
from pymks.tools import draw_concentrations
#draw_concentrations(X[0], y[0])
plt.figure()
plt.imshow(X[0])
plt.colorbar()
plt.figure()
plt.imshow(y[0])
plt.colorbar()
Out[78]:
In [10]:
from pymks.datasets.cahn_hilliard_simulation import CahnHilliardSimulation
N = 50
phi0 = 0.01 * (2 * np.random.random((N, N)) - 1)
Data[:, :, 0] = phi0.copy()
ch = CahnHilliardSimulation()
for ii in range(t_steps - 1):
ch.run(Data[:, :, ii])
Data[:, :, ii + 1] = ch.response
In [13]:
for ii in range(t_steps):
if ii == 0 or ii == (t_steps - 1):
plt.figure()
plt.imshow(Data[:, :, ii])
plt.colorbar()
In [112]:
n_states = 6
LegBasis = LegendreBasis(n_states=n_states, domain=[-1, 1])
In [107]:
X_end = Data[:, :, -1]# Last time step
X_start = Data[..., 0]
X_end_ = LegBasis.discretize(X_end)
X_start_ = LegBasis.discretize(X_start)
print np.unique(X_end.imag)
print len(np.unique(X_end.imag))
In [108]:
FX_end_ = np.fft.fftn(X_end_, axes=(0, 1))
FX_start_ = np.fft.fftn(X_start_, axes=(0, 1))
print np.unique(FX_end_.imag)
print len(np.unique(FX_end_.imag))
In [109]:
def new_coeffs(X_):
n_states = X_.shape[-1]
Niter = np.ceil((n_states + 1) / 2.)
Nslice = n_states * (n_states + 1) / 2
Mat = np.zeros((50, 50, 4, 4))
tmp = [np.conj(X_) * np.roll(X_, i, axis=-1) for i in range(int(Niter))]
return np.concatenate(tmp, axis=-1)[..., :Nslice]
In [110]:
# Think about normalization
FX_t_end = new_coeffs(X_end_)
FX_t_start = new_coeffs(X_start_)
print np.unique(FX_t_end.imag)
print len(np.unique(FX_t_end.imag))
print FX_t_start.shape
In [111]:
X_t_end = np.fft.irfftn(FX_t_end, axes=(0, 1))
X_t_start = np.fft.irfftn(FX_t_start, axes=(0, 1))
print np.unique(X_t_end.imag)
print len(np.unique(X_t_end.imag))
In [105]:
from pymks import MKSKernelPCAModel
In [ ]:
Hello $x=0$ $$ X = 0$$
$$\sum_{n=0}^N$$
In [ ]:
from pymks.stats import autocorrelate
? autocorrelate
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: