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
#!/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 matplotlib.pyplot import *

from numpy import *
from pygolem_lite.config import *
from pygolem_lite.modules import *
from pygolem_lite import Shot

resonant_Bt = 0.0875
R = MajorRadius
a = MinorRadius

def where_first_or_nan(time, values, harmonic=1):
    possible = time[values >= resonant_Bt*harmonic]
    if len(possible) == 0:
        return nan
    else:
        return possible[0]


def make_plots():
    shot = Shot()
    preionization = shot["preionization"]
    # if preionization not in [4, 5, 6, 7]:
    #     saveconst("MWactive", 0)
    #     return
    # else:
    #     saveconst("MWactive", 1)
    t, mw_power = shot["nistandard", "mw_energy"]
    t, Iplasma = shot["plasma_current"]
    t, Uloop = shot["loop_voltage"]
    t, Bt = shot["toroidal_field"] 
    t, haphoto = shot["haphoto"]

    t *= 1e3

    Bt_LFS = R / (R + a) * Bt
    Bt_HFS = R / (R - a) * Bt

    loc = where(mw_power > mw_power.mean())[0]
    mw_start = t[loc[0]]
    mw_end = t[loc[-1]]

    t_resonnant_Bt_HFS = where_first_or_nan(t, Bt_HFS)
    t_resonnant_Bt = where_first_or_nan(t, Bt)
    t_resonnant_Bt_LFS = where_first_or_nan(t, Bt_LFS)

    t_resonnant_2_Bt_HFS = where_first_or_nan(t, Bt_HFS, 2)
    t_resonnant_2_Bt = where_first_or_nan(t, Bt, 2)
    t_resonnant_2_Bt_LFS = where_first_or_nan(t, Bt_LFS, 2)

    def mark_regions():
        axvline(mw_start, c="g", ls="--")
        axvline(mw_end, c="g", ls="--")    
        axvline(t_resonnant_Bt, c="r", ls="--")
        axvline(t_resonnant_Bt_LFS, c="r", ls="--")
        axvline(t_resonnant_Bt_HFS, c="r", ls="--")

        axvline(t_resonnant_2_Bt, c="r", ls=":")
        axvline(t_resonnant_2_Bt_LFS, c="r", ls=":")
        axvline(t_resonnant_2_Bt_HFS, c="r", ls=":")

        
    figure(0)
    axes1 = subplot(511)
    axes1.plot(t, Bt_HFS, "m-", label=r"$B_t$ HFS")    
    axes1.plot(t, Bt, "b-", label=r"$B_t$ center")
    axes1.plot(t, Bt_LFS, "c-", label=r"$B_t$ LFS")
    ylabel(r"$B_t$ [T]")
    ylim(0, Bt_HFS.max()*1.1)
    axes1.axhline(resonant_Bt, c="k", label=("%.4f T" % resonant_Bt))
    axes1.axhline(resonant_Bt * 2, linestyle='--', c="k", label=("%.4f T" % (resonant_Bt * 2)))
    mark_regions()
    l = legend(loc=1, fancybox=True, prop={"size": 10})
    #l.get_frame().set_alpha(0.75)
    axes2 = subplot(512, sharex=axes1)
    axes2.plot(t, Uloop)
    ylabel(r"$U_{loop}$ [V]")
    u_max = shot["loop_voltage_max"]
    ylim(0, u_max+ 0.5)
    mark_regions()
    axes3 = subplot(513, sharex=axes1)
    axes3.plot(t, Iplasma)
    ylabel(r"$I_{plasma}$ [A]")
    ylim(ymin=0)
    mark_regions()
    axes4 = subplot(514, sharex=axes1)
    axes4.plot(t, mw_power)
    ylabel(r"$P_{MW}$ [a.u.]")
    mark_regions()
    axes5 = subplot(515, sharex=axes1)
    axes5.plot(t, haphoto)
    ylabel(r"$H_{\alpha}$ intensity [a.u.]")
    xlabel(r"$t$ [ms]")
    mark_regions()
    savefig("okenko.png")


if __name__ == "__main__":
    make_plots()
    saveconst('status', 0)
    

Navigation