コード例 #1
0
ファイル: test_vcalc.py プロジェクト: kwmsmith/kaw-analysis
def test_mult_by_k1():
    carr = np.zeros((32,16),dtype='F')+1.0+1.0j
    ck0 = vcalc.mult_by_k(carr, 0)
    assert np.allclose(carr, ck0)
    ck1 = vcalc.mult_by_k(carr, 1)
    kx0_line = (np.zeros((16,),dtype='F')+1.0+1.0j) * np.arange(16)
    assert np.allclose(kx0_line, ck1[0])
コード例 #2
0
ファイル: spectrum.py プロジェクト: kwmsmith/kaw-analysis
def plot_eng_spectra(cpsi, cvor, cden, npoints):
    import pylab as pl
    pl.ion()
    Ebk = vcalc.mult_by_k(cpsi * np.conj(cpsi), 2)
    Evk = vcalc.mult_by_k(cvor * np.conj(cvor), -2)
    Enk = cden * np.conj(cden)

    x,Eb_spect = get_spectrum(Ebk, npoints)
    x,Ev_spect = get_spectrum(Evk, npoints)
    x,En_spect = get_spectrum(Enk, npoints)

    pl.figure()
    pl.loglog(x, Eb_spect, 'ro-', label='magnetic')
    pl.loglog(x, Ev_spect, 'g^-', label='kinetic')
    pl.loglog(x, En_spect, 'b<-', label='internal')
    pl.legend()
コード例 #3
0
ファイル: spectrum.py プロジェクト: kwmsmith/kaw-analysis
def spectra_plot(cpsi, cvor, cden, rho_s2, npoints, name, title, exts=('.png', '.pdf')):
    import pylab as pl
    Ebk = vcalc.mult_by_k(cpsi * np.conj(cpsi), 2)
    Evk = vcalc.mult_by_k(cvor * np.conj(cvor), -2)
    Enk = rho_s2 * (cden * np.conj(cden))


    x, Bspec = get_spectrum(Ebk, npoints)
    x, Vspec = get_spectrum(Evk, npoints)
    x, Nspec = get_spectrum(Enk, npoints)

    pl.figure()
    pl.loglog(x, Bspec, 'ro-', label='magnetic')
    pl.loglog(x, Vspec, 'g^-', label='kinetic')
    pl.loglog(x, Nspec, 'b<-', label='internal')
    pl.xlabel('wavenumber (norm. units)')
    pl.ylabel('Spect. amp. (norm. units)')
    pl.title(title)
    pl.legend()
    for ext in exts:
        pl.savefig(name + ext)
コード例 #4
0
ファイル: test_vcalc.py プロジェクト: kwmsmith/kaw-analysis
def test_mult_by_k2():
    carr = np.zeros((32,16),dtype='F')+1.0+1.0j
    ck2 = vcalc.mult_by_k(carr, 2)
    kx_nxby2_line = (np.zeros((16,),dtype='F')+1.0+1.0j) * (np.arange(16)**2 + 16**2)
    assert np.allclose(kx_nxby2_line, ck2[16])