Commit d08cd59e authored by Oscar Gargiulo's avatar Oscar Gargiulo
Browse files

added gaussian fit

parent 2185301f
......@@ -251,6 +251,38 @@ def sqrt_lorentzian_fit(x,*p):
return p[3] * np.sqrt(y) + p[2]
gaussian_fit_pars_labels = ['center', 'sigma', 'offset', 'peak']
def gaussian_fit(x,*p):
"""Gaussian function
.. math::
y(x) = N * exp(-0.5*(x-p[0])/p[1])**2) #N is normalization such that the peak is 1
returns p[3]*y+p[2]
Function parameters:
| p[0] = center
| p[1] = sigma
| p[2] = baseline/vertical offset
| p[3] = peak distance from offset
Parameters
-----------
x : float
x value
*p : args
Initial parameter guesses
Returns
--------
float, np.array, list
Function values. List size depends of given number of parameters
"""
y= np.exp(-0.5*((x-p[0])/p[1])**2)#/(np.sqrt(2*np.pi)*p[1])
return p[3] * y/y.max() + p[2]
cos_fit_pars_labels = ['amplitude', 'period', 'phase', 'offset']
def cos_fit(x, *p):
"""Cosine function
......@@ -340,3 +372,4 @@ def T2_beating_fit(x,*p):
"""
return p[0]*np.sin(2*np.pi/p[1]*x+p[2])*np.sin(2*np.pi/p[3]*x+p[4]) *\
np.exp(-x/p[5])+p[6]
......@@ -17,7 +17,7 @@ class V5015(object):
self.__version__ = VERSION
self.ip = ip
rm = visa.ResourceManager()
self._inst = rm.open_resource('TCPIP0::{}::SOCKET'.format(ip))
self._inst = rm.open_resource('TCPIP::{}::SOCKET'.format(ip))
self._inst.read_termination = '\r\n'
# define amount of lines a single query takes
......
......@@ -67,13 +67,13 @@ def apply_correction(dev,device_id,cal_dict,amplitude):
if cal_dict['Amplitude corrected channel'] == 'chI':
dev.setDouble('/{}/sines/{}/amplitudes/0'.format(device_id,chI), 0)
dev.setDouble('/{}/sines/{}/amplitudes/1'.format(device_id,chI+1), 0)
dev.setDouble('/{}/awgs/{}/outputs/0/amplitude'.format(device_id,int(chI/2)), amplitude*cal_dict['Amplitude ratio']);
dev.setDouble('/{}/awgs/{}/outputs/1/amplitude'.format(device_id,int(chI/2)), amplitude)
dev.setDouble('/{}/awgs/{}/outputs/0/gains/0'.format(device_id,int(chI/2)), amplitude*cal_dict['Amplitude ratio']);
dev.setDouble('/{}/awgs/{}/outputs/1/gains/1'.format(device_id,int(chI/2)), amplitude)
elif cal_dict['Amplitude corrected channel'] == 'chQ':
dev.setDouble('/{}/sines/{}/amplitudes/0'.format(device_id,chI), 0)
dev.setDouble('/{}/sines/{}/amplitudes/1'.format(device_id,chI+1), 0)
dev.setDouble('/{}/awgs/0/outputs/{}/amplitude'.format(device_id,chI+1), amplitude*cal_dict['Amplitude ratio']);
dev.setDouble('/{}/awgs/0/outputs/{}/amplitude'.format(device_id,chI), amplitude)
dev.setDouble('/{}/awgs/{}/outputs/1/gains/1'.format(device_id,chI+1), amplitude*cal_dict['Amplitude ratio']);
dev.setDouble('/{}/awgs/{}/outputs/0/gains/0'.format(device_id,chI), amplitude)
else:
print('Amplitude corrected channel and used channels don\'t match\n')
raise ValueError
......
Markdown is supported
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