sim_data_usage_demo



In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.display import display
import optoanalysis

In [2]:
ConvFactor = 1.8e5

In [3]:
dat = optoanalysis.sim_data.SimData([0, 0.1], 5e6, [75e3, 160e3, 180e3], 4000.0, 3.1e-19, ConvFactor, 1e-30, dt=1e-9)


solving...
solving...
solving...
/home/ash/anaconda2/envs/python3/lib/python3.5/site-packages/scipy/signal/spectral.py:772: UserWarning: nperseg = 1000000, is greater than input length = 500000, using nperseg = 500000
  'using nperseg = {1:d}'.format(nperseg, x.shape[-1]))

In [4]:
# tArray = dat.sde_solvers[0].tArray.get_array()

# fig,ax = plt.subplots()
# ax.plot(tArray, dat.sde_solvers[0].q)
# ax.plot(tArray, dat.sde_solvers[1].q)
# ax.plot(tArray, dat.sde_solvers[2].q)

In [5]:
dat.plot_PSD([0, 300])


Out[5]:
(<matplotlib.figure.Figure at 0x7f98304ac080>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7f97fea9a828>)

In [6]:
dat.extract_ZXY_motion?

In [7]:
z, x, y, t, fig, ax = dat.extract_ZXY_motion([75e3, 160e3, 180e3], 3e3, [10e3, 5e3, 5e3], subSampleFraction=2)


filtering Z
filtering X
filtering Y
/home/ash/anaconda2/envs/python3/lib/python3.5/site-packages/scipy/signal/spectral.py:772: UserWarning: nperseg = 1000000, is greater than input length = 250000, using nperseg = 250000
  'using nperseg = {1:d}'.format(nperseg, x.shape[-1]))

In [8]:
t, z, vz = dat.calc_phase_space(75e3, ConvFactor, FractionOfSampleFreq=2)
t, x, vx = dat.calc_phase_space(160e3, ConvFactor, FractionOfSampleFreq=2)
t, y, vy = dat.calc_phase_space(180e3, ConvFactor, FractionOfSampleFreq=2)


filtering data
filtering data
filtering data

In [9]:
TimeTuple = [500e-6, 1000e-6]
alpha=0.8

In [18]:
plt.plot(t, z, alpha=alpha)
plt.plot(dat.simtime.get_array(), dat.TrueSignals[0, 0], alpha=alpha)
plt.xlim(TimeTuple)


Out[18]:
(0.0005, 0.001)

In [11]:
plt.plot(t[1:], vz, alpha=alpha)
plt.plot(dat.simtime.get_array(), dat.TrueSignals[0, 1], alpha=alpha)
plt.xlim(TimeTuple)


Out[11]:
(0.0005, 0.001)

In [12]:
plt.plot(t, x, alpha=alpha)
plt.plot(dat.simtime.get_array(), dat.TrueSignals[1, 0], alpha=alpha)
plt.xlim(TimeTuple)


Out[12]:
(0.0005, 0.001)

In [13]:
plt.plot(t[1:], vx, alpha=alpha)
plt.plot(dat.simtime.get_array(), dat.TrueSignals[1, 1], alpha=alpha)
plt.xlim(TimeTuple)


Out[13]:
(0.0005, 0.001)

In [14]:
plt.plot(t, y, alpha=alpha)
plt.plot(dat.simtime.get_array(), dat.TrueSignals[2, 0], alpha=alpha)
plt.xlim(TimeTuple)


Out[14]:
(0.0005, 0.001)

In [15]:
plt.plot(t[1:], vy, alpha=alpha)
plt.plot(dat.simtime.get_array(), dat.TrueSignals[2, 1], alpha=alpha)
plt.xlim(TimeTuple)


Out[15]:
(0.0005, 0.001)

In [16]:
dat.get_fit_auto(75e3)


found best

A: 3969235479153.263 +- 5.840222214836059% 
Trap Frequency: 471282.8785324284 +- 0.05436519816391246% 
Big Gamma: 4218.81462428008 +- 12.106241045192178% 
Out[16]:
(471282.8785324284+/-256.21387082674556,
 3969235479153.263+/-231812172212.66336,
 4218.81462428008+/-510.73986766516526,
 <matplotlib.figure.Figure at 0x7f96dc25a908>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7f97fbdfd908>)

In [19]:
dir(dat)


Out[19]:
['A',
 'ConvFactor',
 'DownSampleAmount',
 'Gamma',
 'Gamma0',
 'Noise',
 'NoiseStdDev',
 'OmegaTrap',
 'PSD',
 'SampleFreq',
 'T0',
 'TimeTuple',
 'TrapFreqArray',
 'TrueSignals',
 '__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 'calc_area_under_PSD',
 'calc_phase_space',
 'dt',
 'etaArray',
 'extract_ZXY_motion',
 'extract_parameters',
 'filter_data',
 'freqs',
 'generate_simulated_data',
 'get_PSD',
 'get_fit',
 'get_fit_auto',
 'get_fit_from_peak',
 'get_time_data',
 'load_time_data',
 'mass',
 'plot_PSD',
 'plot_phase_space',
 'plot_phase_space_sns',
 'plot_time_data',
 'q0',
 'seed',
 'simtime',
 'time',
 'timeEnd',
 'timeStart',
 'timeStep',
 'v0',
 'voltage',
 'xVolts',
 'yVolts',
 'zVolts']

In [ ]: