; ; process some of loris's data. ; ; get the files ; @filelist.dat ; ; defines flistar ; savfileout='savbysrc.sav' ; ; input all the save files, cram them into 1 big array ; called b_all[].., store this array in savfileout= ; istat=corsavbysrc(flistar,savfileout,/noavg,/nosingle,/filelist) ; ; get b_all from the save file ; restore,savfileout,/verb ; ; get list of source names ; srcnmAr=string(b_all.b1.h.proc.srcname) ; ; get a list of the unique source names ; usrcnm =srcnmAr[uniq(srcnmAr,sort(srcnmAr))] nsrc=n_elements(usrcnm) print,'number of sources found:',nsrc ; ; allocate b_allavg. holds average of each source ; b_allavg=replicate(b_all[0],nsrc) ; ; in fit, rms computatation ignore 20 % each edge ; edge=[.2,.2] cmask=cormaskmk(b_all[0],edge=edge) ; ; compute mean,rms for each scan. ; will use avg for Tsys weighting ; st=corstat(b_all,mask=cmask) tsys=reform(st.avg[0,*]) ; ; loop over each source ; 1. get the indices for this src ; 2. figure out Tsys so we can scale by 1/Tsys (for those sources ; with more than 1 scan ; 3. average the multi scans of a srcscans ; for i=0,nsrc-1 do begin &$ src=usrcnm[i] &$ ind=where(srcnmAr eq src,ncopysrc) &$ print,src,ncopysrc &$ if ncopysrc eq 1 then begin &$ btmp=b_all[ind] &$ endif else begin &$ new=1 &$ freq0=b_all[ind[0]].b1.h.dop.freqoffsets + $ b_all[ind[0]].b1.h.dop.freqBcRest * [1,1,1,1.] &$ vel0 = b_all[ind[0]].b1.h.dop.velorz &$ for j=0,ncopysrc-1 do begin &$ k=ind[j] &$ freqcur=b_all[k].b1.h.dop.freqoffsets + $ b_all[k].b1.h.dop.freqBcRest*[1,1,1,1.] &$ velcur = b_all[k].b1.h.dop.velorz &$ if velcur ne vel0 then print,$ 'dopvel mismatch src, srcInd,b_all:',src,j,k &$ ii=where((freqcur-freq0) ne 0,count) &$ if count gt 0 then print,$ 'freq mismatch src, srcInd,b_all:',src,j,k &$ w=1./tsys[*,k] &$ coraccum,b_all[k],btmp,new=new,scl=w &$ new=0 &$ endfor &$ endelse &$ ; ; call coravg. it will divide the accumulated data ; by the weights. ; b_allavg[i]=coravg(btmp) &$ endfor ; ; fit baselines to each sbc of each src ; store baselined data in array bbl[] ; poly =deg 2 ; sin = 2nd order ; deg=2 fsin=2 verb=-1 for i=0,nsrc-1 do begin &$ istat=corblauto(b_allavg[i],blfit,maskused,coef,edge=[.15],$ deg=deg,fsin=fsin,verb=verb) &$ if i eq 0 then begin &$ bbl =replicate(blfit,nsrc) &$ blAr=replicate(blfit,nsrc) &$ endif &$ bbl[i] =cormath(b_allavg[i],blfit,/sub) &$ blAr[i]=blfit &$ endfor ; ; look at the data ; nsig=5 for i=0,nsrc-1 do begin &$ a=corstat(bbl[i],mask=cmask) &$ sig=a.rms[0,0] &$ ver,-nsig*sig,nsig*sig &$ corplot,bbl[i],/vel &$ print,'ind:',i,' q to quit' &$ key=checkkey(/wait) &$ if key eq 'q' then stop &$ endfor ; ; look at the baselines we generated ; ver,26,31 corplot,blAr,m=1 i=5 tosmo=9 corsmo,bbl[i],bsmo,smo=tosmo corplot,bsmo,m=1,/vel,sym=10 ; ind=where(srcnmAr eq 'mbm16_cn2',count) print,count b=b_all[ind] bavg=coravg(b) corsmo,bavg,bsmo,smo=9 corplot,bsmo,m=1 b=bbl[5] x=(b.b1.d > (-.05)) < .05 x=wincos4(1024)*x spc=abs(fft(x)) hor,0,512 plot,spc a=strmatch(usrcnm,'mbm16_?1') ind=where(a eq 1) a=strmatch(srcnmAr,'mbm16_c') ii=where(a eq 1) ind=[ii,ind] bavg=coravg(bbl[ind]) corplot,bavg ; ind=where(srcnmar eq 'mbm16_c') bavg=coravg(b_all[ind],/pol) corplot,bavg,m=1,/vel ; istat=corbl(bavg,aa,maskused)