aboutsummaryrefslogtreecommitdiff
path: root/opa_phase/darien_playing.py
blob: b8bd5b76e0eb5ffebf7c220d2b760993927410be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""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)