Commit b291eb0b authored by William Clarke's avatar William Clarke
Browse files

A couple of bits from early 2022, better plotting for dynamic results and...

A couple of bits from early 2022, better plotting for dynamic results and better hlsvd by not using sparse.
parent 31e06c80
......@@ -399,14 +399,15 @@ class dynRes:
fig.legend(handles, labels, loc='right')
return fig
def plot_spectra(self, init=False, fit_to_init=False):
def plot_spectra(self, init=False, fit_to_init=False, indices=None):
"""Plot individual spectra as fitted using the dynamic model
:param init: Plot the spectra as per initilisation, defaults to False
:type init: bool, optional
:param fit_to_init: Plot the spectra as per fitting the dynamic model to init, defaults to False
:type fit_to_init: bool, optional
:param init:
:param indices: List of indicies to plot, defaults to None which plots all.
:type indices: list, optional
:return: plotly figure
"""
from plotly.subplots import make_subplots
......@@ -427,6 +428,7 @@ class dynRes:
dyn_fit = np.asarray(dyn_fit)
dyn_fit_mean = np.mean(dyn_fit, axis=0)
dyn_fit_sd = np.std(dyn_fit.real, axis=0) + 1j * np.std(dyn_fit.imag, axis=0)
x_axis = self._dyn.mrs_list[0].getAxes(ppmlim=self._dyn._fit_args['ppmlim'])
colors = dict(data='rgb(67,67,67)',
......@@ -444,6 +446,13 @@ class dynRes:
else:
sp_titles = [f'#{idx}: {t}' for idx, t in enumerate(self._dyn.time_var)]
if indices is not None:
init_fit = init_fit[indices, :]
init_fitted_fit = init_fitted_fit[indices, :]
dyn_fit_mean = dyn_fit_mean[indices, :]
dyn_fit_sd = dyn_fit_sd[indices, :]
sp_titles = np.asarray(sp_titles)[indices]
row, col = subplot_shape(len(sp_titles))
fig = make_subplots(rows=row, cols=col,
......
......@@ -92,7 +92,7 @@ def _hlsvd(FID, dwelltime, centralFrequency, limits,
:return: HLSVD modeled FID
"""
m = FID.size // 2
r = hlsvdpropy.hlsvdpro(FID, numSingularValues, m=m, sparse=True)
r = hlsvdpropy.hlsvdpro(FID, numSingularValues, m=m, sparse=False)
r = hlsvdpropy.convert_hlsvd_result(r, dwelltime)
nsv_found, singular_values, frequencies, damping_factors, amplitudes, \
phases = r[0:6]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment