Skip to content

Commit

Permalink
👌 Handle missing SVD by computing them if missing in plots that use them
Browse files Browse the repository at this point in the history
  • Loading branch information
s-weigand committed Nov 13, 2021
1 parent 619bce0 commit a828f42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyglotaran_extras/plotting/plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import cast

import matplotlib.pyplot as plt
from glotaran.io.prepare_dataset import add_svd_to_dataset
from matplotlib.axis import Axis

from pyglotaran_extras.io.load_data import load_data
Expand Down Expand Up @@ -58,6 +59,8 @@ def plot_data_overview(
dataset.data.plot(x="time", ax=data_ax, center=False)
else:
dataset.data.plot(ax=data_ax)

add_svd_to_dataset(dataset=dataset, name="data")
plot_lsv_data(dataset, lsv_ax)
plot_sv_data(dataset, sv_ax)
plot_rsv_data(dataset, rsv_ax)
Expand Down
7 changes: 7 additions & 0 deletions pyglotaran_extras/plotting/plot_svd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import TYPE_CHECKING

from glotaran.io.prepare_dataset import add_svd_to_dataset

from pyglotaran_extras.plotting.style import PlotStyle

if TYPE_CHECKING:
Expand All @@ -20,9 +22,14 @@ def plot_svd(
linthresh: float = 1,
cycler: Cycler = PlotStyle().cycler,
) -> None:
if "weighted_residual" in res:
add_svd_to_dataset(dataset=res, name="weighted_residual")
else:
add_svd_to_dataset(dataset=res, name="residual")
plot_lsv_residual(res, axes[0, 0], linlog=linlog, linthresh=linthresh, cycler=cycler)
plot_rsv_residual(res, axes[0, 1], cycler=cycler)
plot_sv_residual(res, axes[0, 2], cycler=cycler)
add_svd_to_dataset(dataset=res, name="data")
plot_lsv_data(res, axes[1, 0], linlog=linlog, linthresh=linthresh, cycler=cycler)
plot_rsv_data(res, axes[1, 1], cycler=cycler)
plot_sv_data(res, axes[1, 2], cycler=cycler)
Expand Down

0 comments on commit a828f42

Please sign in to comment.