Пример #1
0
huaxian = pd.read_excel(root_path +
                        '/time_series/HuaxianRunoff1951-2018(1953-2018).xlsx')
huaxian = huaxian['MonthlyRunoff'][24:
                                   576]  #from 1953/01 to 1998/12, 552 samples
# plotting the data
plt.figure()
huaxian.plot()
plt.xlabel("Time(1953/01-1998/12)")
plt.ylabel(r"Runoff($m^3/s$)")

#%%
# Decomposing the monthly Runoff of huaxian With SSA
window = 12
huaxian_ssa = SSA(huaxian, window)
plt.figure()
huaxian_ssa.plot_wcorr()
plt.title("W-Correlation for monthly Runoff of Huaxian")
plt.tight_layout()

#%%
# Of course, with a larger windown length (and therefore a large number
# of elementary components), such a view of the w-correlation matrix is
# not the most helpful. Zoom into the w-correlation matrix for the first
# 50 components
print("corr:\n{}".format(huaxian_ssa.calc_wcorr()))
plt.figure(figsize=(5.51, 5))
huaxian_ssa.plot_wcorr(max=11)
plt.title("W-Correlation for the monthly Runoff of Huaxian", fontsize=10)
plt.subplots_adjust(left=0.12,
                    bottom=0.06,
                    right=0.9,
Пример #2
0
F_ssa_L2.orig_TS.plot(alpha=0.4)
plt.xlabel("$t$")
plt.ylabel(r"$\tilde{F}_i(t)$")
plt.title(r"$L=2$ for the Toy Time Series")

#%%
F_ssa_L5 = SSA(F, 5)
F_ssa_L5.components_to_df().plot()
F_ssa_L5.orig_TS.plot(alpha=0.4)
plt.xlabel("$t$")
plt.ylabel(r"$\tilde{F}_i(t)$")
plt.title(r"$L=5$ for the Toy Time Series")

#%%
F_ssa_L20 = SSA(F, 20)
F_ssa_L20.plot_wcorr()
plt.title("W-Correlation for Toy Time Series, $L=20$")

#%%
F_ssa_L20.reconstruct(0).plot()
F_ssa_L20.reconstruct([1, 2, 3]).plot()
F_ssa_L20.reconstruct(slice(4, 20)).plot()
F_ssa_L20.reconstruct(3).plot()
plt.xlabel("$t$")
plt.ylabel(r"$\tilde{F}_i(t)$")
plt.title("Component Groupings for Toy Time Series, $L=20$")
plt.legend([
    r"$\tilde{F}_0$",
    r"$\tilde{F}_1+\tilde{F}_2+\tilde{F}_3$",
    r"$\tilde{F}_4+\ldots+\tilde{F}_{19}$",
    r"$\tilde{F}_3$",