示例#1
0
def getshot():
    shot = l2.get()  #获取文本框内容
    shot = int(shot)
    [t_pas104, pas104] = get.data('JHF1', shot, 'east_1')
    pas104 = 1e4 * pas104
    if len(t_pas104) > 1000:

        [t_pas105, pas105] = get.data('PAS105', shot, 'east_1')
        pas105 = 1e4 * pas105
        [t_pas103, pas103] = get.data('PAS103', shot, 'east_1')
        pas103 = 1e4 * pas103
        [t_smbi3, smbi3] = get.data('SMBI3', shot, 'east')
        [t_g105, g105] = get.data('G105', shot, 'east_1')
        g105 = np.exp(1.667 * g105 - 9.333)
        print('SMBI3 ok')

        [t_pjs203, pjs203] = get.data('PJS203', shot, 'east_1')
        pjs203 = 1e4 * pjs203
        [t_pjs204, pjs204] = get.data('PJS204', shot, 'east_1')
        pjs204 = 1e4 * pjs204
        [t_pjs205, pjs205] = get.data('PJS205', shot, 'east_1')
        pjs205 = 1e4 * pjs205
        [t_smbi2, smbi2] = get.data('SMBI2', shot, 'east')
        [t_g103, g103] = get.data('G401', shot, 'east_1')
        g103 = np.exp(1.667 * g103 - 9.333)
        print('SMBI2 ok')

        plt.figure(figsize=(9, 9))

        plt.subplot(4, 2, 1)
        plt.plot(t_pjs204, pjs204)
        plt.title('SMBI2')

        plt.subplot(4, 2, 2)
        plt.plot(t_pas104, pas104)
        plt.title('SMBI3')

        plt.subplot(4, 2, 3)
        plt.plot(t_pjs205, pjs205)

        plt.subplot(4, 2, 4)
        plt.plot(t_pas105, pas105)

        plt.subplot(4, 2, 5)
        plt.plot(t_smbi2, smbi2, color='red')

        plt.subplot(4, 2, 6)
        plt.plot(t_smbi3, smbi3, color='red')

        plt.subplot(4, 2, 7)
        plt.plot(t_g103, g103)

        plt.subplot(4, 2, 8)
        plt.plot(t_g105, g105)

        plt.show()

    else:
        l3.delete('1.0', 'end')
        l3.insert('end', 'Error: No data')
示例#2
0
def spec_stft(signal, shot, tree, timerange, vmax=0.002, fcut=0):
    [t, x] = get.data(signal, shot, tree)
    index = np.where((t>timerange[0])&(t<timerange[1]))
    t = t[index]
    x = x[index]
    nfft = 1024

    dt = (t[22]-t[2])//20
    ts=dt*1000
    fs=1/ts
    f, tf, Zxx = signal.stft(x, fs, nperseg=nfft, noverlap =nfft//2, detrend='constant')
    tf = tf+timerange[0]
    Zxx = np.abs(Zxx)
    Zxx[0:1,:]=0
    vmin =0
    if vmax == -1:
        Zxx = np.log10(Zxx)-np.log10(np.max(Zxx))
        vmax = max(Zxx)
        vmin = min(Zxx)

    plt.figure()
    plt.pcolormesh(tf, f, Zxx, vmin=vmin, vmax=vmax, cmap='jet')
    plt.title('STFT Magnitude')
    plt.ylabel('Frequency [Hz]')
    lt.xlabel('Time [sec]')
    plt.colorbar()
    if fcut != 0:
        pllt.ylim([0, fcut])

    plt.show

    return tf, f, Zxx
示例#3
0
def plot_data():

    plt.figure(figsize=(9, 12))

    [shots, signals, trees, begin, end, low_filter, up_filter] = get_input()

    i = 0
    colors = ['b', 'r', 'g', 'k', 'y']
    n = len(signals)
    for signal in signals:
        tree = trees[i]
        i = i+1
        j = 0
        for shot in shots:
            color = colors[j]
            j = j+1
            [t, y] = get.data(signal, shot, tree)
            
            index = np.where((t>=begin)&(t<=end))            
            t = t[index]
            y = y[index]

            if up_filter != 0:
                fs = 100/(t[100]-t[0])
                if low_filter == 0:
                    y = filter.high_pass(y, up_filter, fs)
                elif up_filter >= 0.5*fs:
                    y = filter.low_pass(y, low_filter, fs)
                else:
                    y = filter.band_stop(y, low_filter, up_filter, fs)
                
                
                
            
            
            
            plt.subplot(n, 1, i)
            if i==1:
                plt.plot(t, y, color=color, label=str(shot))
                plt.legend()
                plt.grid()
            else:
                plt.plot(t, y, color=color)
                plt.grid()
            if j==1:
                if i==n:
                    plt.xlabel('time (s)')
                plt.ylabel(signal)
            # if i==1:
            #     tmp = 1.1*np.max(y)
            #     locationY
            #     locationX = begin+(end-begin)/6*j
            #     plt.text(locationX, locationY, str(shot), color=color, fontsize=12)



    plt.show()
示例#4
0
def read(shot, timerange):
    from east_mds import get_data as get
    import numpy as np
    [t, x] = get.data('PDS1_2', shot, tree='east_1', timerange=timerange)
    
    background = np.mean(x[0:100])
    x = background-x
    x = 4e-4*4.82e20*x

    return t,x
示例#5
0
def data2ml(shot):

    Ip = get.data('ipm', shot)
    ne = get.data('dfsdev2', shot, 'pcs_east')
    [t, gauge3] = get.data('JHF1', shot)
    gauge3 = gauge3 * 4e5
    [t, gauge2] = get.data('PJS204', shot)
    gauge2 = gauge2 * 4e5
    back2 = np.mean(gauge2[0:10000])
    back3 = np.mean(gauge3[0:10000])
    gauge3 = (back3 - gauge3)
    gauge3[gauge3 < 1e4] = 0
    gauge3 = gauge3 * V * Pam2P
    gauge2 = (back2 - gauge2)
    gauge2[gauge2 < 1e4] = 0
    gauge2 = gauge2 * V * Pam2P

    totalP_smbi = (t, gauge2 + gauge3)

    [t, jhg1] = get.data('jhg1', shot)
    jhg1 = (jhg1 - 1) * 2.5e4
    back = np.mean(jhg1[0:10000])
    jhg1 = back - jhg1
    jhg1[jhg1 < 3e3] = 0
    jhg1 = jhg1 * V_jhg1 * Pam2P

    [t, dhg1] = get.data('dhg1', shot)
    dhg1 = (dhg1 - 1) * 2.5e4
    back = np.mean(dhg1[0:10000])
    dhg1 = back - dhg1
    dhg1[dhg1 < 3e3] = 0
    dhg1 = dhg1 * V_jhg1 * Pam2P

    totalP_gaspuff = (t, jhg1 + dhg1)

    f = h5py.File('/home/ASIPP/caobin/data/' + str(shot) + '.h5', 'w')
    f.create_dataset('density', data=ne)
    f.create_dataset('current', data=Ip)
    f.create_dataset('SMBI injected particles', data=totalP_smbi)
    f.create_dataset('Gas puffing injected particles', data=totalP_gaspuff)
    f.close()
示例#6
0
def plot_data():

    plt.figure(figsize=(9, 12))
    plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
    plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内

    [
        shot, signals1, trees1, labels1, zooms1, signals2, trees2, labels2,
        zooms2, signals3, trees3, labels3, zooms3, units, begin, end,
        low_filter, up_filter
    ] = get_input()

    plt.title(str(shot))

    # signals = list(reversed(signals))
    # print(processes)
    # print(parameters)

    i = 0
    colors = ['b', 'r', 'g']
    n = len(signals1)

    # ax = [0]
    # fig=plt.figure()
    for signal in signals1:
        tree = trees1[i]
        slabel = labels1[i]
        zoom = zooms1[i]
        signal2 = signals2[i]
        tree2 = trees2[i]
        slabel2 = labels2[i]
        zoom2 = zooms2[i]
        signal3 = signals3[i]
        tree3 = trees3[i]
        slabel3 = labels3[i]
        zoom3 = zooms3[i]
        unit = units[i]

        i = i + 1

        color = colors[0]
        # print(signal)

        [t, y] = get.data(signal,
                          shot,
                          tree=tree,
                          timerange=[begin, end],
                          zoom=zoom)

        # if shot == 98346:
        #     temp = np.array(t)
        #     temp = temp-7
        #     t = temp

        # if shot == 98351:
        #     temp =np.array(t)
        #     temp = temp-5.5
        #     t = temp

        # index = np.where((t>=begin)&(t<=end))
        # t = t[index]
        # y = y[index]

        if up_filter != 0:
            fs = 100 / (t[100] - t[0])
            fs = int(fs)
            if low_filter == 0:
                y = filter.high_pass(y, up_filter, fs)
            elif up_filter >= 0.5 * fs:
                y = filter.low_pass(y, low_filter, fs)
            else:
                y = filter.band_stop(y, low_filter, up_filter, fs)

        if i == 1:

            plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
            plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内
            ax1 = plt.subplot(n, 1, i)

            plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
            plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内
            plt.tick_params(top='on',
                            bottom='on',
                            left='on',
                            right='on',
                            labelleft='on',
                            direction='in')
            # if (n-i)&1:
            #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
            #     ax1.yaxis.set_label_position("right")
            # else:
            #     plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='off',labelleft='on',labelright='off')
            if n == 1:
                plt.tick_params(top='on',
                                bottom='on',
                                left='on',
                                right='on',
                                labelbottom='on',
                                labelleft='on',
                                direction='in')
            plt.subplots_adjust(wspace=0, hspace=0.03 * n)
            ax1.ticklabel_format(style='sci', scilimits=(-1, 2), axis='y')
            if unit != '0':
                plt.ylabel(unit)
            plt.xlim([begin, end])

            ax1.plot(t, y, color=color, label=slabel)

            if signal2 != '0':
                print(signal2)
                [t2, y2] = get.data(signal2,
                                    shot,
                                    tree=tree2,
                                    timerange=[begin, end],
                                    zoom=zoom2)
                ax1.plot(t2, y2, color=colors[1], label=slabel2)
            if signal3 != '0':
                [t3, y3] = get.data(signal3,
                                    shot,
                                    tree=tree3,
                                    timerange=[begin, end],
                                    zoom=zoom3)
                ax1.plot(t3, y3, color=colors[2], label=slabel3)

            ax1.legend()

        elif i == n:

            ax2 = plt.subplot(n, 1, i, sharex=ax1)

            plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
            plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内

            plt.tick_params(top='on',
                            bottom='on',
                            left='on',
                            right='on',
                            labelbottom='on',
                            labelleft='on',
                            direction='in')

            plt.subplots_adjust(wspace=0, hspace=0.03 * n)
            ax2.ticklabel_format(style='sci', scilimits=(-1, 2), axis='y')
            if unit != '0':
                plt.ylabel(unit)
            plt.xlabel('time (s)')
            plt.xlim([begin, end])
            ax1 = ax2

            ax1.plot(t, y, color=color, label=slabel)
            if signal2 != '0':
                [t2, y2] = get.data(signal2,
                                    shot,
                                    tree=tree2,
                                    timerange=[begin, end],
                                    zoom=zoom2)
                ax1.plot(t2, y2, color=colors[1], label=slabel2)
            if signal3 != '0':
                [t3, y3] = get.data(signal3,
                                    shot,
                                    tree=tree3,
                                    timerange=[begin, end],
                                    zoom=zoom3)
                ax1.plot(t3, y3, color=colors[2], label=slabel3)
            ax1.legend()

            # plt.tick_params(labeltop='off',labelbottom='off',labelleft='off',labelright='off')

        # elif i == n:
        #     ax2 = plt.subplot(n, 1, i, sharex=ax1)
        #     ax2.plot(t, y, color=color, label=str(shot))
        #     plt.xlim([begin, end])
        #     ax2.legend()

        else:

            ax2 = plt.subplot(n, 1, i, sharex=ax1)

            plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
            plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内
            # if (n-i)&1:
            #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
            #     ax2.yaxis.set_label_position("right")
            # else:
            #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='on',labelright='off')
            plt.tick_params(top='on',
                            bottom='on',
                            left='on',
                            right='on',
                            labelleft='on',
                            direction='in')
            plt.subplots_adjust(wspace=0, hspace=0.03 * n)
            ax2.ticklabel_format(style='sci', scilimits=(-1, 2), axis='y')
            if unit != '0':
                plt.ylabel(unit)
            plt.xlim([begin, end])
            ax1 = ax2
            ax1.plot(t, y, color=color, label=slabel)
            if signal2 != '0':
                [t2, y2] = get.data(signal2,
                                    shot,
                                    tree=tree2,
                                    timerange=[begin, end],
                                    zoom=zoom2)
                ax1.plot(t2, y2, color=colors[1], label=slabel2)
            if signal3 != '0':
                [t3, y3] = get.data(signal3,
                                    shot,
                                    tree=tree3,
                                    timerange=[begin, end],
                                    zoom=zoom3)
                ax1.plot(t3, y3, color=colors[2], label=slabel3)
            ax1.legend()

            # if j == m:
            #     ax1 = ax2

        # if i==n:
        #     tmp.plot(t, y, color=color, label=str(shot))
        #     tmp.legend()
        #     # tmp.grid()
        #     plt.xlim([begin, end])
        #     ax[i].get_shared_x_axes().join(ax[i], ax[i-1])
        #     ax[i].set_xticklabels([])
        # elif i == 1:
        #     tmp.plot(t, y, color=color)
        #     # tmp.grid()
        #     plt.xlim([begin, end])
        # else:
        #     tmp.plot(t, y, color=color)
        #     tmp.grid()
        #     plt.xlim([begin, end])
        #     ax[i].get_shared_x_axes().join(ax[i], ax[i-1])
        #     ax[i].set_xticklabels([])

        # if i==1:
        #     tmp = 1.1*np.max(y)
        #     locationY
        #     locationX = begin+(end-begin)/6*j
        #     plt.text(locationX, locationY, str(shot), color=color, fontsize=12)

    # i = 0
    # n = len(signals2)

    # for signal in signals2:
    #     tree = trees2[i]
    #     slabel = labels2[i]

    #     i = i+1
    #     plt.subplot(n, 1, i)
    #     if signal != '0':

    #         color = colors[1]

    #         [t, y] = get.data(signal, shot, tree=tree, timerange=[begin, end], zoom=zoom)

    #             # if shot == 98346:
    #             #     temp = np.array(t)
    #             #     temp = temp-7
    #             #     t = temp

    #             # if shot == 98351:
    #             #     temp =np.array(t)
    #             #     temp = temp-5.5
    #             #     t = temp

    #             # index = np.where((t>=begin)&(t<=end))
    #             # t = t[index]
    #             # y = y[index]

    #         if up_filter != 0:
    #             fs = 100/(t[100]-t[0])
    #             fs = int(fs)
    #             if low_filter == 0:
    #                 y = filter.high_pass(y, up_filter, fs)
    #             elif up_filter >= 0.5*fs:
    #                 y = filter.low_pass(y, low_filter, fs)
    #             else:
    #                 y = filter.band_stop(y, low_filter, up_filter, fs)

    #         judge = signal[0:2]
    #         if judge == "G1":
    #             temp = np.array(y)
    #             temp = 10**(temp*1.667-9.333)
    #             y = list(temp)
    #         elif judge == "PA" or judge == "PJ":
    #             temp = np.array(y)
    #             temp = 2e3*temp
    #             y = list(temp)
    #         elif judge == "PP" or judge == "PD":
    #             temp = np.array(y)
    #             temp = 2e4*temp
    #             y = list(temp)

    #         if i == 1:

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
    #             ax1 = plt.subplot(n, 1, i)

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
    #             plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #                 # if (n-i)&1:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
    #                 #     ax1.yaxis.set_label_position("right")
    #                 # else:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #             if n == 1:
    #                 plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='on',labelleft='on',labelright='off')
    #             plt.subplots_adjust(wspace =0, hspace =0.03*n)
    #             ax1.ticklabel_format(style='sci', scilimits=(-1,2), axis='y')
    #             # plt.ylabel(slabel)
    #                 # plt.xlim([begin, end])

    #             ax1.plot(t, y, color=color, label=slabel)

    #             ax1.legend()

    #         elif i == n:

    #             ax2 = plt.subplot(n, 1, i, sharex=ax1)

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内

    #             plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='on',labelleft='on',labelright='off')

    #             plt.subplots_adjust(wspace =0, hspace =0.03*n)
    #             ax2.ticklabel_format(style='sci', scilimits=(-1,2), axis='y')
    #             # plt.ylabel(slabel)
    #             plt.xlabel('time (s)')
    #                 # plt.xlim([begin, end])
    #             ax1 = ax2

    #             ax1.plot(t, y, color=color, label=slabel)
    #             ax1.legend()

    #             # plt.tick_params(labeltop='off',labelbottom='off',labelleft='off',labelright='off')

    #         # elif i == n:
    #         #     ax2 = plt.subplot(n, 1, i, sharex=ax1)
    #         #     ax2.plot(t, y, color=color, label=str(shot))
    #         #     plt.xlim([begin, end])
    #         #     ax2.legend()

    #         else:

    #             ax2 = plt.subplot(n, 1, i, sharex=ax1)

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
    #                 # if (n-i)&1:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
    #                 #     ax2.yaxis.set_label_position("right")
    #                 # else:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #             plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #             plt.subplots_adjust(wspace =0, hspace =0.03*n)
    #             ax2.ticklabel_format(style='sci', scilimits=(-1,2), axis='y')
    #             # plt.ylabel(slabel)
    #                 # plt.xlim([begin, end])
    #             ax1 = ax2
    #             ax1.plot(t, y, color=color, label=slabel)
    #             ax1.legend()

    # i = 0
    # n = len(signals3)

    # for signal in signals3:
    #     tree = trees3[i]
    #     slabel = labels3[i]

    #     i = i+1
    #     plt.subplot(n, 1, i)
    #     if signal != '0':

    #         color = colors[2]

    #         [t, y] = get.data(signal, shot, tree=tree, timerange=[begin, end], zoom=zoom)

    #             # if shot == 98346:
    #             #     temp = np.array(t)
    #             #     temp = temp-7
    #             #     t = temp

    #             # if shot == 98351:
    #             #     temp =np.array(t)
    #             #     temp = temp-5.5
    #             #     t = temp

    #             # index = np.where((t>=begin)&(t<=end))
    #             # t = t[index]
    #             # y = y[index]

    #         if up_filter != 0:
    #             fs = 100/(t[100]-t[0])
    #             fs = int(fs)
    #             if low_filter == 0:
    #                 y = filter.high_pass(y, up_filter, fs)
    #             elif up_filter >= 0.5*fs:
    #                 y = filter.low_pass(y, low_filter, fs)
    #             else:
    #                 y = filter.band_stop(y, low_filter, up_filter, fs)

    #         judge = signal[0:2]
    #         if judge == "G1":
    #             temp = np.array(y)
    #             temp = 10**(temp*1.667-9.333)
    #             y = list(temp)
    #         elif judge == "PA" or judge == "PJ":
    #             temp = np.array(y)
    #             temp = 2e3*temp
    #             y = list(temp)
    #         elif judge == "PP" or judge == "PD":
    #             temp = np.array(y)
    #             temp = 2e4*temp
    #             y = list(temp)

    #         if i == 1:

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
    #             ax1 = plt.subplot(n, 1, i)

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
    #             plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #                 # if (n-i)&1:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
    #                 #     ax1.yaxis.set_label_position("right")
    #                 # else:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #             if n == 1:
    #                 plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='on',labelleft='on',labelright='off')
    #             plt.subplots_adjust(wspace =0, hspace =0.03*n)
    #             ax1.ticklabel_format(style='sci', scilimits=(-1,2), axis='y')
    #             # plt.ylabel(slabel)
    #                 # plt.xlim([begin, end])

    #             ax1.plot(t, y, color=color, label=slabel)

    #             ax1.legend()

    #         elif i == n:

    #             ax2 = plt.subplot(n, 1, i, sharex=ax1)

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内

    #             plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='on',labelleft='on',labelright='off')

    #             plt.subplots_adjust(wspace =0, hspace =0.03*n)
    #             ax2.ticklabel_format(style='sci', scilimits=(-1,2), axis='y')
    #             # plt.ylabel(slabel)
    #             plt.xlabel('time (s)')
    #                 # plt.xlim([begin, end])
    #             ax1 = ax2

    #             ax1.plot(t, y, color=color, label=slabel)
    #             ax1.legend()

    #             # plt.tick_params(labeltop='off',labelbottom='off',labelleft='off',labelright='off')

    #         # elif i == n:
    #         #     ax2 = plt.subplot(n, 1, i, sharex=ax1)
    #         #     ax2.plot(t, y, color=color, label=str(shot))
    #         #     plt.xlim([begin, end])
    #         #     ax2.legend()

    #         else:

    #             ax2 = plt.subplot(n, 1, i, sharex=ax1)

    #             plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
    #             plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
    #                 # if (n-i)&1:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
    #                 #     ax2.yaxis.set_label_position("right")
    #                 # else:
    #                 #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #             plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='on',labelright='off')
    #             plt.subplots_adjust(wspace =0, hspace =0.03*n)
    #             ax2.ticklabel_format(style='sci', scilimits=(-1,2), axis='y')
    #             plt.ylabel(slabel)
    #                 # plt.xlim([begin, end])
    #             ax1 = ax2
    #             ax1.plot(t, y, color=color, label=slabel)
    #             ax1.legend()

    plt.show()
示例#7
0
def plot_data():

    plt.figure(figsize=(9, 12))

    [
        shots, signals, trees, begin, end, low_filter, up_filter, labels,
        processes, parameters
    ] = get_input()
    # signals = list(reversed(signals))
    # print(processes)
    # print(parameters)

    i = 0
    colors = ['b', 'r', 'g', 'k', 'y']
    n = len(signals)
    m = len(shots)
    # ax = [0]
    # fig=plt.figure()
    for signal in signals:
        tree = trees[i]
        slabel = labels[i]
        process = processes[i]
        parameter = parameters[i]

        i = i + 1
        j = 0
        for shot in shots:
            color = colors[j]
            # print(signal[: 3])
            if signal[:4] == 'get_':
                from importlib import import_module
                read = import_module(signal)
                [t, y] = read.read(shot, [begin, end])
            elif process == 'move':
                [t, y] = get.data(signal,
                                  shot,
                                  tree=tree,
                                  timerange=[begin, end],
                                  move=parameter[j])
            elif process == 'medfilt':
                [t, y] = get.data(signal,
                                  shot,
                                  tree=tree,
                                  timerange=[begin, end],
                                  medfilt=int(parameter[j]))
            elif process == 'smooth':
                parameter = list(map(int, parameter))
                [t, y] = get.data(signal,
                                  shot,
                                  tree=tree,
                                  timerange=[begin, end],
                                  smooth=parameter)
            elif process == 'zoom':
                [t, y] = get.data(signal,
                                  shot,
                                  tree=tree,
                                  timerange=[begin, end],
                                  zoom=parameter)
            elif process == 'log':
                [t, y] = get.data(signal,
                                  shot,
                                  tree=tree,
                                  timerange=[begin, end],
                                  log=parameter)
            else:
                [t, y] = get.data(signal,
                                  shot,
                                  tree=tree,
                                  timerange=[begin, end])

            j = j + 1

            # if shot == 98346:
            #     temp = np.array(t)
            #     temp = temp-7
            #     t = temp

            # if shot == 98351:
            #     temp =np.array(t)
            #     temp = temp-5.5
            #     t = temp

            # index = np.where((t>=begin)&(t<=end))
            # t = t[index]
            # y = y[index]

            if up_filter != 0:
                fs = 100 / (t[100] - t[0])
                fs = int(fs)
                if low_filter == 0:
                    y = filter.high_pass(y, up_filter, fs)
                elif up_filter >= 0.5 * fs:
                    y = filter.low_pass(y, low_filter, fs)
                else:
                    y = filter.band_stop(y, low_filter, up_filter, fs)

            if i == 1:
                if j == 1:
                    plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
                    plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内
                    ax1 = plt.subplot(n, 1, i)

                    plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
                    plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内
                    plt.tick_params(top='on',
                                    bottom='on',
                                    left='on',
                                    right='on',
                                    labelleft='on',
                                    direction='in')
                    # if (n-i)&1:
                    #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
                    #     ax1.yaxis.set_label_position("right")
                    # else:
                    #     plt.tick_params(top='on',bottom='on',left='on',right='on', labeltop='off',labelbottom='off',labelleft='on',labelright='off')
                    if n == 1:
                        plt.tick_params(top='on',
                                        bottom='on',
                                        left='on',
                                        right='on',
                                        labelbottom='on',
                                        labelleft='on',
                                        direction='in')

                    plt.subplots_adjust(wspace=0, hspace=0.03 * n)
                    ax1.ticklabel_format(style='sci',
                                         scilimits=(-1, 2),
                                         axis='y')
                    plt.ylabel(slabel)
                    # plt.xlim([begin, end])

                ax1.plot(t, y, color=color, label=str(shot))

                ax1.legend()

            elif i == n:
                if j == 1:
                    ax2 = plt.subplot(n, 1, i, sharex=ax1)

                    plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
                    plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内

                    plt.tick_params(top='on',
                                    bottom='on',
                                    left='on',
                                    right='on',
                                    labelbottom='on',
                                    labelleft='on',
                                    direction='in')

                    plt.subplots_adjust(wspace=0, hspace=0.03 * n)
                    ax2.ticklabel_format(style='sci',
                                         scilimits=(-1, 2),
                                         axis='y')
                    plt.ylabel(slabel)
                    plt.xlabel('time (s)')
                    # plt.xlim([begin, end])
                    ax1 = ax2

                ax1.plot(t, y, color=color)

                # plt.tick_params(labeltop='off',labelbottom='off',labelleft='off',labelright='off')

            # elif i == n:
            #     ax2 = plt.subplot(n, 1, i, sharex=ax1)
            #     ax2.plot(t, y, color=color, label=str(shot))
            #     plt.xlim([begin, end])
            #     ax2.legend()

            else:
                if j == 1:
                    ax2 = plt.subplot(n, 1, i, sharex=ax1)

                    plt.rcParams['xtick.direction'] = 'in'  #将x周的刻度线方向设置向内
                    plt.rcParams['ytick.direction'] = 'in'  #将y轴的刻度方向设置向内
                    # if (n-i)&1:
                    #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='off',labelright='on')
                    #     ax2.yaxis.set_label_position("right")
                    # else:
                    #     plt.tick_params(top='on',bottom='on',left='on',right='on',labeltop='off',labelbottom='off',labelleft='on',labelright='off')
                    plt.tick_params(top='on',
                                    bottom='on',
                                    left='on',
                                    right='on',
                                    labelleft='on',
                                    direction='in')
                    plt.subplots_adjust(wspace=0, hspace=0.03 * n)
                    ax2.ticklabel_format(style='sci',
                                         scilimits=(-1, 2),
                                         axis='y')
                    plt.ylabel(slabel)
                    # plt.xlim([begin, end])
                    ax1 = ax2
                ax1.plot(t, y, color=color)

                # if j == m:
                #     ax1 = ax2

            # if i==n:
            #     tmp.plot(t, y, color=color, label=str(shot))
            #     tmp.legend()
            #     # tmp.grid()
            #     plt.xlim([begin, end])
            #     ax[i].get_shared_x_axes().join(ax[i], ax[i-1])
            #     ax[i].set_xticklabels([])
            # elif i == 1:
            #     tmp.plot(t, y, color=color)
            #     # tmp.grid()
            #     plt.xlim([begin, end])
            # else:
            #     tmp.plot(t, y, color=color)
            #     tmp.grid()
            #     plt.xlim([begin, end])
            #     ax[i].get_shared_x_axes().join(ax[i], ax[i-1])
            #     ax[i].set_xticklabels([])

            # if i==1:
            #     tmp = 1.1*np.max(y)
            #     locationY
            #     locationX = begin+(end-begin)/6*j
            #     plt.text(locationX, locationY, str(shot), color=color, fontsize=12)

    plt.show()
示例#8
0
    if fcut == "":
        fcut = 0
    else:
        fcut = float(fcut)
    vmin = input('Input the vmin: ')
    if vmin == "":
        vmin = 0
    else:
        vmin = float(vmin)
    vmax = input('Input the vmax: ')
    if vmax == "":
        vmax = 0
    else:
        vmax = float(vmax)

    [t, x] = get.data(signal, shot, tree=tree)
    index = np.where((t >= begin_time) & (t <= end_time))
    t = t[index]
    x = x[index]

    if method == 'stft':
        [tf, f, Zxx, vmin, vmax] = spec_stft(t, x, nfft, vmax)
    elif method == 'wavlet':
        wavename = input('Please input the wavename: ')
        if wavename == '':
            wavename = 'cgau8'
        [tf, f, Zxx, vmin, vmax] = spec_wavlet(t, x, nfft, wavename, vmax)
    if vmax == 0:
        vmax = np.percentile(Zxx, 95)
    else:
        vmax = np.percentile(Zxx, vmax)
示例#9
0
shot = input("input shot: ")
shot = int(shot)
begin = input('input the begin time: ')
if begin == '':
    begin = 0
else:
    begin = float(begin)
end = input('input the end time: ')
if end == "":
    end = 0
else:
    end = float(end)


[t, x] = get.data('Pxuv1', shot, tree='EAST_1')
index = np.where((t>=begin)&(t<=end))
tP = t[index]

Pxuv = np.zeros([64, len(tP)], dtype=float)
Pxuv[0, :] = x[index]

for i in range(1, 64):
    signal_name = 'Pxuv'
    signal_name = signal_name+str(i+1)
    x = get.data1(signal_name, shot, 'EAST_1' )
    Pxuv[i, :] = x[index]



[t, x] = get.data('Cxuv1V', shot, tree='EAST_1')
示例#10
0
def check(shot, whichone, small=1):
    Pam2P = 4.82e20
    kp = 4e5
    if small < -1:
        V = 2.0431e-4 + 3.78e-3
        if whichone > 3:
            V = 4e-4 + 3e-3
    else:
        V = 2.0431e-4
        if whichone > 3:
            V = 4e-4

    small = abs(small)
    if whichone == 3:
        signal_name = 'smbi3'
        if small == 1:
            gauge_name = 'PAS105'
            kp = 2e3
        elif small == 3:
            gauge_name = 'PAS103'
        else:
            gauge_name = 'JHF1'
    elif whichone == 2:
        signal_name = 'smbi2'
        if small == 1:
            gauge_name = 'PJS205'
            kp = 2e3
        elif small == 3:
            gauge_name = 'PJS203'
        else:
            gauge_name = 'PJS204'
    elif whichone == 4:
        V = 4e-4
        signal_name = 'smbi4'
        if small == 1:
            gauge_name = 'PDS1_2'
            kp = 2e4
        else:
            gauge_name = 'PDS1_3'
    elif whichone == 5:
        V = 4e-4
        signal_name = 'smbi5'
        if small == 1:
            gauge_name = 'PDS1_2'
            kp = 2e4
        else:
            gauge_name = 'PDS1_3'
    elif whichone == 6:
        V = 4e-4
        signal_name = 'smbi6'
        if small == 1:
            gauge_name = 'PPS1_2'
            kp = 2e4
        else:
            gauge_name = 'PPS1_3'
    elif whichone == 7:
        V = 4e-4
        signal_name = 'smbi7'
        if small == 1:
            gauge_name = 'PPS1_2'
            kp = 2e4
        else:
            gauge_name = 'PPS1_3'
    else:
        import sys
        sys.exit('SMBI No. error')

    [t, smbi] = get.data(signal_name, shot, tree='EAST')
    pressure = get.data1(gauge_name, shot, tree='EAST_1')
    pressure = kp * pressure

    if len(smbi) < 4.7e4:
        n = 0
        l = 0
        p = 0

    else:

        index = np.where(smbi > 3)
        l = len(index[0]) * 1e-4
        # temp = smbi[1 : ]-smbi[ : -1]
        # index = np.where(temp>3)
        # n = len(index[0])
        t = t[index]
        temp = t[1:] - t[:-1]
        index = np.where(temp > 7e-4)
        n = len(index[0]) + 1

        pressure = savgol_filter(pressure, 1001, 3)
        len_p = len(pressure)
        p = np.mean(pressure[100:1100]) - np.mean(
            pressure[int(len_p - 1e4):int(len_p - 1e4 + 100)])
        p = abs(p)
        if p < 1e2:
            p = 0
        else:
            p = p * V * Pam2P

    print(n)
    print(l)
    print(p)

    return n, l, p