PRO scf,file,dv ; ; Example: ; ; scf,'hcl2_c18o.fits',0.05 ; ;Compute and plot SCF from a given spectral map file with velocity ;channel width = dv, in km/s. !x.thick=2.0 !y.thick=2.0 !p.thick=2.0 !p.charthick=2.0 !p.charsize=1.4 ; ;Read data file: ;--------------- spec=readfits(file) ; ;It is assumed velocity is first coordinate, otherwise: ; ;spec=transpose(spec,[2,0,1]) ;if velocity is third coordinate. ;spec(where(spec ne spec))=0.0 ;if need to turn NaN into zeros. s=size(spec) print,s nv=s(1) N1=s(2) N2=s(3) v=findgen(nv)*dv-(dv*nv/2.) ;velocity channels noise=sqrt(aver(spec(where(spec lt 0.))^2)) ;1-sigma noise signal=sqrt(total(spec^2)/(N1*N2*nv)) ;rms signal print,'noise:',noise print,'rms(S):',signal ; ;Average spectrum: ;----------------- temp=fltarr(nv) for j=0,nv-1 do begin scr=aver(spec(j,*,*)) temp(j)=temp(j)+scr endfor window,0,xsize=400,ysize=300 plot,v,temp,xtitle='v [km/s]',ytitle='T [K]', $ xr=[min(v)-0.2,max(v)+0.2],xs=1,ys=1, $ yr=[min(temp)-0.1,max(temp)+0.1] ;plot the average spectrum ; ;Maps of integrated and peak temperatures: ;----------------------------------------- map_p=fltarr(N1,N2) map_i=fltarr(N1,N2) width=fltarr(N1,N2) for i=0,N1-1 do begin for j=0,N2-1 do begin map_p(i,j)=max(spec(*,i,j)) ;peak temperature map_i(i,j)=dv*total(spec(*,i,j)) ;integrated temperature width(i,j)=map_i(i,j)/map_p(i,j) ;line width endfor endfor index=where(map_p gt 3.*noise and map_i gt 0.0) ;3-sigma detection for computing print,'Average Line-Width:',aver(width(index))/2.355 ;/2.355 to compare with sigma(v) ; ;Statistics of mean spectrum: ;---------------------------- tt=total(temp) mean_v=total(temp*v)/tt sig_v=sqrt(total(temp*(v-mean_v)^2)/tt) print,':',mean_v print,'sigma(v)',sig_v print,'sigma(v)/line-width:',sig_v/(aver(width(index))/2.355) ;comparison sigma_v of mean spectrum/ ; ;Parameters for SCF: ;------------------- mean_vl=fltarr(N1,N2) ;local average velocity Q=fltarr(N1,N2) ;spectrum quality ; widthv=2. ; velocity window for computing the SCF, given as a ; multiple of sigma_v of the mean spectrum. ; ;Put intensity to zero in velocity channels outside the velocity window: ; for i=0,N1-1 do begin for j=0,N2-1 do begin tot=total(spec(*,i,j)) mean_vl(i,j)=total(spec(*,i,j)*v)/tot scr=min(abs((v-(mean_vl(i,j)-widthv*sig_v))),v1) scr=min(abs((v-(mean_vl(i,j)+widthv*sig_v))),v2) spec(0:v1,i,j)=0.0 spec(v2:nv-1,i,j)=0.0 Q(i,j)=1.*sqrt(aver(spec(v1:v2,i,j)^2))/noise ;Spectrum Quality endfor endfor ; print,'=',aver(Q) ;average Spectrum Quality ; scr=where(Q eq 0.0,c) print,'Fraction of pixels with Q=0:',c/(1.0*N1*N2) scr=where(Q gt 0.0 and Q lt 2,c) print,'Fraction of pixels with 02.0 print,'DX, :',avlag(i),scf_av(i) ; ;IMAGE of SCF: ;------------- index=where(Q lt 2.,c) if (c gt 0) then buffer(index)=0.0 tvscl,rebin(buffer,N1*2,N2*2),N1*2,0 ; endif endfor ;i loop (lags) index=where(scf_av gt 0.0) print,'DX:',avlag(index) print,':',scf_av(index) ;Plot SCF versus lag: ;-------------------- scf_av=scf_av(index) avlag=avlag(index) window,3,xsize=500,ysize=300 plot_oo,avlag,scf_av,psym=6,ys=1,yr=[min(scf_av)-0.2,max(scf_av)+0.2], $ xs=1,xtitle='r',ytitle='',xr=[min(avlag)-0.2,max(avlag)+0.2] STOP END