We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
workup.panda docstring description


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `WrightTools/tuning/workup.py`
Content:
```
1 '''
2 Methods for processing OPA 800 tuning data.
3 '''
4 
5 
6 ### import ####################################################################
7 
8 
9 from __future__ import absolute_import, division, print_function, unicode_literals
10 
11 import os
12 import re
13 import sys
14 import imp
15 import ast
16 import time
17 import copy
18 import inspect
19 import collections
20 import subprocess
21 import glob
22 
23 try:
24     import configparser as _ConfigParser  # python 3
25 except ImportError:
26     import ConfigParser as _ConfigParser  # python 2'
27 
28 import matplotlib
29 import matplotlib.pyplot as plt
30 
31 import numpy as np
32 from numpy import sin, cos
33 
34 import scipy
35 from scipy.interpolate import griddata, interp1d, interp2d, UnivariateSpline
36 import scipy.integrate as integrate
37 from scipy.optimize import leastsq
38 
39 from pylab import *
40 
41 from . import curve as wt_curve
42 from .. import artists as wt_artists
43 from .. import data as wt_data
44 from .. import fit as wt_fit
45 from .. import kit as wt_kit
46 from .. import units as wt_units
47 
48 
49 ### define ####################################################################
50 
51 
52 cmap = wt_artists.colormaps['default']
53 cmap.set_bad([0.75] * 3, 1.)
54 cmap.set_under([0.75] * 3)
55 
56 ### processing methods ########################################################
57 
58 
59 def intensity(data, curve, channel_name, level=False, cutoff_factor=0.1,
60               autosave=True, save_directory=None):
61     '''
62     Parameters
63     ----------
64     data : wt.data.Data objeect
65         should be in (setpoint, motor)
66 
67     Returns
68     -------
69     curve
70         New curve object.
71     '''
72     # TODO: documentation
73     data.transpose()
74     channel_index = data.channel_names.index(channel_name)
75     tune_points = curve.colors
76     # process data ------------------------------------------------------------
77     if level:
78         data.level(channel_index, 0, -3)
79     # cutoff
80     channel = data.channels[channel_index]
81     cutoff = np.nanmax(channel.values) * cutoff_factor
82     channel.values[channel.values < cutoff] = np.nan
83     # get centers through expectation value
84     motor_axis_name = data.axes[0].name
85     function = wt_fit.Moments()
86     function.subtract_baseline = False
87     fitter = wt_fit.Fitter(function, data, motor_axis_name, verbose=False)
88     outs = fitter.run(channel_index, verbose=False)
89     offsets = outs.one.values
90     # pass offsets through spline
91     spline = wt_kit.Spline(tune_points, offsets)
92     offsets_splined = spline(tune_points)
93     # make curve --------------------------------------------------------------
94     old_curve = curve.copy()
95     motors = []
96     for motor_index, motor_name in enumerate([m.name for m in old_curve.motors]):
97         if motor_name == motor_axis_name.split('_')[-1]:
98             positions = data.axes[0].centers + offsets_splined
99             motor = wt_curve.Motor(positions, motor_name)
100             motors.append(motor)
101             tuned_motor_index = motor_index
102         else:
103             motors.append(old_curve.motors[motor_index])
104     kind = old_curve.kind
105     interaction = old_curve.interaction
106     curve = wt_curve.Curve(tune_points, 'wn', motors,
107                            name=old_curve.name.split('-')[0],
108                            kind=kind, interaction=interaction)
109     curve.map_colors(old_curve.colors)
110     # plot --------------------------------------------------------------------
111     fig, gs = wt_artists.create_figure(nrows=2, default_aspect=0.5, cols=[1, 'cbar'])
112     # curves
113     ax = plt.subplot(gs[0, 0])
114     xi = old_curve.colors
115     yi = old_curve.motors[tuned_motor_index].positions
116     ax.plot(xi, yi, c='k', lw=1)
117     xi = curve.colors
118     yi = curve.motors[tuned_motor_index].positions
119     ax.plot(xi, yi, c='k', lw=5, alpha=0.5)
120     ax.grid()
121     ax.set_xlim(tune_points.min(), tune_points.max())
122     ax.set_ylabel(curve.motor_names[tuned_motor_index], fontsize=18)
123     plt.setp(ax.get_xticklabels(), visible=False)
124     # heatmap
125     ax = plt.subplot(gs[1, 0])
126     xi = data.axes[1].points
127     yi = data.axes[0].points
128     zi = data.channels[channel_index].values
129     X, Y, Z = wt_artists.pcolor_helper(xi, yi, zi)
130     ax.pcolor(X, Y, Z, vmin=0, vmax=np.nanmax(zi), cmap=cmap)
131     ax.set_xlim(xi.min(), xi.max())
132     ax.set_ylim(yi.min(), yi.max())
133     ax.grid()
134     ax.axhline(c='k', lw=1)
135     xi = curve.colors
136     yi = offsets
137     ax.plot(xi, yi, c='grey', lw=5, alpha=0.5)
138     xi = curve.colors
139     yi = offsets_splined
140     ax.plot(xi, yi, c='k', lw=5, alpha=0.5)
141     units_string = '$\mathsf{(' + wt_units.color_symbols[curve.units] + ')}$'
142     ax.set_xlabel(' '.join(['setpoint', units_string]), fontsize=18)
143     ax.set_ylabel(
144         ' '.join(['$\mathsf{\Delta}$', curve.motor_names[tuned_motor_index]]), fontsize=18)
145     # colorbar
146     cax = plt.subplot(gs[1, -1])
147     label = channel_name
148     ticks = np.linspace(0, np.nanmax(zi), 7)
149     wt_artists.plot_colorbar(cax=cax, cmap=cmap, label=label, ticks=ticks)
150     # finish ------------------------------------------------------------------
151     if autosave:
152         if save_directory is None:
153             save_directory = os.getcwd()
154         curve.save(save_directory=save_directory, full=True)
155         p = os.path.join(save_directory, 'intensity.png')
156         wt_artists.savefig(p, fig=fig)
157     return curve
158 
159 
160 def tune_test(data, curve, channel_name, level=False, cutoff_factor=0.01,
161               autosave=True, save_directory=None):
162     """
163 
164     Parameters
165     ----------
166     data : wt.data.Data object
167         should be in (setpoint, detuning)
168     curve : wt.curve object
169         tuning curve used to do tune_test
170     channel_nam : str
171         name of the signal chanel to evalute
172     level : bool (optional)
173         does nothing, default is False
174     cutoff_factor : float (optoinal)
175         minimum value for datapoint/max(datapoints) for point to be included
176         in the fitting procedure, default is 0.01
177     autosave : bool (optional)
178         saves output curve if True, default is True
179     save_directory : str
180         directory to save new curve, default is None which uses the data source
181         directory
182 
183     Returns
184     -------
185     curve
186         New curve object.
187     """
188     # make data object
189     data = data.copy()
190     data.bring_to_front(channel_name)
191     data.transpose()
192     # process data ------------------------------------------------------------
193     # cutoff
194     channel_index = data.channel_names.index(channel_name)
195     channel = data.channels[channel_index]
196     cutoff = np.nanmax(channel.values) * cutoff_factor
197     channel.values[channel.values < cutoff] = np.nan
198     # fit
199     gauss_function = wt_fit.Gaussian()
200     g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)
201     outs = g_fitter.run()
202     # spline
203     xi = outs.axes[0].points
204     yi = outs.mean.values
205     spline = wt_kit.Spline(xi, yi)
206     offsets_splined = spline(xi)  # wn
207     # make curve --------------------------------------------------------------
208     curve = curve.copy()
209     curve_native_units = curve.units
210     curve.convert('wn')
211     points = curve.colors.copy()
212     curve.colors += offsets_splined
213     curve.map_colors(points, units='wn')
214     curve.convert(curve_native_units)
215     # plot --------------------------------------------------------------------
216     data.axes[1].convert(curve_native_units)
217     fig, gs = wt_artists.create_figure(default_aspect=0.5, cols=[1, 'cbar'])
218     # heatmap
219     ax = plt.subplot(gs[0, 0])
220     xi = data.axes[1].points
221     yi = data.axes[0].points
222     zi = data.channels[channel_index].values
223     X, Y, Z = wt_artists.pcolor_helper(xi, yi, zi)
224     ax.pcolor(X, Y, Z, vmin=0, vmax=np.nanmax(zi), cmap=cmap)
225     ax.set_xlim(xi.min(), xi.max())
226     ax.set_ylim(yi.min(), yi.max())
227     # lines
228     outs.convert(curve_native_units)
229     xi = outs.axes[0].points
230     yi = outs.mean.values
231     ax.plot(xi, yi, c='grey', lw=5, alpha=0.5)
232     ax.plot(xi, offsets_splined, c='k', lw=5, alpha=0.5)
233     ax.axhline(c='k', lw=1)
234     ax.grid()
235     units_string = '$\mathsf{(' + wt_units.color_symbols[curve.units] + ')}$'
236     ax.set_xlabel(r' '.join(['setpoint', units_string]), fontsize=18)
237     ax.set_ylabel(r'$\mathsf{\Delta' + wt_units.color_symbols['wn'] + '}$', fontsize=18)
238     # colorbar
239     cax = plt.subplot(gs[:, -1])
240     label = channel_name
241     ticks = np.linspace(0, np.nanmax(zi), 7)
242     wt_artists.plot_colorbar(cax=cax, cmap=cmap, label=label, ticks=ticks)
243     # finish ------------------------------------------------------------------
244     if autosave:
245         if save_directory is None:
246             save_directory = os.path.dirname(data.source)
247         curve.save(save_directory=save_directory, full=True)
248         p = os.path.join(save_directory, 'tune test.png')
249         wt_artists.savefig(p, fig=fig)
250     return curve
251 
252 
253 def panda(data, curve, channel_name, level=False, cutoff_factor=0.01,
254           autosave=True, save_directory=None):
255     """
256 
257     Parameters
258     ----------
259     data : wt.data.Data object
260         should be in (setpoint, detuning)
261     curve : wt.curve object
262         tuning curve used to do tune_test
263     channel_nam : str
264         name of the signal chanel to evalute
265     level : bool (optional)
266         does nothing, default is False
267     cutoff_factor : float (optoinal)
268         minimum value for datapoint/max(datapoints) for point to be included
269         in the fitting procedure, default is 0.01
270     autosave : bool (optional)
271         saves output curve if True, default is True
272     save_directory : str
273         directory to save new curve, default is None which uses the data source
274         directory
275 
276     Returns
277     -------
278     curve
279         New curve object.
280     """
281     # make data object
282     data.bring_to_front(channel_name)
283     data.transpose()
284     # process data ------------------------------------------------------------
285     # cutoff
286     channel_index = data.channel_names.index(channel_name)
287     channel = data.channels[channel_index]
288     cutoff = np.nanmax(channel.values) * cutoff_factor
289     channel.values[channel.values < cutoff] = np.nan
290     # fit
291     # TODO: evaluate suggested edits to fit section
292     function = wt_fit.Moments()
293     fitter = wt_fit.Fitter(function, data, data.axes[0].name)
294     outs = fitter.run()
295     gauss_function = wt_fit.Gaussian()
296     g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)
297     gauss_outs = g_fitter.run()
298     return gauss_outs
299
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/WrightTools/tuning/workup.py b/WrightTools/tuning/workup.py
--- a/WrightTools/tuning/workup.py
+++ b/WrightTools/tuning/workup.py
@@ -36,8 +36,6 @@
 import scipy.integrate as integrate
 from scipy.optimize import leastsq
 
-from pylab import *
-
 from . import curve as wt_curve
 from .. import artists as wt_artists
 from .. import data as wt_data
@@ -248,51 +246,3 @@
         p = os.path.join(save_directory, 'tune test.png')
         wt_artists.savefig(p, fig=fig)
     return curve
-
-
-def panda(data, curve, channel_name, level=False, cutoff_factor=0.01,
-          autosave=True, save_directory=None):
-    """
-
-    Parameters
-    ----------
-    data : wt.data.Data object
-        should be in (setpoint, detuning)
-    curve : wt.curve object
-        tuning curve used to do tune_test
-    channel_nam : str
-        name of the signal chanel to evalute
-    level : bool (optional)
-        does nothing, default is False
-    cutoff_factor : float (optoinal)
-        minimum value for datapoint/max(datapoints) for point to be included
-        in the fitting procedure, default is 0.01
-    autosave : bool (optional)
-        saves output curve if True, default is True
-    save_directory : str
-        directory to save new curve, default is None which uses the data source
-        directory
-
-    Returns
-    -------
-    curve
-        New curve object.
-    """
-    # make data object
-    data.bring_to_front(channel_name)
-    data.transpose()
-    # process data ------------------------------------------------------------
-    # cutoff
-    channel_index = data.channel_names.index(channel_name)
-    channel = data.channels[channel_index]
-    cutoff = np.nanmax(channel.values) * cutoff_factor
-    channel.values[channel.values < cutoff] = np.nan
-    # fit
-    # TODO: evaluate suggested edits to fit section
-    function = wt_fit.Moments()
-    fitter = wt_fit.Fitter(function, data, data.axes[0].name)
-    outs = fitter.run()
-    gauss_function = wt_fit.Gaussian()
-    g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)
-    gauss_outs = g_fitter.run()
-    return gauss_outs

{"golden_diff": "diff --git a/WrightTools/tuning/workup.py b/WrightTools/tuning/workup.py\n--- a/WrightTools/tuning/workup.py\n+++ b/WrightTools/tuning/workup.py\n@@ -36,8 +36,6 @@\n import scipy.integrate as integrate\n from scipy.optimize import leastsq\n \n-from pylab import *\n-\n from . import curve as wt_curve\n from .. import artists as wt_artists\n from .. import data as wt_data\n@@ -248,51 +246,3 @@\n         p = os.path.join(save_directory, 'tune test.png')\n         wt_artists.savefig(p, fig=fig)\n     return curve\n-\n-\n-def panda(data, curve, channel_name, level=False, cutoff_factor=0.01,\n-          autosave=True, save_directory=None):\n-    \"\"\"\n-\n-    Parameters\n-    ----------\n-    data : wt.data.Data object\n-        should be in (setpoint, detuning)\n-    curve : wt.curve object\n-        tuning curve used to do tune_test\n-    channel_nam : str\n-        name of the signal chanel to evalute\n-    level : bool (optional)\n-        does nothing, default is False\n-    cutoff_factor : float (optoinal)\n-        minimum value for datapoint/max(datapoints) for point to be included\n-        in the fitting procedure, default is 0.01\n-    autosave : bool (optional)\n-        saves output curve if True, default is True\n-    save_directory : str\n-        directory to save new curve, default is None which uses the data source\n-        directory\n-\n-    Returns\n-    -------\n-    curve\n-        New curve object.\n-    \"\"\"\n-    # make data object\n-    data.bring_to_front(channel_name)\n-    data.transpose()\n-    # process data ------------------------------------------------------------\n-    # cutoff\n-    channel_index = data.channel_names.index(channel_name)\n-    channel = data.channels[channel_index]\n-    cutoff = np.nanmax(channel.values) * cutoff_factor\n-    channel.values[channel.values < cutoff] = np.nan\n-    # fit\n-    # TODO: evaluate suggested edits to fit section\n-    function = wt_fit.Moments()\n-    fitter = wt_fit.Fitter(function, data, data.axes[0].name)\n-    outs = fitter.run()\n-    gauss_function = wt_fit.Gaussian()\n-    g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)\n-    gauss_outs = g_fitter.run()\n-    return gauss_outs\n", "issue": "workup.panda docstring description\n\n", "before_files": [{"content": "'''\nMethods for processing OPA 800 tuning data.\n'''\n\n\n### import ####################################################################\n\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport os\nimport re\nimport sys\nimport imp\nimport ast\nimport time\nimport copy\nimport inspect\nimport collections\nimport subprocess\nimport glob\n\ntry:\n    import configparser as _ConfigParser  # python 3\nexcept ImportError:\n    import ConfigParser as _ConfigParser  # python 2'\n\nimport matplotlib\nimport matplotlib.pyplot as plt\n\nimport numpy as np\nfrom numpy import sin, cos\n\nimport scipy\nfrom scipy.interpolate import griddata, interp1d, interp2d, UnivariateSpline\nimport scipy.integrate as integrate\nfrom scipy.optimize import leastsq\n\nfrom pylab import *\n\nfrom . import curve as wt_curve\nfrom .. import artists as wt_artists\nfrom .. import data as wt_data\nfrom .. import fit as wt_fit\nfrom .. import kit as wt_kit\nfrom .. import units as wt_units\n\n\n### define ####################################################################\n\n\ncmap = wt_artists.colormaps['default']\ncmap.set_bad([0.75] * 3, 1.)\ncmap.set_under([0.75] * 3)\n\n### processing methods ########################################################\n\n\ndef intensity(data, curve, channel_name, level=False, cutoff_factor=0.1,\n              autosave=True, save_directory=None):\n    '''\n    Parameters\n    ----------\n    data : wt.data.Data objeect\n        should be in (setpoint, motor)\n\n    Returns\n    -------\n    curve\n        New curve object.\n    '''\n    # TODO: documentation\n    data.transpose()\n    channel_index = data.channel_names.index(channel_name)\n    tune_points = curve.colors\n    # process data ------------------------------------------------------------\n    if level:\n        data.level(channel_index, 0, -3)\n    # cutoff\n    channel = data.channels[channel_index]\n    cutoff = np.nanmax(channel.values) * cutoff_factor\n    channel.values[channel.values < cutoff] = np.nan\n    # get centers through expectation value\n    motor_axis_name = data.axes[0].name\n    function = wt_fit.Moments()\n    function.subtract_baseline = False\n    fitter = wt_fit.Fitter(function, data, motor_axis_name, verbose=False)\n    outs = fitter.run(channel_index, verbose=False)\n    offsets = outs.one.values\n    # pass offsets through spline\n    spline = wt_kit.Spline(tune_points, offsets)\n    offsets_splined = spline(tune_points)\n    # make curve --------------------------------------------------------------\n    old_curve = curve.copy()\n    motors = []\n    for motor_index, motor_name in enumerate([m.name for m in old_curve.motors]):\n        if motor_name == motor_axis_name.split('_')[-1]:\n            positions = data.axes[0].centers + offsets_splined\n            motor = wt_curve.Motor(positions, motor_name)\n            motors.append(motor)\n            tuned_motor_index = motor_index\n        else:\n            motors.append(old_curve.motors[motor_index])\n    kind = old_curve.kind\n    interaction = old_curve.interaction\n    curve = wt_curve.Curve(tune_points, 'wn', motors,\n                           name=old_curve.name.split('-')[0],\n                           kind=kind, interaction=interaction)\n    curve.map_colors(old_curve.colors)\n    # plot --------------------------------------------------------------------\n    fig, gs = wt_artists.create_figure(nrows=2, default_aspect=0.5, cols=[1, 'cbar'])\n    # curves\n    ax = plt.subplot(gs[0, 0])\n    xi = old_curve.colors\n    yi = old_curve.motors[tuned_motor_index].positions\n    ax.plot(xi, yi, c='k', lw=1)\n    xi = curve.colors\n    yi = curve.motors[tuned_motor_index].positions\n    ax.plot(xi, yi, c='k', lw=5, alpha=0.5)\n    ax.grid()\n    ax.set_xlim(tune_points.min(), tune_points.max())\n    ax.set_ylabel(curve.motor_names[tuned_motor_index], fontsize=18)\n    plt.setp(ax.get_xticklabels(), visible=False)\n    # heatmap\n    ax = plt.subplot(gs[1, 0])\n    xi = data.axes[1].points\n    yi = data.axes[0].points\n    zi = data.channels[channel_index].values\n    X, Y, Z = wt_artists.pcolor_helper(xi, yi, zi)\n    ax.pcolor(X, Y, Z, vmin=0, vmax=np.nanmax(zi), cmap=cmap)\n    ax.set_xlim(xi.min(), xi.max())\n    ax.set_ylim(yi.min(), yi.max())\n    ax.grid()\n    ax.axhline(c='k', lw=1)\n    xi = curve.colors\n    yi = offsets\n    ax.plot(xi, yi, c='grey', lw=5, alpha=0.5)\n    xi = curve.colors\n    yi = offsets_splined\n    ax.plot(xi, yi, c='k', lw=5, alpha=0.5)\n    units_string = '$\\mathsf{(' + wt_units.color_symbols[curve.units] + ')}$'\n    ax.set_xlabel(' '.join(['setpoint', units_string]), fontsize=18)\n    ax.set_ylabel(\n        ' '.join(['$\\mathsf{\\Delta}$', curve.motor_names[tuned_motor_index]]), fontsize=18)\n    # colorbar\n    cax = plt.subplot(gs[1, -1])\n    label = channel_name\n    ticks = np.linspace(0, np.nanmax(zi), 7)\n    wt_artists.plot_colorbar(cax=cax, cmap=cmap, label=label, ticks=ticks)\n    # finish ------------------------------------------------------------------\n    if autosave:\n        if save_directory is None:\n            save_directory = os.getcwd()\n        curve.save(save_directory=save_directory, full=True)\n        p = os.path.join(save_directory, 'intensity.png')\n        wt_artists.savefig(p, fig=fig)\n    return curve\n\n\ndef tune_test(data, curve, channel_name, level=False, cutoff_factor=0.01,\n              autosave=True, save_directory=None):\n    \"\"\"\n\n    Parameters\n    ----------\n    data : wt.data.Data object\n        should be in (setpoint, detuning)\n    curve : wt.curve object\n        tuning curve used to do tune_test\n    channel_nam : str\n        name of the signal chanel to evalute\n    level : bool (optional)\n        does nothing, default is False\n    cutoff_factor : float (optoinal)\n        minimum value for datapoint/max(datapoints) for point to be included\n        in the fitting procedure, default is 0.01\n    autosave : bool (optional)\n        saves output curve if True, default is True\n    save_directory : str\n        directory to save new curve, default is None which uses the data source\n        directory\n\n    Returns\n    -------\n    curve\n        New curve object.\n    \"\"\"\n    # make data object\n    data = data.copy()\n    data.bring_to_front(channel_name)\n    data.transpose()\n    # process data ------------------------------------------------------------\n    # cutoff\n    channel_index = data.channel_names.index(channel_name)\n    channel = data.channels[channel_index]\n    cutoff = np.nanmax(channel.values) * cutoff_factor\n    channel.values[channel.values < cutoff] = np.nan\n    # fit\n    gauss_function = wt_fit.Gaussian()\n    g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)\n    outs = g_fitter.run()\n    # spline\n    xi = outs.axes[0].points\n    yi = outs.mean.values\n    spline = wt_kit.Spline(xi, yi)\n    offsets_splined = spline(xi)  # wn\n    # make curve --------------------------------------------------------------\n    curve = curve.copy()\n    curve_native_units = curve.units\n    curve.convert('wn')\n    points = curve.colors.copy()\n    curve.colors += offsets_splined\n    curve.map_colors(points, units='wn')\n    curve.convert(curve_native_units)\n    # plot --------------------------------------------------------------------\n    data.axes[1].convert(curve_native_units)\n    fig, gs = wt_artists.create_figure(default_aspect=0.5, cols=[1, 'cbar'])\n    # heatmap\n    ax = plt.subplot(gs[0, 0])\n    xi = data.axes[1].points\n    yi = data.axes[0].points\n    zi = data.channels[channel_index].values\n    X, Y, Z = wt_artists.pcolor_helper(xi, yi, zi)\n    ax.pcolor(X, Y, Z, vmin=0, vmax=np.nanmax(zi), cmap=cmap)\n    ax.set_xlim(xi.min(), xi.max())\n    ax.set_ylim(yi.min(), yi.max())\n    # lines\n    outs.convert(curve_native_units)\n    xi = outs.axes[0].points\n    yi = outs.mean.values\n    ax.plot(xi, yi, c='grey', lw=5, alpha=0.5)\n    ax.plot(xi, offsets_splined, c='k', lw=5, alpha=0.5)\n    ax.axhline(c='k', lw=1)\n    ax.grid()\n    units_string = '$\\mathsf{(' + wt_units.color_symbols[curve.units] + ')}$'\n    ax.set_xlabel(r' '.join(['setpoint', units_string]), fontsize=18)\n    ax.set_ylabel(r'$\\mathsf{\\Delta' + wt_units.color_symbols['wn'] + '}$', fontsize=18)\n    # colorbar\n    cax = plt.subplot(gs[:, -1])\n    label = channel_name\n    ticks = np.linspace(0, np.nanmax(zi), 7)\n    wt_artists.plot_colorbar(cax=cax, cmap=cmap, label=label, ticks=ticks)\n    # finish ------------------------------------------------------------------\n    if autosave:\n        if save_directory is None:\n            save_directory = os.path.dirname(data.source)\n        curve.save(save_directory=save_directory, full=True)\n        p = os.path.join(save_directory, 'tune test.png')\n        wt_artists.savefig(p, fig=fig)\n    return curve\n\n\ndef panda(data, curve, channel_name, level=False, cutoff_factor=0.01,\n          autosave=True, save_directory=None):\n    \"\"\"\n\n    Parameters\n    ----------\n    data : wt.data.Data object\n        should be in (setpoint, detuning)\n    curve : wt.curve object\n        tuning curve used to do tune_test\n    channel_nam : str\n        name of the signal chanel to evalute\n    level : bool (optional)\n        does nothing, default is False\n    cutoff_factor : float (optoinal)\n        minimum value for datapoint/max(datapoints) for point to be included\n        in the fitting procedure, default is 0.01\n    autosave : bool (optional)\n        saves output curve if True, default is True\n    save_directory : str\n        directory to save new curve, default is None which uses the data source\n        directory\n\n    Returns\n    -------\n    curve\n        New curve object.\n    \"\"\"\n    # make data object\n    data.bring_to_front(channel_name)\n    data.transpose()\n    # process data ------------------------------------------------------------\n    # cutoff\n    channel_index = data.channel_names.index(channel_name)\n    channel = data.channels[channel_index]\n    cutoff = np.nanmax(channel.values) * cutoff_factor\n    channel.values[channel.values < cutoff] = np.nan\n    # fit\n    # TODO: evaluate suggested edits to fit section\n    function = wt_fit.Moments()\n    fitter = wt_fit.Fitter(function, data, data.axes[0].name)\n    outs = fitter.run()\n    gauss_function = wt_fit.Gaussian()\n    g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)\n    gauss_outs = g_fitter.run()\n    return gauss_outs\n", "path": "WrightTools/tuning/workup.py"}], "after_files": [{"content": "'''\nMethods for processing OPA 800 tuning data.\n'''\n\n\n### import ####################################################################\n\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport os\nimport re\nimport sys\nimport imp\nimport ast\nimport time\nimport copy\nimport inspect\nimport collections\nimport subprocess\nimport glob\n\ntry:\n    import configparser as _ConfigParser  # python 3\nexcept ImportError:\n    import ConfigParser as _ConfigParser  # python 2'\n\nimport matplotlib\nimport matplotlib.pyplot as plt\n\nimport numpy as np\nfrom numpy import sin, cos\n\nimport scipy\nfrom scipy.interpolate import griddata, interp1d, interp2d, UnivariateSpline\nimport scipy.integrate as integrate\nfrom scipy.optimize import leastsq\n\nfrom . import curve as wt_curve\nfrom .. import artists as wt_artists\nfrom .. import data as wt_data\nfrom .. import fit as wt_fit\nfrom .. import kit as wt_kit\nfrom .. import units as wt_units\n\n\n### define ####################################################################\n\n\ncmap = wt_artists.colormaps['default']\ncmap.set_bad([0.75] * 3, 1.)\ncmap.set_under([0.75] * 3)\n\n### processing methods ########################################################\n\n\ndef intensity(data, curve, channel_name, level=False, cutoff_factor=0.1,\n              autosave=True, save_directory=None):\n    '''\n    Parameters\n    ----------\n    data : wt.data.Data objeect\n        should be in (setpoint, motor)\n\n    Returns\n    -------\n    curve\n        New curve object.\n    '''\n    # TODO: documentation\n    data.transpose()\n    channel_index = data.channel_names.index(channel_name)\n    tune_points = curve.colors\n    # process data ------------------------------------------------------------\n    if level:\n        data.level(channel_index, 0, -3)\n    # cutoff\n    channel = data.channels[channel_index]\n    cutoff = np.nanmax(channel.values) * cutoff_factor\n    channel.values[channel.values < cutoff] = np.nan\n    # get centers through expectation value\n    motor_axis_name = data.axes[0].name\n    function = wt_fit.Moments()\n    function.subtract_baseline = False\n    fitter = wt_fit.Fitter(function, data, motor_axis_name, verbose=False)\n    outs = fitter.run(channel_index, verbose=False)\n    offsets = outs.one.values\n    # pass offsets through spline\n    spline = wt_kit.Spline(tune_points, offsets)\n    offsets_splined = spline(tune_points)\n    # make curve --------------------------------------------------------------\n    old_curve = curve.copy()\n    motors = []\n    for motor_index, motor_name in enumerate([m.name for m in old_curve.motors]):\n        if motor_name == motor_axis_name.split('_')[-1]:\n            positions = data.axes[0].centers + offsets_splined\n            motor = wt_curve.Motor(positions, motor_name)\n            motors.append(motor)\n            tuned_motor_index = motor_index\n        else:\n            motors.append(old_curve.motors[motor_index])\n    kind = old_curve.kind\n    interaction = old_curve.interaction\n    curve = wt_curve.Curve(tune_points, 'wn', motors,\n                           name=old_curve.name.split('-')[0],\n                           kind=kind, interaction=interaction)\n    curve.map_colors(old_curve.colors)\n    # plot --------------------------------------------------------------------\n    fig, gs = wt_artists.create_figure(nrows=2, default_aspect=0.5, cols=[1, 'cbar'])\n    # curves\n    ax = plt.subplot(gs[0, 0])\n    xi = old_curve.colors\n    yi = old_curve.motors[tuned_motor_index].positions\n    ax.plot(xi, yi, c='k', lw=1)\n    xi = curve.colors\n    yi = curve.motors[tuned_motor_index].positions\n    ax.plot(xi, yi, c='k', lw=5, alpha=0.5)\n    ax.grid()\n    ax.set_xlim(tune_points.min(), tune_points.max())\n    ax.set_ylabel(curve.motor_names[tuned_motor_index], fontsize=18)\n    plt.setp(ax.get_xticklabels(), visible=False)\n    # heatmap\n    ax = plt.subplot(gs[1, 0])\n    xi = data.axes[1].points\n    yi = data.axes[0].points\n    zi = data.channels[channel_index].values\n    X, Y, Z = wt_artists.pcolor_helper(xi, yi, zi)\n    ax.pcolor(X, Y, Z, vmin=0, vmax=np.nanmax(zi), cmap=cmap)\n    ax.set_xlim(xi.min(), xi.max())\n    ax.set_ylim(yi.min(), yi.max())\n    ax.grid()\n    ax.axhline(c='k', lw=1)\n    xi = curve.colors\n    yi = offsets\n    ax.plot(xi, yi, c='grey', lw=5, alpha=0.5)\n    xi = curve.colors\n    yi = offsets_splined\n    ax.plot(xi, yi, c='k', lw=5, alpha=0.5)\n    units_string = '$\\mathsf{(' + wt_units.color_symbols[curve.units] + ')}$'\n    ax.set_xlabel(' '.join(['setpoint', units_string]), fontsize=18)\n    ax.set_ylabel(\n        ' '.join(['$\\mathsf{\\Delta}$', curve.motor_names[tuned_motor_index]]), fontsize=18)\n    # colorbar\n    cax = plt.subplot(gs[1, -1])\n    label = channel_name\n    ticks = np.linspace(0, np.nanmax(zi), 7)\n    wt_artists.plot_colorbar(cax=cax, cmap=cmap, label=label, ticks=ticks)\n    # finish ------------------------------------------------------------------\n    if autosave:\n        if save_directory is None:\n            save_directory = os.getcwd()\n        curve.save(save_directory=save_directory, full=True)\n        p = os.path.join(save_directory, 'intensity.png')\n        wt_artists.savefig(p, fig=fig)\n    return curve\n\n\ndef tune_test(data, curve, channel_name, level=False, cutoff_factor=0.01,\n              autosave=True, save_directory=None):\n    \"\"\"\n\n    Parameters\n    ----------\n    data : wt.data.Data object\n        should be in (setpoint, detuning)\n    curve : wt.curve object\n        tuning curve used to do tune_test\n    channel_nam : str\n        name of the signal chanel to evalute\n    level : bool (optional)\n        does nothing, default is False\n    cutoff_factor : float (optoinal)\n        minimum value for datapoint/max(datapoints) for point to be included\n        in the fitting procedure, default is 0.01\n    autosave : bool (optional)\n        saves output curve if True, default is True\n    save_directory : str\n        directory to save new curve, default is None which uses the data source\n        directory\n\n    Returns\n    -------\n    curve\n        New curve object.\n    \"\"\"\n    # make data object\n    data = data.copy()\n    data.bring_to_front(channel_name)\n    data.transpose()\n    # process data ------------------------------------------------------------\n    # cutoff\n    channel_index = data.channel_names.index(channel_name)\n    channel = data.channels[channel_index]\n    cutoff = np.nanmax(channel.values) * cutoff_factor\n    channel.values[channel.values < cutoff] = np.nan\n    # fit\n    gauss_function = wt_fit.Gaussian()\n    g_fitter = wt_fit.Fitter(gauss_function, data, data.axes[0].name)\n    outs = g_fitter.run()\n    # spline\n    xi = outs.axes[0].points\n    yi = outs.mean.values\n    spline = wt_kit.Spline(xi, yi)\n    offsets_splined = spline(xi)  # wn\n    # make curve --------------------------------------------------------------\n    curve = curve.copy()\n    curve_native_units = curve.units\n    curve.convert('wn')\n    points = curve.colors.copy()\n    curve.colors += offsets_splined\n    curve.map_colors(points, units='wn')\n    curve.convert(curve_native_units)\n    # plot --------------------------------------------------------------------\n    data.axes[1].convert(curve_native_units)\n    fig, gs = wt_artists.create_figure(default_aspect=0.5, cols=[1, 'cbar'])\n    # heatmap\n    ax = plt.subplot(gs[0, 0])\n    xi = data.axes[1].points\n    yi = data.axes[0].points\n    zi = data.channels[channel_index].values\n    X, Y, Z = wt_artists.pcolor_helper(xi, yi, zi)\n    ax.pcolor(X, Y, Z, vmin=0, vmax=np.nanmax(zi), cmap=cmap)\n    ax.set_xlim(xi.min(), xi.max())\n    ax.set_ylim(yi.min(), yi.max())\n    # lines\n    outs.convert(curve_native_units)\n    xi = outs.axes[0].points\n    yi = outs.mean.values\n    ax.plot(xi, yi, c='grey', lw=5, alpha=0.5)\n    ax.plot(xi, offsets_splined, c='k', lw=5, alpha=0.5)\n    ax.axhline(c='k', lw=1)\n    ax.grid()\n    units_string = '$\\mathsf{(' + wt_units.color_symbols[curve.units] + ')}$'\n    ax.set_xlabel(r' '.join(['setpoint', units_string]), fontsize=18)\n    ax.set_ylabel(r'$\\mathsf{\\Delta' + wt_units.color_symbols['wn'] + '}$', fontsize=18)\n    # colorbar\n    cax = plt.subplot(gs[:, -1])\n    label = channel_name\n    ticks = np.linspace(0, np.nanmax(zi), 7)\n    wt_artists.plot_colorbar(cax=cax, cmap=cmap, label=label, ticks=ticks)\n    # finish ------------------------------------------------------------------\n    if autosave:\n        if save_directory is None:\n            save_directory = os.path.dirname(data.source)\n        curve.save(save_directory=save_directory, full=True)\n        p = os.path.join(save_directory, 'tune test.png')\n        wt_artists.savefig(p, fig=fig)\n    return curve\n", "path": "WrightTools/tuning/workup.py"}]}