def gen_bmag_temporal_correlation(refPos, filt, window, norm='ref'): """ Outputs the spatial correlation array based on the bmag data. """ 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 shot in range(0, 25): Bmag1, time = tools.get_windowed_filtered_bmag(refPos, shot, window, filt) corr_MagHold, tau = tools.correlation(Bmag1, Bmag1, time, mode='same') corr_MagHold = np.abs(corr_MagHold) normValue = norm_value(norm, 0, shot) if (shot == 0): corr_Mag = corr_MagHold / (25 * normValue) else: corr_Mag += corr_MagHold / (25 * normValue) magShotArray = np.append(magShotArray, corr_Mag) return magShotArray, tau
def gen_shot_pos_bmag_correlation(refPos, pos, shot, filt, window, norm='ref', normalized=True): """ This function outputs the bmag correlation of shot at pos and the corresponding time delay.""" 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 bmagRef, time = tools.get_windowed_filtered_bmag(pos=refPos, shot=shot, window=window, filt=filt) bmagPos, _ = tools.get_windowed_filtered_bmag(pos, shot, window, filt) magCorr, tau = tools.correlation(bmagRef, bmagPos, time) if normalized: posIndex = tools.get_pos_index(refPos, pos) normMagCorr = magCorr / norm_value(norm, posIndex, shot) else: normMagCorr = magCorr return normMagCorr, tau
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