Exemple #1
0
def gen_RMdly_mat(nu, spec, window='hamming'):
    N = len(nu)
    RMs = gen_rm_samples(nu)
    wgt = dsp.gen_window(N, window)
    mat = np.zeros((N, N), dtype=np.complex)
    for i, RM in enumerate(RMs):
        mat_ift = spec * np.conjugate(gen_rm_spec(nu, RM))
        mat[:, i] = np.fft.fftshift(np.fft.ifft(mat_ift * wgt))
    return mat
Exemple #2
0
def iRMTmat(nu, window='hamming'):
    N = len(nu)
    dnu = nu[1] - nu[0]
    W = np.indices(np.array((N, N)))
    RMs = gen_rm_samples(nu)
    L2 = better_guess_l2(nu)
    if window == 'none': wgt = np.ones(N)
    else: wgt = dsp.gen_window(N, window)
    L0 = l0(nu)
    W = np.exp(2.j * RMs[W[0]] * (L2[W[1]] - L0))
    W *= (RMs[-1] - RMs[0]) / (np.pi * N)
    return W.T
Exemple #3
0
def RMTmat(nu, window='hamming'):
    N = len(nu)
    dnu = nu[1] - nu[0]
    W = np.indices(np.array((N, N)))
    RMs = gen_rm_samples(nu)
    L2 = better_guess_l2(nu)
    L0 = l0(nu)
    if window == 'none': wgt = np.ones(N)
    else: wgt = dsp.gen_window(N, window)
    W = np.exp(-2.j * RMs[W[1]] *
               (L2[W[0]] - L0)) * Lam2Measure(nu[W[0]], dnu) * wgt[W[0]]
    return RMs, W.T
Exemple #4
0
def gen_RMtau_ker(nu, inv=None, window='hamming'):
    N = len(nu)
    rms = gen_rm_samples(nu)
    wgt = dsp.gen_window(N, window)
    mat = np.zeros((N, N**2), dtype=np.complex)
    dly = np.fft.fftshift(np.fft.fftfreq(N, nu[1] - nu[0]))
    RM, DLY = np.zeros((N, N)), np.zeros((N, N))
    for i in range(N):
        RM[:, i] = rms[i]
        DLY[i, :] = dly[i]
    RM = RM.flatten()
    DLY = DLY.flatten()

    for i in range(N**2):
        mat[:, i] = np.conj(gen_rm_spec(nu, RM[i])) * np.exp(
            -2.j * np.pi * DLY[i] * nu)
    if not inv is None: return np.conj(mat)
    else: return mat / float(N)
Exemple #5
0
from aipy import dsp
import RotMeasTools as RMT
from pylab import *
import pspec

c = 0.3 #m/ns
twopi = 2.*np.pi

N = 512
fq = np.linspace(0.1,0.2,N)
L2 = RMT.better_guess_l2(fq)

Rms,W = RMT.RMTmat(fq)
plot_me = np.zeros((N,N),dtype=np.complex)
delays = np.fft.fftshift(np.fft.fftfreq(N,fq[1]-fq[0]))
wgt = dsp.gen_window(N,window='blackman-harris')
Rm0 = 5.
for i,Rm in enumerate(Rms): 
    QiUi = RMT.gen_rm_spec(fq,Rm+Rm0)
    plot_me[:,i] = np.fft.fftshift(np.fft.ifft(QiUi*wgt))
    
plot_me1 = plot_me*np.conjugate(plot_me)
plot_me1 = plot_me1.real
plot_me1 /= np.max(plot_me1)

figure(0)
imshow(10.*np.log10(plot_me1),aspect='auto',interpolation='nearest',
    extent=[delays[0],delays[-1],Rms[-1],Rms[0]],
    vmax=0,vmin=-100)
ylabel('Rotation Measure [$m^{-2}$]')
xlabel('Delay [ns]')
Exemple #6
0
 def test_kaiser2(self):
     win = dsp.gen_window(1024, 'kaiser2')
     self.assertAlmostEqual(win[0], 0.01147993)
     self.assertAlmostEqual(win[1], 0.01192681)
     self.assertAlmostEqual(win[2], 0.01238142)