aboutsummaryrefslogtreecommitdiff
path: root/active_correction/TA dual chopping/workup.py
blob: 5d3e5fe841de120614dec7a8bc33b126ea533dc0 (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
### import ####################################################################


import os

import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['font.size'] = 14

import WrightTools as wt


### define ####################################################################


gd_path = wt.kit.get_path_matching('Google Drive')
directory = os.path.dirname(__file__)

cmap = wt.artists.colormaps['signed']


### process ###################################################################


if True:
    fig, gs = wt.artists.create_figure(nrows=3, cols=[1, 1, 'cbar'],
                                       default_aspect=0.5, width='double')
    def get_vmin_vmax(zi):
        extent = max(zi.max(), -zi.min())
        return -extent, extent
    def plot(data, col_index, name='name'):    
        # raw
        ax = plt.subplot(gs[0, col_index])
        xi = data.axes[1].points
        yi = data.axes[0].points
        zi = data.channels[0].values
        X, Y, Z = wt.artists.pcolor_helper(xi, yi, zi)
        vmin, vmax = get_vmin_vmax(zi)
        ax.pcolor(xi, yi, zi, vmin=vmin, vmax=vmax, cmap=cmap)
        ax.axhline(0, lw=1, c='k')
        ax.set_xlim(xi.min(), xi.max())
        ax.set_ylim(yi.min(), yi.max())
        ax.set_title(name, fontsize=18)
        wt.artists.corner_text('raw', ax=ax, fontsize=18)
        # leveled
        ax = plt.subplot(gs[1, col_index])
        data.level(0, 'd2', -3)
        xi = data.axes[1].points
        yi = data.axes[0].points
        zi = data.channels[0].values
        X, Y, Z = wt.artists.pcolor_helper(xi, yi, zi)
        ax.pcolor(xi, yi, zi, vmin=vmin, vmax=vmax, cmap=cmap)
        ax.axhline(0, lw=1, c='k')
        ax.set_xlim(xi.min(), xi.max())
        ax.set_ylim(yi.min(), yi.max())
        wt.artists.corner_text('leveled', ax=ax, fontsize=18)
        # smoothed
        ax = plt.subplot(gs[2, col_index])
        data.smooth(2)
        xi = data.axes[1].points
        yi = data.axes[0].points
        zi = data.channels[0].values
        X, Y, Z = wt.artists.pcolor_helper(xi, yi, zi)
        ax.pcolor(xi, yi, zi, vmin=vmin, vmax=vmax, cmap=cmap)
        ax.axhline(0, lw=1, c='k')
        ax.set_xlim(xi.min(), xi.max())
        ax.set_ylim(yi.min(), yi.max())
        wt.artists.corner_text('smoothed', ax=ax, fontsize=18)
    # single
    p = os.path.join(directory, 'SCAN [wmw1, d2] 2016.05.30 11_50_06 single', 'SCAN [wmw1, d2] 2016.05.30 11_50_06 single.data')
    data = wt.data.from_PyCMDS(p)
    data.transpose()
    data.bring_to_front('signal_diff')
    data.channels[0].values *= -1
    plot(data, 0, name='single')
    # dual
    p = os.path.join(directory, 'SCAN [wmw1, d2] 2016.05.30 13_32_42 dual', 'SCAN [wmw1, d2] 2016.05.30 13_32_42 dual.data')
    data = wt.data.from_PyCMDS(p)
    data.transpose()
    data.bring_to_front('signal_diff')
    data.channels[0].values *= -1
    plot(data, 1, name='dual')
    # colorbar
    cax = plt.subplot(gs[:, -1])
    matplotlib.colorbar.ColorbarBase(cax, cmap=cmap, ticks=[-1, 0, 1])
    # finish
    plt.savefig('compare.png', dpi=300, transparent=True, pad_inches=1)
    plt.close('fig')