#!/usr/bin/python2
# -*- coding: utf-8 -*-
import matplotlib
matplotlib.rcParams['backend'] = 'Agg'
matplotlib.rc('font', size='10')
matplotlib.rc('text', usetex=True) # FIXME !! nicer but slower !!!
from pygolem_lite import *
from pygolem_lite.modules import *
from numpy import *
#from pygolem_lite.config import *
#from pygolem_lite.modules import *
#from matplotlib.pyplot import *
import time
from shutil import copy, move
import os, sys
flukes = [
{ #number 1
"measuring" : "Toroidal magnetic field coils current",
"maximum" : 6e3 #[A]
},
{ #number 2
"measuring" : "Current drive primary winding current",
"maximum" : 6e3 #[A]
},
{ #number 3
"measuring" : "Breakdown winding current",
"maximum" : 6e3 #[A]
},
{ #number 4
"measuring" : "Stabilization vert. mag. field coils current",
"maximum" : 6e3 #[A]
},
]
def acquisition():
save('config', flukes)
tvec, Flukes = Shot()['NIbasic']
t = time.time()
r,Flukes,chi2 = DiffFilter(Flukes, mean(diff(tvec)), 500, 1e3)
print time.time()-t
das, ch1 = Shot().get_data('NIbasic', 'toroidal_mag_field_fluke', return_channel = True)
das, ch2 = Shot().get_data('NIbasic', 'current_drive_filed_fluke', return_channel = True)
das, ch3 = Shot().get_data('NIbasic', 'breakdown_field_fluke', return_channel = True)
das, ch4 = Shot().get_data('NIbasic', 'stabilization_field_fluke', return_channel = True)
scaling_factor = ones(len(flukes))
for i in range(len(flukes)):
_, maximum = flukes[i].values()
scaling_factor[i] = 5 * 10 ** -(log10(maximum / 6) + 1)
save('scaling_factor', scaling_factor)
save_adv_par('I_toroidal_coils', tvec, Flukes[:, ch1]/scaling_factor[0])
save_adv_par('I_current_drive_coils', tvec, Flukes[:,ch2]/scaling_factor[1])
save_adv_par('I_breakdown_coils', tvec, Flukes[:,ch3]/scaling_factor[2])
save_adv_par('I_stabilization_coils', tvec, Flukes[:,ch4]/scaling_factor[3])
def graphs(file_type):
title = "Flukes"
name = []
for i in range(len(flukes)):
measuring, _ = flukes[i].values()
name += [measuring]
scaling_factor = load('scaling_factor.npy')
out = get_data('NIbasic', name , "I [A]", xlim = [0,None], integrated=False, data_rescale = 1/scaling_factor, columns = [0,1,2,3] , smoothing = 1e3)
multiplot(out, title , 'flukes', (10,len(out)*2), 100, 'vertical', file_type)
#icon
#out = get_data('NIbasic', "", "" , xlim = [0,None], xlabel = "",integrated=False, smoothing = 1e6 )
#paralel_multiplot(out, "" , 'icon', (4,3), 40)
os.system('convert -resize 150x120\! flukes.png icon.png')
def main():
if sys.argv[1] == "acquisition":
acquisition()
if sys.argv[1] == "plots":
graphs('png')
saveconst('status', 0)
if __name__ == "__main__":
main()