Track frequency shift

Script intended to measure the frequency over a specific timeframe


In [1]:
import pylab as pb
import time
import os
import numpy as np

In [3]:
confocal.refocus_clicked()

In [ ]:
# some parameters (total time, time for individual measurement, refocus rate)
T_tot = 60*60
T_meas = 5* 60
refocus_rate = 1/(5*60)

In [2]:
os.chdir(r'C:\Users\Quantum Optics\QuDi\qudi\notebooks\FreqShift')

In [12]:
# first I need to be able to actually start a single measurement  
time_start = time.time()
pulsedmasterlogic.start_measurement()
confocal.refocus_clicked()
time.sleep(120)
pulsedmasterlogic.stop_measurement()
time_meas = time.time() - time_start
# till here it works, then data needs to be processed and saved
freqs = pulsedmeasurement.signal_plot_x * 10**6
signal = pulsedmeasurement.signal_plot_y
pb.plot(pulsedmeasurement.signal_plot_x, pulsedmeasurement.signal_plot_y)
fname = 'freq_over_time_{0}.pdf'.format(time_meas)
sname = 'freq_over_time_{0}.txt'.format(time_meas)
pb.savefig(fname)
np.savetxt(sname, np.array([freqs, signal]).T)
# now everything is saved, lets do the fitting
results = fitlogic.make_N14_fit(axis=freqs, data=signal)
freq_peaks = [time_meas, results.params['lorentz0_center'].value, results.params['lorentz1_center'].value, results.params['lorentz2_center'].value]
file = open('peak_freqs.txt', 'a')
file.write(" ".join(map(str, freq_peaks)))
file.write("\n")
file.close()

In [4]:
# Lets make test run for about 12 hours
time_start = time.time()
for i in range(120):
    pulsedmasterlogic.start_measurement()
    confocal.refocus_clicked()
    time.sleep(150)
    confocal.refocus_clicked()
    time.sleep(150)
    pulsedmasterlogic.stop_measurement()
    time_meas = time.time() - time_start
    # till here it works, then data needs to be processed and saved
    freqs = pulsedmeasurement.signal_plot_x * 10**6
    signal = pulsedmeasurement.signal_plot_y
    pb.plot(pulsedmeasurement.signal_plot_x, pulsedmeasurement.signal_plot_y)
    fname = 'freq_over_time_{0}.pdf'.format(time_meas)
    sname = 'freq_over_time_{0}.txt'.format(time_meas)
    pb.savefig(fname)
    pb.close()
    np.savetxt(sname, np.array([freqs, signal]).T)
    # now everything is saved, lets do the fitting
    results = fitlogic.make_N14_fit(axis=freqs, data=signal)
    freq_peaks = [time_meas, results.params['lorentz0_center'].value, results.params['lorentz1_center'].value, results.params['lorentz2_center'].value]
    file = open('peak_freqs.txt', 'a')
    file.write(" ".join(map(str, freq_peaks)))
    file.write("\n")
    file.close()

In [1]:
# lets test it for 5 hourse hours
for

In [5]:
time.time()


Out[5]:
1483960216.3855853

In [10]:
np.savetxt('test.txt', np.array([pulsedmeasurement.signal_plot_x*10**6, pulsedmeasurement.signal_plot_y].T))

In [11]:
data = np.loadtxt('test.txt')

In [12]:
data[:,0]


Out[12]:
array([  1.79500000e+04,   1.03109055e+00])

In [30]:
file = open('peak_freqs.txt', 'a')

In [31]:
testvec = np.array([i for i in range(10)])
testvec2 = np.array([i*2 for i in range(10)])

In [32]:
file.write(" ".join(map(str, testvec2)))


Out[32]:
24

In [5]:
freq_peaks


Out[5]:
[17958944451.47972, 17961094451.47972, 17963244451.47972]

In [ ]: