head=headfits(fitsname);read the header of the fits file to a vector
bw = fxpar(head,'BW'); band width (MHz) freq = fxpar(head,'LINEFREQ'); central frequency (GHz)
nx = fxpar(head,'NAXIS1'); number of elements in the first dimension ny = fxpar(head,'NAXIS2'); nz = fxpar(head,'NAXIS3'); crvalx = fxpar(head,'CRVAL1'); reference value of the first dimension cdeltax = fxpar(head,'CDELT1'); increasement of the first dimension ; in units of degree, when calculate physical ; scale, must changed to arcdegree crpixx = fxpar(head,'CRPIX1'); reference position of the first dimension crvaly = fxpar(head,'CRVAL2'); cdeltay = fxpar(head,'CDELT2'); crpixy = fxpar(head,'CRPIX2'); crvalz = fxpar(head,'CRVAL3'); cdeltaz = fxpar(head,'CDELT3'); crpixz = fxpar(head,'CRPIX3'); f = (dindgen(nz)+0.5-crpixz)*cdeltaz+crvalz; m/s f = f/1.0e3; km/s width = cdeltaz/1.0e3
expr = 'P[0]+GAUSS1(X,P[1:3],/PEAK)'
status = 'init' while (status ne 'exit') do begin print,'enter x y coordinates:' read,x,y c=a(x,y,*) maxc = max(c) index = where(c eq maxc) start = [0.1,f(index),width,maxc] result = MPFITEXPR(expr,f,c,c*0.0+1.0,start) sigma = result[2] plot,f,c,psym=4,symsize=1.0 oplot,f,result[0]+gauss1(f,result[1:3],/PEAK),color=100,thick=3 strsigma = textoidl('sigma =')+strtrim(sigma) xyouts, f[index],c[index]*0.8, strsigma,charsize=1.5,charthick=1.5 print,'enter command:' read,status endwhile END