コード例 #1
0
ファイル: sph_harm_coeffs.py プロジェクト: SaulAryehKohn/capo
def test_recover_gs(Q,baselines,lms,n_sig=5):
    print lms[:,0].shape
    a = get_a_from_gsm(lms[:,0]) # this is the sky, i.e. the x in y=Qx+n 
    a.shape = (a.shape[0],1)
    print Q.shape
    print a.shape
    VV = n.array(n.matrix(Q)*n.matrix(a))+n.random.normal(loc=0.0,scale=n_sig,size=[Q.shape[0],1])*n.exp(2*n.pi*1j*n.random.rand())
    print a.shape
    print VV.shape
    ahat,covar = uf.general_lstsq_fit_with_err(a,VV,Q,(n_sig**2)*n.identity(Q.shape[0]),pseudo=True)
    print covar
    err = n.sqrt(n.array(covar)*n.array(n.identity(covar.shape[0])))
    print err.shape
    print "true      gs = {0}\nrecovered gs = {1}".format(a[0],ahat[0])
    print "Error = ",err
    return a[0], ahat[0], err[0,0]
コード例 #2
0
def test_regress_general_lstsq(baselines,coeffs,nparams,gs=1,n_sig=5,na=32,readFromFile=False):
    """
    This function tests the linear regression method of recovering the global 
    signal by generating a visibility VV with random normal noise of amplitude 
    n_sig and then performing a linear regression on VV and the coefficients 
    from get_coeffs(). 
    """
    print coeffs.shape
    VV = gs*coeffs + n.random.normal(loc=0.0,scale=n_sig,size=[len(coeffs),1])*n.exp(2*n.pi*1j*n.random.rand())
    print VV.shape
    #                                           xdata,ydata,noiseCovar,nparam)
    params,covar = uf.general_lstsq_fit_with_err(coeffs,VV,(n_sig**2)*n.identity(len(coeffs)),2)
    gs_recov = params[1]
    print 'covar shape',covar.shape
    err = n.sqrt(n.array(covar)*n.array(n.identity(covar.shape[0])))
    print "true gs = {0}\trecovered gs = {1}".format(gs,gs_recov[0])
    print "Error = ",err
    return gs_recov[0], err[1,1]
コード例 #3
0
ファイル: global_sig.py プロジェクト: mkolopanis/capo
def test_regress_general_lstsq(baselines, coeffs, nparams, gs=1, n_sig=5, na=32, readFromFile=False):
    """
    This function tests the linear regression method of recovering the global 
    signal by generating a visibility VV with random normal noise of amplitude 
    n_sig and then performing a linear regression on VV and the coefficients 
    from get_coeffs(). 
    """
    print coeffs.shape
    VV = gs * coeffs + n.random.normal(loc=0.0, scale=n_sig, size=[len(coeffs), 1]) * n.exp(
        2 * n.pi * 1j * n.random.rand()
    )
    print VV.shape
    #                                           xdata,ydata,noiseCovar,nparam)
    params, covar = uf.general_lstsq_fit_with_err(coeffs, VV, (n_sig ** 2) * n.identity(len(coeffs)), 2)
    gs_recov = params[1]
    print "covar shape", covar.shape
    err = n.sqrt(n.array(covar) * n.array(n.identity(covar.shape[0])))
    print "true gs = {0}\trecovered gs = {1}".format(gs, gs_recov[0])
    print "Error = ", err
    return gs_recov[0], err[1, 1]
コード例 #4
0
ファイル: sph_harm_coeffs.py プロジェクト: nkern/capo
def test_recover_gs(Q, baselines, lms, n_sig=5):
    print lms[:, 0].shape
    a = get_a_from_gsm(lms[:, 0])  # this is the sky, i.e. the x in y=Qx+n
    a.shape = (a.shape[0], 1)
    print Q.shape
    print a.shape
    VV = n.array(n.matrix(Q) * n.matrix(a)) + n.random.normal(
        loc=0.0, scale=n_sig, size=[Q.shape[0], 1]) * n.exp(
            2 * n.pi * 1j * n.random.rand())
    print a.shape
    print VV.shape
    ahat, covar = uf.general_lstsq_fit_with_err(a,
                                                VV,
                                                Q, (n_sig**2) *
                                                n.identity(Q.shape[0]),
                                                pseudo=True)
    print covar
    err = n.sqrt(n.array(covar) * n.array(n.identity(covar.shape[0])))
    print err.shape
    print "true      gs = {0}\nrecovered gs = {1}".format(a[0], ahat[0])
    print "Error = ", err
    return a[0], ahat[0], err[0, 0]