Exemple #1
0
     #  of a component with 1" FWHM - note signal_fwhm here
     #  is in radians
     parvec[0] = master_norm * (signal_fwhm[i] * 206264.8)**2
 # set default deltas for calculating the numerical derivative
 #  default to 1% for nonzero params; 0.1xsynth beam for positions;
 #  and 0.5 deg for the axis angle-
 default_par_delta = sp.copy(parvec * 0.01)
 default_par_delta[1] = cfg_resolution[j] * 0.1
 default_par_delta[2] = cfg_resolution[j] * 0.1
 default_par_delta[5] = 0.5
 # put telescope gain scaling in to the errors (which are in mJy)-
 this_err = typical_err(beamfwhm[j] / 2.91e-4)**2
 f = tv.make_fisher_mx(bl,
                       this_err,
                       default_par_delta,
                       beamfwhm[j],
                       parvec,
                       brute_force=False,
                       flux_norm=True)
 # use SVD pseudo inverse instead of direct
 #  inverse for stability
 #finv=spla.inv(f)
 finv = spla.pinv(f)
 norm_snr[i] = parvec[0] / (finv[0, 0])**0.5
 # save position error = average 1D error-
 pos_err0[i] = (finv[1, 1])**0.5
 pos_err1[i] = (finv[2, 2])**0.5
 fwhm_snr[i] = parvec[3] / (finv[3, 3])**0.5
 fwhm2_snr[i] = parvec[4] / (finv[4, 4])**0.5
 angle_err[i] = (finv[5, 5])**0.5
 print cfg_files[j], i, norm_snr[i], fwhm_snr[i], pos_err[i]
Exemple #2
0
def calc_one_fisher(this_info):
    '''
    routine called by worker bee function to do all the heavy lifting.
    '''
    lam = this_info[0]
    cfg_file = this_info[1]
    cfg_resolution = this_info[2]
    min_resolution = this_info[3]
    cfg_las = this_info[4]
    beamfwhm = this_info[5]
    master_norm = this_info[6]
    typical_err = this_info[7]
    n_samps = this_info[8]
    do_constSurfBright = this_info[9]

    if do_constSurfBright:
        print "SURFACE BRIGHTNESS of components held fixed"
    else:
        print "TOTAL FLUX density of components held fixed"

    deltax = beamfwhm * 0.01
    parvec = sp.array(
        [master_norm, deltax, deltax, cfg_resolution, cfg_resolution, 10.0])
    # param order is - norm,l0,m0,fwhm_1,fwhm_2,axis_angle - last is deg others rad.
    # initialize variables
    norm_snr = sp.zeros(n_samps)
    fwhm_snr = sp.zeros(n_samps)
    fwhm2_snr = sp.zeros(n_samps)
    pos_err0 = sp.zeros(n_samps)
    pos_err1 = sp.zeros(n_samps)
    angle_err = sp.zeros(n_samps)
    # go from resolution/5 to LAS*2
    #min_scale=cfg_resolution*0.1
    min_scale = min_resolution * 0.05
    max_scale = cfg_las * 2.5
    # compute range of models to consider-
    step_size = (max_scale - min_scale) / n_samps
    signal_fwhm = (sp.arange(n_samps) * step_size + step_size)
    # this will return the uv baselines in inverse radians-
    bl = tv.getbaselines(cfg_file, lam=lam)
    # loop over gaussian component sizes-
    print '***', step_size, max_scale, min_scale, cfg_file
    for i in range(n_samps):
        parvec[3] = signal_fwhm[i] * 1.05
        parvec[4] = signal_fwhm[i] / 1.05
        if do_constSurfBright:
            # normalize total flux so that master_norm is the flux in mJy
            #  of a component with 1" FWHM - note signal_fwhm here
            #  is in radians
            parvec[0] = master_norm * (signal_fwhm[i] * 206264.8)**2
        # set default deltas for calculating the numerical derivative
        #  default to 1% for nonzero params; 0.1xsynth beam for positions;
        #  and 0.5 deg for the axis angle-
        default_par_delta = sp.copy(parvec * 0.01)
        default_par_delta[1] = cfg_resolution * 0.1
        default_par_delta[2] = cfg_resolution * 0.1
        default_par_delta[5] = 0.5
        # put telescope gain scaling in to the errors (which are in mJy)-
        this_err = typical_err * (beamfwhm / 2.91e-4)**2
        f = tv.make_fisher_mx(bl,
                              this_err,
                              default_par_delta,
                              beamfwhm,
                              parvec,
                              brute_force=False,
                              flux_norm=True)
        # use SVD pseudo inverse instead of direct
        #  inverse for stability
        #finv=spla.inv(f)
        finv = spla.pinv(f)
        norm_snr[i] = parvec[0] / (finv[0, 0])**0.5
        # save position error = average 1D error-
        pos_err0[i] = (finv[1, 1])**0.5
        pos_err1[i] = (finv[2, 2])**0.5
        fwhm_snr[i] = parvec[3] / (finv[3, 3])**0.5
        fwhm2_snr[i] = parvec[4] / (finv[4, 4])**0.5
        angle_err[i] = (finv[5, 5])**0.5
        print cfg_file, i, norm_snr[i], fwhm_snr[i], pos_err0[i]
        # save fisher mx i here
    # save (signal_fwhm,norm_snr, fwhm_snr) here
    if do_constSurfBright:
        mystring = '-constSB'
    else:
        mystring = '-constFlux'
    fh = open(cfg_file + mystring + '.parErrs.txt', 'w')
    for i in range(n_samps):
        outstr = '{0:.3e} {1:.3e} {2:.3e} {3:.4e} {3:.4e} {4:.3e} {4:.3e} {4:.3e}'.format(
            signal_fwhm[i], beamfwhm, norm_snr[i], fwhm_snr[i], fwhm2_snr[i],
            angle_err[i], pos_err0[i], pos_err1[i])
        fh.write(outstr + '\n')
    fh.close()
def calc_one_fisher(this_info):
    '''
    routine called by worker bee function to do all the heavy lifting.
     calculates many fisher matrices for a given array configuration
     (one fishMx for each angular scale to be assessed)
    '''
    lam=this_info[0]
    cfg_file=this_info[1]
    cfg_resolution=this_info[2]
    min_resolution=this_info[3]
    cfg_las=this_info[4]
    beamfwhm=this_info[5]
    master_norm=this_info[6]
    typical_err=this_info[7]
    n_samps=this_info[8]
    do_constSurfBright=this_info[9]
    mytag=this_info[10]

    if do_constSurfBright:
        print "SURFACE BRIGHTNESS of components held fixed"
    else:
        print "TOTAL FLUX density of components held fixed"

    parvec=sp.array([master_norm,cfg_resolution,cfg_resolution,cfg_resolution,cfg_resolution,25.0*sp.pi/180.0])
    # param order is - norm,l0,m0,fwhm_1,fwhm_2,axis_angle - last is deg others rad.
    # initialize variables
    norm_snr=sp.zeros(n_samps)
    fwhm_snr=sp.zeros(n_samps)
    fwhm2_snr=sp.zeros(n_samps)
    pos_err0=sp.zeros(n_samps)
    pos_err1=sp.zeros(n_samps)
    angle_err=sp.zeros(n_samps)
    nzeros=sp.zeros(n_samps,dtype=sp.int_)
    # go from resolution/5 to LAS*2
    #min_scale=cfg_resolution*0.1
    min_scale=min_resolution*0.05
    max_scale=cfg_las*2.5
    # compute range of models to consider-
    step_size=(max_scale-min_scale)/n_samps
    signal_fwhm= (sp.arange(n_samps)*step_size+step_size) 
    # this will return the uv baselines in inverse radians-
    bl=tv.getbaselines(cfg_file,lam=lam)
    # loop over gaussian component sizes-
    print '***',step_size,max_scale,min_scale,cfg_file
    if do_constSurfBright:
        mystring='-constSB_2'
    else:
        mystring='-constFlux_2'
    test_delta = tv.create_delta_vec(parvec,parvec)
    print " *** Representative deltas: {}".format(test_delta)
    # save (signal_fwhm,norm_snr, fwhm_snr) here
    fh=open(cfg_file+mytag+mystring+'.parErrs.txt','w',1)
    for i in range(n_samps):
        parvec[3] = signal_fwhm[i] * 1.05
        parvec[4] = signal_fwhm[i] / 1.05
        if do_constSurfBright:
            # normalize total flux so that master_norm is the flux in mJy
            #  of a component with 1" FWHM - note signal_fwhm here
            #  is in radians
            parvec[0] = master_norm * (signal_fwhm[i] * 206264.8)**2 
        default_scales = sp.array([parvec[0],cfg_resolution,cfg_resolution,cfg_resolution,cfg_resolution,0.35])
        default_par_delta = tv.create_delta_vec(parvec,default_scales)
        # put telescope gain scaling in to the errors (which are in mJy)-
        this_err = typical_err * (beamfwhm/2.91e-4)**2 
        f=tv.make_fisher_mx(bl,this_err,default_par_delta,beamfwhm,parvec,brute_force=False,flux_norm=True)
        # use SVD pseudo inverse instead of direct
        #  inverse for stability
        #finv=spla.inv(f)
        finv=spla.pinv(f)
	norm_snr[i]= parvec[0] / (finv[0,0])**0.5
        # save position error = average 1D error-
        pos_err0[i]= (finv[1,1])**0.5 
        pos_err1[i] = (finv[2,2])**0.5
	fwhm_snr[i]= parvec[3] / (finv[3,3])**0.5
        fwhm2_snr[i] = parvec[4]/ (finv[4,4])**0.5
        angle_err[i]= (finv[5,5])**0.5
        diags = sp.diag(finv)
        nzeros[i]=diags[diags==0.0].size
        dumpfile='raw_fish/f-'+cfg_file+'-'+mytag+mystring+'{}'.format(i)+'.pkl'
        pickle.dump(f,open(dumpfile,"wb"))
        dumpfile='raw_fish/finv-'+cfg_file+'-'+mytag+mystring+'{}'.format(i)+'.pkl'
        pickle.dump(finv,open(dumpfile,"wb"))
        outstr='{0:d} {1:.5e} {2:.5e} {3:.5e} {4:.5e} {5:.5e} {6:.5e} {7:.5e} {8:.5e} {9:d}'.format(i,signal_fwhm[i],beamfwhm,norm_snr[i],fwhm_snr[i],fwhm2_snr[i],angle_err[i],pos_err0[i],pos_err1[i],nzeros[i])
        fh.write(outstr+'\n')        
        print cfg_file,outstr
    fh.close()
    signal_fwhm= (sp.arange(n_samps)*step_size+step_size) 
    # this will return the uv baselines in inverse radians-
    bl=tv.getbaselines(cfg_files[j],lam=lam)
    # loop over gaussian component sizes-
    print '***',j,step_size,max_scale,min_scale,cfg_files[j]
    for i in range(n_samps):
        parvec[3] = signal_fwhm[i] 
        parvec[4] = signal_fwhm[i]
        # set default deltas for calculating the numerical derivative
        #  default to 1% for nonzero params; 0.1xsynth beam for positions;
        #  and 0.5 deg for the axis angle-
        default_par_delta=sp.copy(parvec*0.01)
        default_par_delta[1]=cfg_resolution[j]*0.1
        default_par_delta[2]=cfg_resolution[j]*0.1
        default_par_delta[5]=0.5
	f=tv.make_fisher_mx(bl,typical_err,default_par_delta,beamfwhm[j],parvec,brute_force=False,flux_norm=True)
	finv=spla.inv(f)
	norm_snr[i]= parvec[0] / (finv[0,0])**0.5
        # save position error = average 1D error-
        pos_err[i]= 0.5 * (finv[1,1]**0.5 + finv[2,2]**0.5)
	fwhm_snr[i]= parvec[3] / (finv[3,3])**0.5
        # save fisher mx i here
    # save (signal_fwhm,norm_snr, fwhm_snr) here
    mystring='-constFlux'
    fh=open(cfg_files[j]+mystring+'.parErrs.txt','w')
    for i in range(n_samps):
        outstr='{0:.3e} {1:.3e} {2:.3e} {3:.4e} {4:.3e}'.format(signal_fwhm[i],beamfwhm[j],norm_snr[i],fwhm_snr[i],pos_err[i])
        fh.write(outstr+'\n')
    fh.close()

Exemple #5
0
# beam fwhm in rad- (B3 alma) - 1' fwhm = 2.91e-4 radians fwhm
beamfwhm=2.91e-4
parvec=sp.array([0.01,0.0,0.0,2e-5,2e-5,0.0])
# param order is - norm,l0,m0,fwhm_1,fwhm_2,axis_angle
parvec += 1e-9

print tv.visval(beamfwhm,0,0,parvec[0],parvec[1],parvec[2],parvec[3],parvec[4],parvec[5],brute_force=False)
# this is a typical visibility value. set the error in make_fisher_mx to something of this order

signal_fwhm= (sp.arange(100)*0.02+0.02) * beamfwhm
norm_snr=sp.zeros(100)
fwhm_snr=sp.zeros(100)
for i in range(100):
	parvec[3] = signal_fwhm[i] 
	parvec[4] = signal_fwhm[i]
	f=tv.make_fisher_mx(bl,1e-12,0.01,beamfwhm,parvec,brute_force=False)
	finv=spla.inv(f)
	norm_snr[i]= parvec[0] / (finv[0,0])**0.5
	fwhm_snr[i]= parvec[3] / (finv[3,3])**0.5

pl.plot(signal_fwhm/beamfwhm,fwhm_snr)
pl.plot(signal_fwhm/beamfwhm,norm_snr,'-r')

##save comptued array 2 values for comparison-
#norm_snr_2=sp.copy(norm_snr)
#fwhm_snr_2=sp.copy(fwhm_snr)

# check the visibility values
#  integral of this should be pi*sigma_beam^2 = pi*(0.1/2.3548)^2
u=0
v=0
Exemple #6
0
                parvec[0],
                parvec[1],
                parvec[2],
                parvec[3],
                parvec[4],
                parvec[5],
                brute_force=False)
# this is a typical visibility value. set the error in make_fisher_mx to something of this order

signal_fwhm = (sp.arange(100) * 0.02 + 0.02) * beamfwhm
norm_snr = sp.zeros(100)
fwhm_snr = sp.zeros(100)
for i in range(100):
    parvec[3] = signal_fwhm[i]
    parvec[4] = signal_fwhm[i]
    f = tv.make_fisher_mx(bl, 1e-12, 0.01, beamfwhm, parvec, brute_force=False)
    finv = spla.inv(f)
    norm_snr[i] = parvec[0] / (finv[0, 0])**0.5
    fwhm_snr[i] = parvec[3] / (finv[3, 3])**0.5

pl.plot(signal_fwhm / beamfwhm, fwhm_snr)
pl.plot(signal_fwhm / beamfwhm, norm_snr, '-r')

##save comptued array 2 values for comparison-
#norm_snr_2=sp.copy(norm_snr)
#fwhm_snr_2=sp.copy(fwhm_snr)

# check the visibility values
#  integral of this should be pi*sigma_beam^2 = pi*(0.1/2.3548)^2
u = 0
v = 0
    bl=tv.getbaselines(cfg_files[j],lam=lam)
    # loop over gaussian component sizes-
    print '***',j,step_size,max_scale,min_scale,cfg_files[j]
    for i in range(n_samps):
	parvec[3] = signal_fwhm[i] 
	parvec[4] = signal_fwhm[i]
        # set default deltas for calculating the numerical derivative
        #  default to 1% for nonzero params; 0.1xsynth beam for positions;
        #  and 0.5 deg for the axis angle-
        default_par_delta=sp.copy(parvec*0.01)
        default_par_delta[1]=cfg_resolution[j]*0.1
        default_par_delta[2]=cfg_resolution[j]*0.1
        default_par_delta[5]=0.5
        if do_const_flux:
            parvec[0] = master_norm / (parvec[3]*parvec[4])
	f=tv.make_fisher_mx(bl,typical_err,default_par_delta,beamfwhm[j],parvec,brute_force=False)
	finv=spla.inv(f)
	norm_snr[i]= parvec[0] / (finv[0,0])**0.5
        # save position error = average 1D error-
        pos_err[i]= 0.5 * (finv[1,1]**0.5 + finv[2,2]**0.5)
	fwhm_snr[i]= parvec[3] / (finv[3,3])**0.5
        # save fisher mx i here
    # save (signal_fwhm,norm_snr, fwhm_snr) here
    if do_const_flux:
        mystring='-constFlux'
    else:
        mystring='-constSB'
    fh=open(cfg_files[j]+mystring+'.parErrs.txt','w')
    for i in range(n_samps):
        outstr='{0:.3e} {1:.3e} {2:.3e} {3:.4e} {4:.3e}'.format(signal_fwhm[i],beamfwhm[j],norm_snr[i],fwhm_snr[i],pos_err[i])
        fh.write(outstr+'\n')
def calc_one_fisher(this_info):
    '''
    routine called by worker bee function to do all the heavy lifting.
    '''
    lam=this_info[0]
    cfg_file=this_info[1]
    cfg_resolution=this_info[2]
    min_resolution=this_info[3]
    cfg_las=this_info[4]
    beamfwhm=this_info[5]
    master_norm=this_info[6]
    typical_err=this_info[7]
    n_samps=this_info[8]
    do_constSurfBright=this_info[9]

    if do_constSurfBright:
        print "SURFACE BRIGHTNESS of components held fixed"
    else:
        print "TOTAL FLUX density of components held fixed"

    deltax=beamfwhm * 0.01
    parvec=sp.array([master_norm,deltax,deltax,cfg_resolution,cfg_resolution,10.0])
    # param order is - norm,l0,m0,fwhm_1,fwhm_2,axis_angle - last is deg others rad.
    # initialize variables
    norm_snr=sp.zeros(n_samps)
    fwhm_snr=sp.zeros(n_samps)
    fwhm2_snr=sp.zeros(n_samps)
    pos_err0=sp.zeros(n_samps)
    pos_err1=sp.zeros(n_samps)
    angle_err=sp.zeros(n_samps)
    # go from resolution/5 to LAS*2
    #min_scale=cfg_resolution*0.1
    min_scale=min_resolution*0.05
    max_scale=cfg_las*2.5
    # compute range of models to consider-
    step_size=(max_scale-min_scale)/n_samps
    signal_fwhm= (sp.arange(n_samps)*step_size+step_size) 
    # this will return the uv baselines in inverse radians-
    bl=tv.getbaselines(cfg_file,lam=lam)
    # loop over gaussian component sizes-
    print '***',step_size,max_scale,min_scale,cfg_file
    for i in range(n_samps):
        parvec[3] = signal_fwhm[i] * 1.05
        parvec[4] = signal_fwhm[i] / 1.05
        if do_constSurfBright:
            # normalize total flux so that master_norm is the flux in mJy
            #  of a component with 1" FWHM - note signal_fwhm here
            #  is in radians
            parvec[0] = master_norm * (signal_fwhm[i] * 206264.8)**2 
        # set default deltas for calculating the numerical derivative
        #  default to 1% for nonzero params; 0.1xsynth beam for positions;
        #  and 0.5 deg for the axis angle-
        default_par_delta=sp.copy(parvec*0.01)
        default_par_delta[1]=cfg_resolution*0.1
        default_par_delta[2]=cfg_resolution*0.1
        default_par_delta[5]=0.5
        # put telescope gain scaling in to the errors (which are in mJy)-
        this_err = typical_err * (beamfwhm/2.91e-4)**2 
	f=tv.make_fisher_mx(bl,this_err,default_par_delta,beamfwhm,parvec,brute_force=False,flux_norm=True)
        # use SVD pseudo inverse instead of direct
        #  inverse for stability
	#finv=spla.inv(f)
        finv=spla.pinv(f)
	norm_snr[i]= parvec[0] / (finv[0,0])**0.5
        # save position error = average 1D error-
        pos_err0[i]= (finv[1,1])**0.5 
        pos_err1[i] = (finv[2,2])**0.5
	fwhm_snr[i]= parvec[3] / (finv[3,3])**0.5
        fwhm2_snr[i] = parvec[4]/ (finv[4,4])**0.5
        angle_err[i]= (finv[5,5])**0.5
        print cfg_file,i, norm_snr[i],fwhm_snr[i],pos_err0[i]
        # save fisher mx i here
    # save (signal_fwhm,norm_snr, fwhm_snr) here
    if do_constSurfBright:
        mystring='-constSB'
    else:
        mystring='-constFlux'
    fh=open(cfg_file+mystring+'.parErrs.txt','w')
    for i in range(n_samps):
        outstr='{0:.3e} {1:.3e} {2:.3e} {3:.4e} {3:.4e} {4:.3e} {4:.3e} {4:.3e}'.format(signal_fwhm[i],beamfwhm,norm_snr[i],fwhm_snr[i],fwhm2_snr[i],angle_err[i],pos_err0[i],pos_err1[i])
        fh.write(outstr+'\n')
    fh.close()