def reproducibility (infile='lbcs_stats.sum',outfile=''): a = np.loadtxt(infile,dtype='str') coords = sum2coords(a) acorr = correlate(coords,0,1,coords,0,1,0.003) acorr = acorr[acorr[:,0]<acorr[:,1]] tdiff = np.zeros((len(tels),10),dtype='float') for i in acorr: g1,g2 = a[int(i[0]),7],a[int(i[1]),7] for tel in range(len(tels)): if g1[tel]!='-' and g2[tel]!='-': tdiff[tel,abs(int(g1[tel])-int(g2[tel]))]+=1 matplotlib.rcParams.update({'font.size':14}) for tel in range(len(tels)): tdiff[tel] /= tdiff[tel].sum() for i in range(1,len(tdiff[tel])): tdiff[tel,i]+=tdiff[tel,i-1] plt.plot(tdiff[tel]) matplotlib.rcParams.update({'font.size':10}) plt.legend(tels) matplotlib.rcParams.update({'font.size':14}) plt.xlabel('Difference in S:N parameter') plt.ylabel('Cumulative fraction') if outfile=='': plt.show() else: plt.savefig(outfile,bbox_inches='tight') plt.clf()
def lbcsjvas (jvascat='/home/njj/catalogues/jvas.txt'): lbcs = np.loadtxt('lbcs_stats.sum',dtype='str') jvas = np.loadtxt(jvascat, dtype='str') for i in lbcs: new = np.array([hms2decimal(i[1],':'),dms2decimal(i[2],':')]) try: clbcs = np.vstack((clbcs,new)) except: clbcs = np.copy(new) for i in jvas: #2-4,5-7 new = np.array([hms2decimal(i[2]+':'+i[3]+':'+i[4],':'),\ dms2decimal(i[5]+':'+i[6]+':'+i[7],':')]) try: cjvas = np.vstack((cjvas,new)) except: cjvas = np.copy(new) a=correlate(clbcs,0,1,cjvas,0,1,10./3600.) f=open('lbcs_in_jvas','w') for i in a: f.write('%s\n'%(lbcs[int(i[0]),0])) f.close()
def transfer (picdir): os.system('grep P lbcs_stats.sum >transfer_temp') dat = np.loadtxt('transfer_temp',dtype='str') for i in dat: new = np.array([hms2decimal(i[1],':'),dms2decimal(i[2],':')]) try: coords = np.vstack((coords,new)) except: coords = np.copy(new) a = correlate (coords,0,1,coords,0,1,2.0) a = a[a[:,0]<a[:,1]] # Select correlations between observations at the same time for i in a: i0,i1 = int(i[0]), int(i[1]) condtime = dat[i0,3]==dat[i1,3] and dat[i0,4]==dat[i1,4] condP = dat[i0,5].count('P')>5 and dat[i1,5].count('P')>5 if condtime: try: atime = np.vstack((atime,i)) except: atime = np.copy(i) if condP: try: aP = np.vstack((aP,i)) except: aP = np.copy(i) fo = open('transfer_sources','w') for i in aP: i0,i1 = int(i[0]),int(i[1]) pcount = dat[i0,5].count('P')+dat[i1,5].count('P') scount = dat[i0,5].count('S')+dat[i1,5].count('S') xcount = dat[i0,5].count('X')+dat[i1,5].count('X') prop = float(pcount)/float(pcount+scount+xcount) fo.write('%s %s %.3f %.3f\n'%(dat[i0,0],dat[i1,0],i[2],prop)) fo.close()
def plotdensity (infile='lbcs_stats.sum',station=0,reqtype='PSX-',dobar=True,\ outfile='lbcs_den.png',text='',vmin=0,vmax=2,racol=2,deccol=3,black_level=1.0): radius = 3.0 if infile=='lbcs_stats.sum': ain = np.loadtxt(infile,dtype='str') for i in ain: if i[5][station] in reqtype: try: a = np.vstack((a,i)) except: a = np.copy(i) coords = sum2coords(a) else: ain = np.loadtxt(infile,dtype='str') coords = np.asarray(np.column_stack((ain[:,racol],ain[:,deccol])),dtype='float') y,x = np.meshgrid(np.arange(0.,90,2),np.arange(0.,360,2)) cgrid = np.dstack((x,y)).reshape(45*180,2) acorr = correlate(cgrid,0,1,coords,0,1,radius) ngrid = 0.0*cgrid[:,0] for i in range(len(cgrid)): ngrid[i] = len(np.argwhere(acorr[:,0]==i)) cplot = ngrid.reshape(180,45).T/(np.pi*radius**2) cplot = cplot[:,::-1] plt.imshow(cplot,extent=[24,0,0,90],cmap=matplotlib.cm.gray_r,\ vmin=0.0,vmax=black_level,aspect=0.0692) plt.contour(cplot,[1.0],extent=[24.0,0.0,0,90]) plt.text(20,10,text) eq = ga2eq(10); plt.plot(eq[:,0],eq[:,1],'r-') eq = ga2eq(-10); plt.plot(eq[:,0],eq[:,1],'r-') plt.xlabel ('Right ascension/hr') plt.ylabel ('Declination/deg') plt.ylim(0.0,90.0) plt.grid() if dobar: plt.colorbar() plt.savefig (outfile,bbox_inches='tight') plt.clf()
def plotdetect (dfile = 'lbcs_stats.sum'): a = np.loadtxt(dfile ,dtype='str') coords = sum2coords(a) listN = np.loadtxt('../scheduling/lbcs_list',dtype='str') coordsN = np.asarray(listN[:,1:3],dtype='float') acorrN = correlate(coords,0,1,coordsN,0,1,0.003) # listS = np.loadtxt('../scheduling/lbcs_south',dtype='str') # coordsS = np.asarray(listS[:,1:3],dtype='float') # acorrS = correlate(coords,0,1,coordsS,0,1,0.003) ndet,wflux,spind,ncorr = np.array([]),np.array([]),np.array([]), 0 det = np.zeros((9,len(acorrN)),dtype='str') for cN in acorrN: for j in range(9): det[j,ncorr] = a[int(cN[0])][5][j] ncorr+=1 ndet = np.append(ndet,a[int(cN[0])][6]) lineN = listN[int(cN[1])] fv,fm,fc,fw = np.asarray(lineN[3:7],dtype='f') sp_vc = np.log10(fv/fc)/np.log10(70/150.) sp_vw = np.log10(fv/fw)/np.log10(70/325.) sp_cw = np.log10(fc/fw)/np.log10(150/325.) spind = np.append(spind,np.nanmean([sp_vc,sp_vw,sp_cw])) wflux = np.append(wflux,fw) plt.semilogx(wflux,spind,'bx') plt.semilogx(wflux[det[0]=='P'],spind[det[0]=='P'],'rx') plt.semilogx(wflux[det[7]=='P'],spind[det[7]=='P'],'gx') aplot0 = np.zeros((10,10))*np.nan aplot7 = np.zeros((10,10))*np.nan n = len(wflux) for i in range(10): x = -1.0+0.2*i for j in range(10): nall = n0 = n7 = 0.0 y = -1.0+0.1*j for k in range(n): if x<np.log10(wflux[k])<x+0.2 and y<spind[k]<y+0.1: nall+=1.0 if det[0,k]=='P': n0+=1.0 if det[7,k]=='P': n7+=1.0 if nall and n0 and (n0/nall)*np.sqrt(1./n0+1./nall)<0.1: aplot0[i,j] = n0/nall if nall and n7 and (n7/nall)*np.sqrt(1./n7+1./nall)<0.1: aplot7[i,j] = n7/nall if i==0 and j==1: print ('n0,n7,nall',n0,n7,nall) matplotlib.rcParams.update({'font.size': 14}) plt.subplot(211,xticks=[]) plt.imshow(aplot0,extent=[-1.0,1.0,-1.0,0.0],vmax=0.6,cmap=matplotlib.cm.gray_r) plt.colorbar() plt.ylabel('Low-f spectral index') plt.plot([-1.,0.0],[-0.5,-1],'k-') plt.text(0.5,-0.2,'DE601') plt.subplot(212) plt.colorbar() plt.ylabel('Low-f spectral index') plt.plot([-1.,0.0],[-0.5,-1],'k-') plt.xlabel('log 325-MHz flux density/Jy') plt.imshow(aplot7,extent=[-1.0,1.0,-1.0,0.0],vmax=0.6,cmap=matplotlib.cm.gray_r) plt.text(0.5,-0.2,'UK608') # plt.show() plt.savefig('lbcs_detfig.png',bbox_inches='tight')