Skip to content

Commit

Permalink
Merge pull request #10 from pastas/dev
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
martinvonk authored Dec 21, 2022
2 parents ac3c74c + 10fe2c5 commit e30c0bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 6 additions & 2 deletions metran/kalmanfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,16 @@ def decompose(self, observation_matrix, method="smoother"):
for t, _ in enumerate(means):
sdf_means.append(np.dot(observation_matrix[:, :nsdf],
means[t, :nsdf]))
cdf_means = [[]] * ncdf

cdf_means = []
for k in range(ncdf):
idx = nsdf + k
cdf_means_cdf = []
for t, _ in enumerate(means):
cdf_means[k].append(np.dot(observation_matrix[:, idx],
cdf_means_cdf.append(np.dot(observation_matrix[:, idx],
means[t, idx]))

cdf_means.append(cdf_means_cdf)
return (sdf_means, cdf_means)

def set_observations(self, oseries):
Expand Down
15 changes: 10 additions & 5 deletions metran/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import matplotlib.pyplot as plt
import numpy as np
from pandas import Timestamp
from pastas.plots import _get_height_ratios
from pastas import __version__ as psversion

if psversion < '0.19.0':
from pastas.plots import _get_height_ratios
else:
from pastas.modelplots import _get_height_ratios


class MetranPlot:
Expand All @@ -25,7 +30,7 @@ def scree_plot(self):
ax.plot(n_ev, self.mt.eigval, marker="o", ms=7, mfc="none", c="C3")
ax.bar(n_ev, self.mt.eigval, facecolor="none",
edgecolor="C0", linewidth=2)
ax.grid(b=True)
ax.grid(visible=True)
ax.set_xticks(n_ev)
ax.set_ylabel("eigenvalue")
ax.set_xlabel("eigenvalue number")
Expand Down Expand Up @@ -94,7 +99,7 @@ def state_means(self, tmin=None, tmax=None, adjust_height=True):

states.loc[:, col].plot(ax=iax, label=lbl, color=c)
iax.legend(loc=(0, 1), ncol=3, frameon=False, numpoints=3)
iax.grid(b=True)
iax.grid(visible=True)

if adjust_height:
iax.set_ylim(ylims[i])
Expand Down Expand Up @@ -149,7 +154,7 @@ def simulation(self, name, alpha=0.05, tmin=None, tmax=None, ax=None):
ax.fill_between(sim.index, sim["lower"], sim["upper"], color="gray",
alpha=0.5, label="95%-confidence interval")
ax.legend(loc=(0, 1), ncol=3, frameon=False, numpoints=3)
ax.grid(b=True)
ax.grid(visible=True)
ax.set_xlim(tmin, tmax)

if ax is None:
Expand Down Expand Up @@ -277,7 +282,7 @@ def decomposition(self, name, tmin=None, tmax=None, ax=None,
iax.plot(s.index, s, label=f"{col} {name}", color=c, zorder=zorder)

# grid and legend
iax.grid(b=True)
iax.grid(visible=True)
iax.legend(loc=(0, 1), ncol=3, frameon=False, numpoints=3)

# set ylimits
Expand Down
2 changes: 1 addition & 1 deletion metran/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This is the only location where the version will be written and changed.
# Based on https://packaging.python.org/single_source_version/
__version__ = '0.1.2'
__version__ = '0.2.0'

0 comments on commit e30c0bb

Please sign in to comment.