from pygolem_lite import Shot, saveconst
import numpy as np
import matplotlib
matplotlib.rcParams['backend'] = 'Agg'
matplotlib.rc('font', size='10')
import matplotlib.pyplot as plt
R = 47.0 # [Ohm] resistance for U -> I
def calculate_M(U_up, U_down):
return 0.5 * np.log(U_up / U_down) # should be I, but U/R / U/R would be the same
def make_img1(t, M, up_ch, down_ch):
plt.figure(figsize=[12, 6]) #size in inches
plt.plot(t * 1e3, M) # in ms
plt.xlabel('time [ms]')
plt.ylabel('M')
fname = 'M1-ch{}_ch{}.png'.format(up_ch, down_ch)
plt.savefig(fname)
plt.close() #close this figure
def make_img2(t, M, up_ch, down_ch):
plt.figure(figsize=[12, 6]) #size in inches
plt.plot(t * 1e3, M) # in ms
plt.xlabel('time [ms]')
plt.ylabel('M')
fname = 'M2-ch{}_ch{}.png'.format(up_ch, down_ch)
plt.savefig(fname)
plt.close() #close this figure
def make_plots1(probe_channels1, automatic_select_up):
shot = Shot()
t, data_st = shot['papouch_st']
start = shot['plasma_start']
end = shot['plasma_end']
start_idx = np.where(start <= t)[0][0]
end_idx = np.where(t <= end)[0][-1]
t = t[start_idx:end_idx]
for up_ch, down_ch in probe_channels1:
U_down = data_st[start_idx:end_idx,down_ch-1] # data columns is indexed from 0
U_up = data_st[start_idx:end_idx,up_ch-1]
# if automatic_select_up and U_down.mean() > U_up.mean():
# U_up, U_down = U_down, U_up #swap
M = calculate_M(U_up, U_down)
make_img1(t, M, up_ch, down_ch)
probe_channels1 = [
(1, 2),
(3, 4),
(5, 6),
(7, 8),
(9,10),
(11,12),
]
def make_plots2(probe_channels2, automatic_select_up):
shot = Shot()
t, data_ja = shot['papouch_ja']
start = shot['plasma_start']
end = shot['plasma_end']
start_idx = np.where(start <= t)[0][0]
end_idx = np.where(t <= end)[0][-1]
t = t[start_idx:end_idx]
for up_ch, down_ch in probe_channels2:
U_down = data_ja[start_idx:end_idx,down_ch-1] # data columns is indexed from 0
U_up = data_ja[start_idx:end_idx,up_ch-1]
# if automatic_select_up and U_down.mean() > U_up.mean():
# U_up, U_down = U_down, U_up #swap
M = calculate_M(U_up, U_down)
make_img2(t, M, up_ch, down_ch)
probe_channels2 = [
(1, 2),
]
if __name__ == '__main__':
make_plots1(probe_channels1, automatic_select_up=True)
make_plots2(probe_channels2, automatic_select_up=True)
saveconst('status', 0)