diff --git a/src/openqlab/analysis/__init__.py b/src/openqlab/analysis/__init__.py index bc6d9d728a15090391efa43c2bc2e00023010245..80354e0181edd48412e3e33e750a475f6371463f 100644 --- a/src/openqlab/analysis/__init__.py +++ b/src/openqlab/analysis/__init__.py @@ -1,4 +1,4 @@ from .servo_design import ServoDesign from .gaussian_beam import fit_beam_data, GaussianBeam from ..conversion import db -from . import phase +from . import phase, cavity diff --git a/src/openqlab/plots/time_domain.py b/src/openqlab/plots/time_domain.py index 92cc615de97b1cf6d316e1d9e69b7e06f599e48f..0c604b4f2737680d87f8dad28f020e0b2d322d0e 100644 --- a/src/openqlab/plots/time_domain.py +++ b/src/openqlab/plots/time_domain.py @@ -80,8 +80,8 @@ def scope(traces, title='Oscilloscope View'): from mpl_toolkits.axes_grid1 import host_subplot import mpl_toolkits.axisartist as AA - traces = DataContainer( - traces) # then you can also conviniently put in a single column, which would otherwise be a series + # then you can also conviniently put in a single column, which would otherwise be a series + traces = DataContainer(traces) offset = 50 Ntraces = len(traces.columns) if Ntraces > 4: @@ -91,7 +91,7 @@ def scope(traces, title='Oscilloscope View'): host = host_subplot(111, axes_class=AA.Axes) plt.subplots_adjust(right=1.0 - 0.11 * (Ntraces - 1)) - line, = host.plot(traces.index, traces.iloc[:, 0], label=traces.columns[0]) + line, = host.plot(np.array(traces.index), np.array(traces.iloc[:, 0]), label=traces.columns[0]) host.set_ylabel(traces.columns[0]) host.set_xlabel(traces.index.name) host.axis['left'].label.set_color(line.get_color()) @@ -111,7 +111,7 @@ def scope(traces, title='Oscilloscope View'): pax.major_ticks.set_ticksize(4.0) ax.axis['right'] = pax - line, = ax.plot(traces.index, traces.iloc[:, ii], label=traces.columns[ii]) + line, = ax.plot(np.array(traces.index), np.array(traces.iloc[:, ii]), label=traces.columns[ii]) ax.axis['right'].toggle(all=True) ax.set_ylabel(traces.columns[ii]) ax.axis['right'].label.set_color(line.get_color()) diff --git a/src/tests/test_plots.py b/src/tests/test_plots.py index 20bee8302bd8cc71917c192da92a1dee626e95c7..7ef36e3bf92abe5fb87bd64770de8f2a75a88a0c 100644 --- a/src/tests/test_plots.py +++ b/src/tests/test_plots.py @@ -51,3 +51,14 @@ class TestAmplitudePhase(unittest.TestCase): def test_clamp_phase_warns(self): with self.assertWarns(DeprecationWarning): plots.frequency_domain._clamp_phase(4) + + +class TestTimeDomain(unittest.TestCase): + def setUp(self): + self.data = io.read( + r'./ContainerTestData/SuccedingImport/Oscilloscope/Keysight/20180606_001.csv') + + def test_default_plot(self): + fig = plots.scope(self.data) + fig = plots.scope(self.data.iloc[:, 0]) + self.assertIsInstance(fig, matplotlib.figure.Figure)