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
#!/usr/bin/env python
# -*- coding: utf-8 -*-


#main script from the vagnetic profile animation generator. 
#Autor :Tomas Odstrcil


import time
cas = time.time()

import matplotlib 
matplotlib.rcParams['backend'] = 'Agg'
matplotlib.rc('font',  size='10')
matplotlib.rc('text', usetex=True)  # FIXME !! nicer but slower !!!
import matplotlib.pyplot as plt

from numpy import *
import os
import sys
from pygolem_lite.modules import saveconst
from scipy.signal import  fftconvolve,gaussian
from scipy.interpolate import interpolate
import MagFieldProfileGen

from pygolem_lite import Shot
print 'including time: ',  time.time()-cas




#constants
a = 0.085		#[m]
R_0 = 0.4		#[m]





  
def LoadData():
    Data = Shot()
    
    
    tvec, R_position =  Data['plasma_position_r']
    tvec, Z_position =  Data['plasma_position_z']

    Ip = array(Data['plasma_current'], copy = False).T


    return tvec,R_position,Z_position,Ip


def Resample(tvec,vec,t_min,t_max,n):
    
    std = (t_max-t_min)/(tvec[1]-tvec[0])/n/2
    gauss_win = gaussian(std*3,std)
    gauss_win/= sum(gauss_win)
    vec_smmoth = fftconvolve(vec,gauss_win, mode = 'same')
    tvec_new = linspace(t_min,t_max,n)
    f = interpolate.interp1d(tvec,vec_smmoth,bounds_error = False, fill_value = 0, copy = False)
    vec_new = f(tvec_new)
    

    return tvec_new,vec_new
    
    

def graphs():
    tvec,R_position,Z_position,Ip = LoadData()    
    tvec,Ip = Resample(Ip[:,0],Ip[:,1],tvec[0],tvec[-1],len(tvec)) 
    position = vstack((R_position,Z_position)).T
    
    
    #plot animation -- very slow!!!
    print "plotting animation" 
    MagFieldProfileGen.PlotProfile(tvec,Ip,position, 'animation')
    

def main():
    
    if not os.path.exists('video'):
	os.mkdir('video')

    if sys.argv[1] ==  "plots":
	graphs()
	saveconst('status', 0)



if __name__ == "__main__":
    main()
    	 

Navigation