Exemple #1
0
def shot_bmag_stdnorm(refPos, window, filt, max_probe_number=8):
    """ Outputs the tools.correlation norm array w.r.t shot. The norm is product of 
    the standard deviations of the two windowed and filtered bmag signals. """

    maxRange = tools.gen_max_probe_range(refPos,
                                         max_probe_number=max_probe_number)
    type(maxRange)
    normWFArray = np.zeros([maxRange, 25])
    posArray = [*range(refPos, 16, 2)]

    for posIndex, pos in enumerate(posArray):
        for shot in range(0, 25):

            Br_1, Bt_1, Bz_1, time = data03.load_data(refPos, shot)
            Br_2, Bt_2, Bz_2, time = data03.load_data(pos, shot)

            start_Dex = BMX.finding_Index_Time(time * 1e-6, window[0])
            end_Dex = BMX.finding_Index_Time(time * 1e-6, window[1])

            Bmag1 = np.sqrt(Br_1**2 + Bt_1**2 + Bz_1**2)
            Bmag2 = np.sqrt(Br_2**2 + Bt_2**2 + Bz_2**2)
            fBmag1 = tools.HPF(Bmag1, filt)
            fBmag2 = tools.HPF(Bmag2, filt)

            wfBmag1 = fBmag1[start_Dex:end_Dex]
            wfBmag2 = fBmag2[start_Dex:end_Dex]

            normWFBmag = np.sqrt(np.var(wfBmag1) * np.var(wfBmag2))

            normWFArray[posIndex, shot] = normWFBmag

    return normWFArray
Exemple #2
0
def single_shot_bmag_temporal_taylor_y_intercepts(refPos, shot, filt, window, norm='ref', window2=[0, 13]):
    wfMagCorr, tau = btc.gen_shot_pos_bmag_correlation(
        refPos=refPos, pos=refPos, shot=shot, filt=filt, window=window, norm=norm)
    separations = tof.get_tau_spatial(tau, shot)
    startDex = bmx.finding_Index_Time(separations*1e-6, window2[0])
    endDex = bmx.finding_Index_Time(separations*1e-6, window2[1])
    yTSArray, maxSeparationArray, uncertainty, _ = y_intercepts(
        wfMagCorr[startDex:endDex], separations[startDex:endDex])
    return yTSArray, maxSeparationArray, uncertainty
Exemple #3
0
def get_windowed_bmag(pos, shot, window):
    """ Output the windowed bmag and time arrays of {shot} at {pos}."""
    bmag, time = get_bmag(pos, shot)

    start_dex = BMX.finding_Index_Time(time * 1e-6, window[0])
    end_dex = BMX.finding_Index_Time(time * 1e-6, window[1])

    wbmag = bmag[start_dex:end_dex]
    time = time[start_dex:end_dex]

    return wbmag, time
Exemple #4
0
def single_shot_abs_bmag_temporal_taylor_y_intercepts(refPos, shot, filt, window, norm='ref', window2=[0, 13]):
    """ Outputs the y_intercept array from the temporal correlations of the absolute Bmag with respect
    to shot.
    """
    wfMagCorr, tau = btc.gen_shot_pos_bmag_correlation(
        refPos=refPos, pos=refPos, shot=shot, filt=filt, window=window, norm=norm)
    separations = tof.get_tau_spatial(tau, shot)
    startDex = bmx.finding_Index_Time(separations*1e-6, window2[0])
    endDex = bmx.finding_Index_Time(separations*1e-6, window2[1])
    yTSArray, maxSeparationArray, uncertainty, _ = y_intercepts(
        np.abs(wfMagCorr[startDex:endDex]), separations[startDex:endDex])
    return yTSArray, maxSeparationArray, uncertainty
Exemple #5
0
def compute_time_delay(refPos, pos, shot, window=[75, 150], norm='ref', normalized=False):
    """ Output the time delay corresponding to the maximum correlation.
    """
    magwCorr, tau = get_shot_correlation(
        refPos, pos, shot, window, norm, normalized)
    zeroDex = bmx.finding_Index_Time(tau*1e-6, -10)
    limitDex = bmx.finding_Index_Time(tau*1e-6, 10)

    magwCorr = magwCorr[zeroDex:limitDex]
    tau = tau[zeroDex:limitDex]
    maxIndex = np.where(magwCorr == np.max(magwCorr))[0][0]
    timeDelay = tau[maxIndex]

    return timeDelay
Exemple #6
0
def gen_shot_bmag_spatial_correlation(refPos,
                                      shot,
                                      filt=3e4,
                                      window=[75, 150],
                                      norm='ref'):

    normArray = norms.which_norm(norm, refPos, window, filt)

    def norm_value(norm, posIndex, shot):
        """ Wrapper function to make choosing the norm value easier"""
        if norm.lower() == 'ref':
            normValue = normArray[shot]
        else:
            normValue = normArray[posIndex, shot]

        return normValue

    magShotArray = np.asarray([])

    for pos2Index, pos2 in enumerate([*range(refPos, 16, 2)]):
        Br_1, Bt_1, Bz_1, time = data03.load_data(refPos, shot)
        Br_2, Bt_2, Bz_2, time = data03.load_data(pos2, shot)

        if (pos2 == refPos):
            start_Dex = BMX.finding_Index_Time(time * 1e-6, window[0])
            if (window[1] != 190):
                end_Dex = BMX.finding_Index_Time(time * 1e-6, window[1])
            else:
                end_Dex = -1

        Bmag1 = np.sqrt(Br_1**2 + Bt_1**2 + Bz_1**2)
        Bmag2 = np.sqrt(Br_2**2 + Bt_2**2 + Bz_2**2)

        Bmag1 = tools.HPF(Bmag1, filt)
        Bmag2 = tools.HPF(Bmag2, filt)

        time = time[start_Dex:end_Dex]

        Bmag1 = Bmag1[start_Dex:end_Dex]
        Bmag2 = Bmag2[start_Dex:end_Dex]

        corrMagHold, _ = tools.correlation(Bmag1, Bmag2, time, mode='valid')
        # corr_MagHold = np.abs(corr_MagHold)
        normValue = norm_value(norm=norm, posIndex=pos2Index, shot=shot)
        normCorrMagHold = corrMagHold / normValue

        magShotArray = np.append(magShotArray, normCorrMagHold)
    return magShotArray