Skip to content
Snippets Groups Projects
Commit d863ff43 authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Fix window determination

parent 14a381e3
No related branches found
No related tags found
2 merge requests!15Move daq/domains.py to qutil,!13Alazar driver (config2)
Pipeline #1030233 waiting for manual action
......@@ -54,8 +54,9 @@ class _PlotManager:
plot_cumulative_normalized: bool = False, plot_style: _styleT = 'fast',
plot_update_mode: str = 'fast', plot_dB_scale: bool = False, prop_cycle=None,
raw_unit: str = 'V', processed_unit: str = 'V',
figure_kw: Optional[Mapping] = None, subplot_kw: Optional[Mapping] = None,
gridspec_kw: Optional[Mapping] = None, legend_kw: Optional[Mapping] = None):
uses_windowed_estimator: bool = True, figure_kw: Optional[Mapping] = None,
subplot_kw: Optional[Mapping] = None, gridspec_kw: Optional[Mapping] = None,
legend_kw: Optional[Mapping] = None):
"""A helper class that manages plotting spectrometer data."""
self._data = data
......@@ -78,6 +79,7 @@ class _PlotManager:
self.prop_cycle = prop_cycle or plt.rcParams['axes.prop_cycle']
self.raw_unit = raw_unit
self.uses_windowed_estimator = uses_windowed_estimator
self._leg = None
self.axes = {key: dict.fromkeys(self.LINE_TYPES) for key in self.PLOT_TYPES}
......@@ -677,7 +679,7 @@ class _PlotManager:
x += self._data[key]['settings'].get('freq', 0)
window = self._data[key]['settings'].get(
'window', 'hann' if self.psd_estimator.func is welch else 'boxcar'
'window', 'hann' if self.uses_windowed_estimator else 'boxcar'
)
nperseg = self._data[key]['settings']['nperseg']
fs = self._data[key]['settings']['fs']
......@@ -942,15 +944,17 @@ class Spectrometer:
elif isinstance(psd_estimator, Mapping):
self.psd_estimator = partial(welch, **psd_estimator)
else:
raise TypeError('psd_estimator should be callable or kwarg_dict for welch().')
raise TypeError('psd_estimator should be callable or kwarg dict for welch().')
uses_windowed_estimator = 'window' in inspect.signature(self.psd_estimator).parameters
self._plot_manager = _PlotManager(self._data, plot_raw, plot_timetrace,
plot_cumulative, plot_negative_frequencies,
plot_absolute_frequencies, plot_amplitude,
plot_density, plot_cumulative_normalized,
plot_style, plot_update_mode, plot_dB_scale,
prop_cycle, raw_unit, processed_unit, figure_kw,
subplot_kw, gridspec_kw, legend_kw)
prop_cycle, raw_unit, processed_unit,
uses_windowed_estimator, figure_kw, subplot_kw,
gridspec_kw, legend_kw)
# Expose plot properties from plot manager
_to_expose = ('fig', 'ax', 'ax_raw', 'leg', 'plot_raw', 'plot_timetrace', 'plot_cumulative',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment