In [1]:
%matplotlib inline
import optoanalysis
from numpy import pi
In [2]:
optoanalysis.properties["default_fig_size"] = (7, 5) # sets default fig size for optoanalysis plots
In [3]:
data = optoanalysis.load_data("testData.raw")
In [4]:
data.plot_time_data(timeStart=0, timeEnd=200, units='us')
Out[4]:
In [5]:
fig, ax = data.plot_PSD([0, 300]); # Plot PSD of loaded data
In [6]:
W_trap_z, A, Gamma, fig, ax = data.get_fit_auto(75e3); # fit to Z peak of loaded data and extracts the parameters A (The A parameter), W_trap_z (the trap frequency in Z) and Gamma (the damping on Z)
In [7]:
# next 3 lines are just me getting the pressure value from a file
with open("testDataPressure.dat", 'r') as file:
for line in file:
pressure = float(line.split("mbar")[0])
R, M, ConvFactorZ = data.extract_parameters(pressure, 0.15) # extracts the radius of the particle, mass and conversion factor for the z degree of freedom (used to convert volts to meters of particle motion)
In [8]:
print(R, M, ConvFactorZ)
In [9]:
F_trap_z = W_trap_z/(2*pi)
In [10]:
print(F_trap_z)
In [11]:
fig, axscatter, axhistx, axhisty, cbar = data.plot_phase_space(F_trap_z.n, ConvFactorZ, FractionOfSampleFreq=3, figsize=[7, 7]); # this filters for the z motion, calculates the phase space of this motion and plots it using the qplots library
In [12]:
W_trap_x, A, Gamma, fig, ax = data.get_fit_auto(160e3); # fits to the x peak
R, M, ConvFactorX = data.extract_parameters(pressure, 0.15) # extracts parameters from x peak
W_trap_y, A, Gamma, fig, ax = data.get_fit_auto(180e3); # fits to the y peak
R, M, ConvFactorY = data.extract_parameters(pressure, 0.15)# extracts parameters from y peak
In [13]:
print(ConvFactorZ, ConvFactorX, ConvFactorY) # conversion factor for z is larger than conversion factor for x and y (which have similar values) as our detection more sesitive to z than x and y
In [14]:
z, x, y, t, fig, ax = data.extract_ZXY_motion([75e3, 165e3, 180e3], 10e3, [10e3, 10e3, 10e3], subSampleFraction=3) # extracts the motion of z, x and y
In [15]:
znm = z/ConvFactorZ.n*1e9
In [16]:
sample_freq = data.SampleFreq/3
In [17]:
wigner, centres = optoanalysis.get_wigner(znm, F_trap_z.n, sample_freq, histbins=1000)
In [18]:
optoanalysis.plot_wigner3d(wigner, centres, "nm")
Out[18]:
In [19]:
optoanalysis.plot_wigner2d(wigner, centres)
Out[19]:
In [20]:
optoanalysis.animate(z, x, y, [ConvFactorZ.n, ConvFactorX.n, ConvFactorY.n], t, 150, timeSteps=25) # animates the motion of z, x and y
In [21]:
PRef = 2.703
Pcooled = 0.0232
In [22]:
ref = optoanalysis.load_data("CH1_RUN00000001_REPEAT0000.raw")
cooldata = optoanalysis.load_data("CH1_RUN00000036_REPEAT0000.raw")
In [23]:
optoanalysis.multi_plot_PSD([ref, cooldata], [0, 200])
Out[23]:
In [24]:
ref.get_PSD(0.5e5)
Out[24]:
In [25]:
W_trap_z, A, Gamma, fig, ax = ref.get_fit_auto(60e3, MaxWidth=5000); # fits to the z peak
R, M, ConvFactorZ = ref.extract_parameters(PRef, 0.15) # extracts parameters from z peak
W_trap_x, A, Gamma, fig, ax = ref.get_fit_auto(150e3); # fits to the x peak
R, M, ConvFactorX = ref.extract_parameters(PRef, 0.15) # extracts parameters from x peak
W_trap_y, A, Gamma, fig, ax = ref.get_fit_auto(166e3, MaxWidth=10e3); # fits to the y peak
R, M, ConvFactorY = ref.extract_parameters(PRef, 0.15)# extracts parameters from y peak
In [26]:
fz = W_trap_z/(2*pi)
fx = W_trap_x/(2*pi)
fy = W_trap_y/(2*pi)
In [27]:
z, x, y, t, fig, ax = ref.extract_ZXY_motion([fz, fx, fy], 6e3, [10e3, 10e3, 10e3], subSampleFraction=1) # extracts the motion of z, x and y
optoanalysis.animate(z, x, y, [ConvFactorZ.n, ConvFactorX.n, ConvFactorY.n], t, 150, timeSteps=25, filename="referenceParticle") # animates the motion of z, x and y