; NAME: ; ADDLINES ; ; PURPOSE: ; This function inserts a list of lines in a 1D array ; ; CALLING SEQUENCE: ; Result = ADDLINES(linelist, wavl) ; ; INPUTS: ; List = The 2D array with [loc, width, amp] ; Wavl = The array of wavelength locations (in meters) ; (range 0.5 microns to 2.0) ; ; OUTPUT: ; A spectrum with lines from the input list ; ; PROCEDURE: ; Evaluate each along the line using a gaussing of amplitude = ; intensity, fwhm = width, and mean=pos ; ; MODIFICATION HISTORY: ; created Aug 18 2003 by John Dermody function ADDLINES, list, ny linespec = fltarr(ny) ; the ohline spectrum if (list eq [0]) then return, linespec ; prepare to calculate each lines gaussian if ((size(list))[0] gt 1) then begin nlines = (size(list))[2] endif else begin nlines = 1 endelse mean = list[0,*] sigma = (list[1,*] / 2.354) amp = list[2,*] x1 = (round(mean - 4 * sigma) > 0) < (ny-1) x2 = (round(mean + 4 * sigma) > 0) < (ny-1) x = findgen(ny) gauss = fltarr(ny, nlines) for i = 0, nlines-1 do begin if (x1[i]+1 ge x2[i]) then begin gauss[mean[i], i] = 1. endif else begin gauss[x1[i]:x2[i], i] = 1 / (sigma[i] * sqrt(2.*!pi)) * $ exp((-1./2) * ((x[x1[i]:x2[i]] - mean[i]) / sigma[i])^2) endelse endfor linespec = total(amp ## (fltarr(ny)+1) * $ gauss / (total(gauss,1) # (fltarr(ny) + 1)),2) return, linespec end