Frequency sweep odmr

Trying to make a script now, which is going to measure odmr over a range of frequencies. This should help to find the frequency, where the wire is most efficient.


In [7]:
import time

In [ ]:
def perform_odmr_measurement(self, freq_start, freq_step, freq_stop, power,
                                 runtime, fit_function='Lorentzian',
                                 save_after_meas=True, name_tag=''):

In [8]:
freq_range = 0.1 * 10**(9)
freq_step = 2 * 10**(6)
steps = 40
freq_sweep_start = 4.1*10**(9)
freq_sweep_stop = 9.0 * 10**(9)
power = -20
runtime = 120.0
freq_step2 = (freq_sweep_stop-freq_sweep_start)/steps
freq_list = [freq_sweep_start + i*freq_step2 for i in range(steps+1)]
mag_list = [(i-2.87*10**9)/(28*10**9) for i in freq_list]
y_data = []
x_data = []

In [6]:
freq_step/10**6


Out[6]:
2.0

In [9]:
for ii, freq in enumerate(freq_list):
    save_data = {}
    myscmagnet.move_abs({'rho': mag_list[ii]})
    while magnet_logic._check_is_moving():
        time.sleep(1)
    confocal.refocus_clicked()
    time.sleep(30)
    # odmrlogic.perform_odmr_measurement(freq, freq_step, freq + freq_range, power, runtime, save_after_meas=False)
    odmrlogic.mw_start = freq
    odmrlogic.mw_step = freq_step
    odmrlogic.mw_stop = freq + freq_range
    odmrlogic.mw_power = power
    odmrlogic.run_time = runtime
    odmrlogic.start_odmr_scan()
    while odmrlogic.getState() != 'idle':
        time.sleep(1)
    freq_vals = odmrlogic.ODMR_plot_x
    sig_vals = odmrlogic.ODMR_plot_y
    save_data['freq_vals'] = freq_vals
    save_data['sig_vals'] = sig_vals
    filepath = savelogic.get_path_for_module(module_name='ODMR')
    filelabel = 'ODMR_FREQ_SWEEP_' + str(freq)
    savelogic.save_data(save_data, filepath, filelabel=filelabel, as_text=True)


set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off
set cw
off

In [7]:
freq_start = 7.45 * 10**(9)
freq_step = 2 * 10**(6)
freq_stop = 7.55 * 10**(9)
power = -20
runtime = 60.0
name_tag = 'frequency_sweep'

In [8]:
save_data = {}
confocal.refocus_clicked()
time.sleep(30)
# odmrlogic.perform_odmr_measurement(freq, freq_step, freq + freq_range, power, runtime, save_after_meas=False)
odmrlogic.mw_start = freq_start
odmrlogic.mw_step = freq_step
odmrlogic.mw_stop = freq_stop
odmrlogic.mw_power = power
odmrlogic.run_time = runtime
odmrlogic.start_odmr_scan()
while odmrlogic.getState() != 'idle':
    time.sleep(1)
freq_vals = odmrlogic.ODMR_plot_x
sig_vals = odmrlogic.ODMR_plot_y
save_data['freq_vals'] = freq_vals
save_data['sig_vals'] = sig_vals
filepath = savelogic.get_path_for_module(module_name='ODMR')
filelabel = 'ODMR_FREQ_SWEEP_1'
savelogic.save_data(save_data, filepath, filelabel=filelabel, as_text=True)


set cw
off

In [5]:
odmrlogic.ODMR_plot_x


Out[5]:
array([  4.95000000e+09,   4.95200000e+09,   4.95400000e+09,
         4.95600000e+09,   4.95800000e+09,   4.96000000e+09,
         4.96200000e+09,   4.96400000e+09,   4.96600000e+09,
         4.96800000e+09,   4.97000000e+09,   4.97200000e+09,
         4.97400000e+09,   4.97600000e+09,   4.97800000e+09,
         4.98000000e+09,   4.98200000e+09,   4.98400000e+09,
         4.98600000e+09,   4.98800000e+09,   4.99000000e+09,
         4.99200000e+09,   4.99400000e+09,   4.99600000e+09,
         4.99800000e+09,   5.00000000e+09,   5.00200000e+09,
         5.00400000e+09,   5.00600000e+09,   5.00800000e+09,
         5.01000000e+09,   5.01200000e+09,   5.01400000e+09,
         5.01600000e+09,   5.01800000e+09,   5.02000000e+09,
         5.02200000e+09,   5.02400000e+09,   5.02600000e+09,
         5.02800000e+09,   5.03000000e+09,   5.03200000e+09,
         5.03400000e+09,   5.03600000e+09,   5.03800000e+09,
         5.04000000e+09,   5.04200000e+09,   5.04400000e+09,
         5.04600000e+09,   5.04800000e+09,   5.05000000e+09])

In [8]:
x = odmrlogic.ODMR_plot_x
y = odmrlogic.ODMR_plot_y

In [9]:
from matplotlib import pyplot

In [11]:
pyplot.plot(x,y)
pyplot.show()



In [12]:
result = fitlogic.make_lorentzian_fit(axis=x, data=y)

In [14]:
result.params.pretty_print()


Name          Value      Min      Max   Stderr     Vary     Expr
amplitude  -6.227e+10     -inf   -1e-12 7.496e+09     True     None
c          9.554e+04     -inf      inf    92.65     True     None
center     4.983e+09 4.848e+09 5.152e+09 4.466e+05     True     None
fwhm       1.018e+07     -inf      inf 1.483e+06    False 2.0000000*sigma
height        -3894     -inf      inf    342.8    False 0.3183099*amplitude/sigma
sigma      5.091e+06    1e+06    1e+09 7.417e+05     True     None

In [38]:
myscmagnet.move_abs({'rho':0.078})


Out[38]:
0

In [ ]:
def refocus_clicked(self):
        """ Start optimize position. """
        self.disable_scan_actions()
        # Get the current crosshair position to send to optimizer
        crosshair_pos = self._scanning_logic.get_position()
        self.sigStartOptimizer.emit(crosshair_pos, 'confocalgui')

In [39]:
confocal.refocus_clicked()

In [63]:
meas_param = {}
meas_param['ODMR frequency start (Hz)'] = [2]
meas_param['ODMR frequency step (Hz)'] = [3]
meas_param['ODMR frequency stop (Hz)'] = [4]
meas_param['ODMR power (dBm)'] = [5]
meas_param['ODMR run time (s)'] = [6]

In [64]:
filelabel = 'test'

In [65]:
filepath = savelogic.get_path_for_module(module_name='ODMR')
savelogic.save_data(meas_param, filepath, filelabel=filelabel, as_text=True)

In [48]:
odmrlogic.mw_stop


Out[48]:
5050000000.0

In [52]:
odmrlogic.run_time, odmrlogic.mw_power, odmrlogic.mw_stop, odmrlogic.mw_step, odmrlogic.mw_start


Out[52]:
(60.0, -16, 5050000000.0, 2000000, 4950000000.0)

In [2]:
test_x = [i for i in range(9)]
test_y = [i**2 for i in test_x]

In [4]:
filepath = savelogic.get_path_for_module(module_name='ODMR')
filelabel = 'ODMR_FREQ_SWEEP_'
savelogic.save_data({'x': test_x}, filepath, filelabel=filelabel, as_text=True)

In [7]:
odmrlogic.ODMR_plot_y


Out[7]:
array([ 76370.,  76763.,  76170.,  76323.,  75733.,  76031.,  75720.,
        75771.,  76537.,  76385.,  75892.,  76111.,  76011.,  75933.,
        75914.,  75556.,  76296.,  76665.,  76046.,  76283.,  75653.,
        76155.,  76173.,  75240.,  76002.,  76232.,  76035.,  76234.,
        75524.,  76185.,  76107.,  76110.,  76600.,  76203.,  76724.,
        76340.,  76320.,  76243.,  76345.,  76829.,  76247.,  76505.,
        76527.,  75630.,  76774.,  76692.,  76451.,  76789.,  76031.,
        76253.,  75940.])

In [6]:
confocal.refocus_clicked()
while confocal.getState() != 'idle':
    time.sleep(1)
    print('wait until ready')

In [9]:
freq_step


Out[9]:
122500000.0

In [ ]: