aboutsummaryrefslogtreecommitdiff
path: root/opa_phase/darien_playing.py
diff options
context:
space:
mode:
authorDarien Morrow <darienmorrow@gmail.com>2018-04-09 19:59:35 -0500
committerDarien Morrow <darienmorrow@gmail.com>2018-04-09 19:59:35 -0500
commitae6890544df4d48e0b029ca86e576e934a3d1035 (patch)
tree43592b3936c3b5c443a10f3bd0c2f033048a0638 /opa_phase/darien_playing.py
parent466d572cf7399f7102b0766b430383e28101bfc3 (diff)
opa interferometry
Diffstat (limited to 'opa_phase/darien_playing.py')
-rw-r--r--opa_phase/darien_playing.py110
1 files changed, 110 insertions, 0 deletions
diff --git a/opa_phase/darien_playing.py b/opa_phase/darien_playing.py
new file mode 100644
index 0000000..cc8ce39
--- /dev/null
+++ b/opa_phase/darien_playing.py
@@ -0,0 +1,110 @@
+"""OPA interferometry"""
+
+
+# --- import --------------------------------------------------------------------------------------
+
+
+import numpy as np
+
+import WrightTools as wt
+
+import matplotlib
+import matplotlib.pyplot as plt
+
+import os
+
+
+# --- define --------------------------------------------------------------------------------------
+
+
+folderpath = os.getcwd()
+datafolder = os.path.join(folderpath, '2014.04.10 data')
+
+
+# --- get data ------------------------------------------------------------------------------------
+
+
+p = 'OPA_interferometry.wt5'
+if False:
+ col = wt.Collection(name='root')
+ # autointerference
+ filepath = os.path.join(datafolder, 'auto interferometry (1) 0 ms wait [1x201] Delay.dat')
+ ignore=['w3', 'dref', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6']
+ d = wt.data.from_COLORS(filepath, name='auto', ignore=ignore, parent=col)
+ # crossinterference
+ filepath = os.path.join(datafolder, 'cross interferometry (2) 0 ms wait [1x201] Delay.dat')
+ ignore=['w3', 'dref', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6']
+ d = wt.data.from_COLORS(filepath, name='cross', ignore=ignore, parent=col)
+ # interference over time
+ filepath = os.path.join(datafolder, 'high res (1) 1 shots 100 ms wait [1000] Capture.dat')
+ arr = np.genfromtxt(filepath).T
+ xi = np.arange(1000)*.1 # convert to seconds
+ yi = arr[8][:256]
+ zi = arr[21]
+ zi.shape = (-1, 256)
+ d = wt.Data(name='time', parent=col)
+ d.create_variable('time', values=xi[:, None])
+ d.create_variable('wa', values=yi[None, :], units='nm', label='a')
+ d.create_channel('array', values=zi)
+ d.transform('time', 'wa')
+ col.save(p, overwrite=True)
+
+col = wt.open(p)
+
+
+# --- auto and cross correlation figure -----------------------------------------------------------
+
+
+if True:
+ def plotter(ax, d, label):
+ ax.pcolor(d, channel='mc') # pcolor is kinda distracting
+ ax.set_ylim(1200,1400)
+ ax.set_xlabel('delay (fs)')
+ ax.grid()
+ wt.artists.corner_text(label)
+
+
+ fig, gs = wt.artists.create_figure(width='double', cols=[1,1,'cbar'])
+ # auto
+ ax = plt.subplot(gs[0,0])
+ plotter(ax, col.auto, 'auto-interference')
+ # cross
+ ax = plt.subplot(gs[0,1])
+ plotter(ax, col.cross, 'cross-interference')
+ # pretty up
+ wt.artists.set_fig_labels(ylabel=col.auto.wa.label)
+ # colorbar
+ cax = plt.subplot(gs[0,-1])
+ ticks = np.linspace(0,1,11)
+ label = 'norm array signal'
+ wt.artists.plot_colorbar(cax, ticks=ticks, label=label)
+ # finish
+ p = 'auto_cross_interference.png'
+ wt.artists.savefig(p)
+
+
+# --- over time -----------------------------------------------------------------------------------
+
+
+if True:
+ def plotter(ax, d):
+ ax.pcolor(d) # pcolor is kinda distracting
+ ax.set_ylim(1250,1350)
+ ax.set_xlabel('lab time (s)')
+ ax.set_ylabel(col.auto.wa.label)
+ ax.grid()
+
+ #d.array.clip(.3)
+ fig, gs = wt.artists.create_figure(width='double', cols=[1, 'cbar'], default_aspect=.5)
+ # overtime
+ ax = plt.subplot(gs[0,0])
+ plotter(ax, col.time)
+ ax.hlines(1300, 0, 99.9, color='grey', linewidth=5, alpha=.7, zorder=10)
+ # colorbar
+ cax = plt.subplot(gs[0,-1])
+ ticks = np.linspace(0,1,11)
+ label = 'norm array signal'
+ wt.artists.plot_colorbar(cax, ticks=ticks, label=label)
+ # finish
+ p = 'time_interference.png'
+ wt.artists.savefig(p)