def __init__(self, svd_data, sv_list, timebase, min_dphase=-np.pi, phase_pairs=None): # NOTE I'd prefer not to duplicate info here which is in svd_data - should be able to refer to that, once sqlalchemy is hooked in #self.topo_channels = svd_data.topo_channels self.channels = svd_data.channels #self.svs = sv_list if len(sv_list) == 1: self.a12 = 0 else: # this ratio was inverted accidentally at first self.a12 = svd_data.svs[sv_list[1]] / svd_data.svs[sv_list[0]] self._binary_svs = list2bin(sv_list) # peak frequency for fluctuation structure self.timebase = timebase self.freq, self.freq_elmt = peak_freq(svd_data.chronos[sv_list[0]], self.timebase) self.phase_pairs = phase_pairs self.t0 = timebase[0] # singular value filtered signals self.signal = np.dot( np.transpose(svd_data.topos[sv_list, :]), np.dot(np.diag(svd_data.svs.take(sv_list)), svd_data.chronos[sv_list, :])) # phase differences between nearest neighbour channels self.dphase = self._get_dphase(min_dphase=min_dphase) self.p = np.sum(svd_data.svs.take(sv_list)**2) / svd_data.E self.H = svd_data.H self.E = svd_data.E debug_(pyfusion.DEBUG, 4, key='FlucStruc') super(FlucStruc, self).__init__()
def __init__(self, svd_data, sv_list, timebase, min_dphase = -np.pi, phase_pairs = None): # NOTE I'd prefer not to duplicate info here which is in svd_data - should be able to refer to that, once sqlalchemy is hooked in #self.topo_channels = svd_data.topo_channels self.channels = svd_data.channels #self.svs = sv_list if len(sv_list) == 1: self.a12 = 0 else: # this ratio was inverted accidentally at first self.a12 = svd_data.svs[sv_list[1]]/svd_data.svs[sv_list[0]] self._binary_svs = list2bin(sv_list) # peak frequency for fluctuation structure self.timebase = timebase self.freq, self.freq_elmt = peak_freq(svd_data.chronos[sv_list[0]], self.timebase) self.phase_pairs = phase_pairs self.t0 = timebase[0] # singular value filtered signals self.signal = np.dot(np.transpose(svd_data.topos[sv_list,:]), np.dot(np.diag(svd_data.svs.take(sv_list)), svd_data.chronos[sv_list,:])) # phase differences between nearest neighbour channels self.dphase, self.fourier_values = self._get_dphase(min_dphase=min_dphase, get_fourier_value = 1) self.p = np.sum(svd_data.svs.take(sv_list)**2)/svd_data.E self.H = svd_data.H self.E = svd_data.E debug_(pyfusion.DEBUG, 4, key='FlucStruc') super(FlucStruc, self).__init__()
def test_peak_freq(self): timebase = Timebase(np.arange(0.0, 0.01, 1.e-6)) single_mode_signal = get_multimode_test_data( channels=get_n_channels(1), timebase=timebase, modes=[mode_3]) p_f, p_f_elmt = peak_freq(single_mode_signal.signal[0], single_mode_signal.timebase) # Check that we get mode_3 frequency of 27.0 kHz (to 1 decimal place). self.assertAlmostEqual(1.e-3 * p_f, 1.e-3 * mode_3['freq'], 1)
def test_peak_freq(self): timebase = Timebase(np.arange(0.0,0.01, 1.e-6)) single_mode_signal = get_multimode_test_data(channels=get_n_channels(1), timebase=timebase, modes = [mode_3]) p_f, p_f_elmt = peak_freq(single_mode_signal.signal[0], single_mode_signal.timebase) # Check that we get mode_3 frequency of 27.0 kHz (to 1 decimal place). self.assertAlmostEqual(1.e-3*p_f, 1.e-3*mode_3['freq'], 1)