Source code :: main

[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
 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
110
111
112
113
114
115
#!/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" : "Current drive primary winding current",
        "maximum" : 6e2 #[A]
        },
    { #number 2
        "measuring" : "Toroidal magnetic field coils current",
        "maximum" : 6e3 #[A]
        },
    { #number 3
        "measuring" : "Breakdown primary winding current",
        "maximum" : 6e2 #[A]
        },
    { #number 4
        "measuring" : "Stabilization horizont. mag. field coils current",
        "maximum" : 6e2 #[A]
        },
    { #number 5
        "measuring" : "Stabilization vert. mag. field coils current",
        "maximum" : 6e2 #[A]
        },
    { #number 6
        "measuring" : "Misc current",
        "maximum" : 6e2 #[A]
        },

    ]

    
def acquisition():


    save('config', flukes)
    
    tvec, Flukes = Shot()['Papouch_Za']
    t = time.time()
    r,Flukes,chi2 = DiffFilter(Flukes, mean(diff(tvec)),  500, 1e3)
    print   time.time()-t

    das, ch1  = Shot().get_data('Papouch_Za', 'primary_coil_fluke', return_channel = True)
    das, ch2  = Shot().get_data('Papouch_Za', 'toroidal_coil_fluke', return_channel = True)
    das, ch3  = Shot().get_data('Papouch_Za', 'breakdown_coil_fluke', return_channel = True)
    das, ch4  = Shot().get_data('Papouch_Za', 'horizont_stabilization_coil_fluke', return_channel = True)
    das, ch5  = Shot().get_data('Papouch_Za', 'vertic_stabilization_coil_fluke', return_channel = True)
    das, ch6  = Shot().get_data('Papouch_Za', 'misc_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_current_drive_coils', tvec, Flukes[:, ch1]/scaling_factor[0])
    save_adv_par('I_toroidal_coils', tvec, Flukes[:,ch2]/scaling_factor[1])
    save_adv_par('I_breakdown_coils', tvec, Flukes[:,ch3]/scaling_factor[2])
    save_adv_par('I_horiz_stabilization_coils', tvec, Flukes[:,ch4]/scaling_factor[3])
    save_adv_par('I_vert_stabilization_coils', tvec, Flukes[:,ch5]/scaling_factor[4])
    save_adv_par('I_misc', tvec, Flukes[:,ch6]/scaling_factor[5])

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('Papouch_Za', name , "I [A]", xlim = [0,None], integrated=False, data_rescale =  1/scaling_factor, columns = [0,1,2,3,4,5] , 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()

    

Navigation