Source code :: plots

[Return]
 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
from pygolem_lite import Shot
import numpy as np

import matplotlib
matplotlib.rcParams['backend'] = 'Agg'
matplotlib.rc('font',  size='10')

import matplotlib.pyplot as plt
from scipy.ndimage import median_filter
from matplotlib.pyplot import axvline

def make_img(data, fname, interpolation, start, end,shotno):
    plt.figure(figsize=[12, 6])          #size in inches
    plt.imshow(data,
        aspect='auto',
        extent = [start * 1e3, end * 1e3,   #time extents in ms
                   19, 1,],                   #channel idx
        interpolation=interpolation,
        cmap=plt.cm.hot,
        )
    hx = plt.colorbar()
    hx.set_label('P[W/sr/m$^2$]')
    plt.xlabel('time [ms]')
    plt.ylabel('channel number')
    plt.text(11, 2, 'TOP')
    plt.text(10.5, 18, 'BOTTOM')
    #cx = axvline(x = 16,linewidth=5, color='black')
    #cx.set_label('16 ms')
    plt.title('SHOT NUMBER ' '%d'%shotno)
    plt.text(21.5, 2, 'P[W/sr/m$^2$]')
    plt.yticks(np.arange(1, 19+1))
    plt.savefig(fname)
    plt.close()                           #close this figure

def plot_cut(data, fname,shotno):
    plt.plot(data[:,6000],'r+',markersize = 10)
    plt.savefig(fname) 
    plt.xlabel('channel number')
    plt.ylabel('P[W/sr/m$^2$]')
    plt.title('SHOT NUMBER ' '%d'%shotno)

def make_plots():
    shot = Shot()
    t, data_za = shot['papouch_za']
    t, data_ko = shot['papouch_ko']
    start = shot['plasma_start']
    end = shot['plasma_end']
    shotno = shot['shotno']
    vector_coef = np.genfromtxt('coeficients_AXUV2.txt')
    start_idx = np.where(start <= t)[0][0]
    end_idx = np.where(t <= end)[0][-1]
    data = np.hstack([data_za, data_ko]) # NOTE: make sure this is the right order
    data = data[start_idx:end_idx,0:18]
    for i in range(18):
      data[:,i] = data[:,i]*vector_coef[i]
    data = data.T                    # transpose to have time as x axis; 
    
    plot_cut(data, 'bolometer_timecut.png',shotno)
    make_img(data, 'bolometers.png', 'none', start, end,shotno)
    make_img(median_filter(data, size=(3, 333)), 
'bolometers_medfilt-bicube_interp.png', 'bicubic', start, end,shotno)


if __name__ == '__main__':
    make_plots()

Navigation