;+ ; NAME : GAUSSFIT_INT ; ; PURPOSE : Get the set of paramters of single gaussian fit ; by applying integration method ; ; CALLING SEQUENCE : ; ; Result = gaussfit_int( data) ; ; INPUTS : ; DATA Spectral data ; 1 D : one profile with N_SPEC elements ; 2 D : a set of profiles(spectrum image) ; with N_SPEC x N_SPAT elements ; OUTPUT : ; Result ; 1D or 2D acoording to input DATA ; Result(0,*) : backbround ; Result(1,*) : Peak value ; Result(2,*) : center position ; Result(3,*) : Gaussian width(standard devaition) ; - function gaussfit_int, data wdim = n_elements(data(*,0)) ydim = n_elements(data(0,*)) goto, next ; Average Profile prof = total(data, 2)/ydim ; Define region x=indgen(wdim) range=3.0 s=where(prof ge (max(prof, min=m)-m)*0.5+m, count) cen = total(x(s))/count fwhm = x(s(count-1))+1-x(s(0)) sigma =fwhm*0.4247 inside = where( (x-cen-range*sigma)*(x-cen+range*sigma) le 0., n_in) outside =where( (x-cen-range*sigma)*(x-cen+range*sigma) gt 0., n_out) weight = ((x-cen-range*sigma)*(x-cen+range*sigma) le 0.) next: ; Bg image ;if n_out le 3 then begin bg = total(data([0,1,2,3,4],*),1)/5. $ < total(data([wdim-5, wdim-4, wdim-3, wdim-2, wdim-1],*),1)/5. ;endif else bg = reform(total(data(outside,*), 1)/n_out) if n_elements(cutoff) eq 0 then cutoff=bg*0.5*wdim/2. ; Accumulative sums hsum = replicate(0., wdim+1, ydim) for j=1, wdim do hsum(j,*)=hsum(j-1,*)+(data(j-1,*)-bg) ; *weight(j-1) h = reform(hsum(wdim,*)) ; Check positivity of the integrated values pos = where(h gt cutoff, n_pos) neg = where(h le cutoff, n_neg) ; Determination of 0.25, 0.5, 0.75 points left = fltarr(ydim) middle = fltarr(ydim) right = fltarr(ydim) if n_pos eq 0 then return, 0 niv=0.25*h(pos) j=0 for jj=0, wdim do j=j+(hsum(jj,pos) le niv) left(pos)= (j-1.5+(niv-hsum(j-1,pos)) $ /(hsum(j,pos)-hsum(j-1,pos))) niv=0.5*h(pos) j=0 for jj=0, wdim do j=j+(hsum(jj,pos) le niv) middle(pos)= (j-1.5+(niv-hsum(j-1,pos)) $ /(hsum(j,pos)-hsum(j-1,pos))) niv=0.75*h(pos) j=0 for jj=0, wdim do j=j+(hsum(jj,pos) le niv) right(pos)= (j-1.5+(niv-hsum(j-1,pos)) $ /(hsum(j,pos)-hsum(j-1,pos))) if n_neg ge 1 then begin left(neg)=median(left(pos)) middle(neg)=median(middle(pos)) right(neg)= median(right(pos)) endif value = fltarr(4, ydim) value(0,*) = bg value(1, *) = 0.269085*h/((right-left)/2.) value(2, *) = middle value(3, *) = (right-left)/2./0.6745 return, reform(value) end