;---------------------------------------------------------------------- ; NAME: ; remove_pattern3 ; PURPOSE: ; Remove the digital noise pattern from individual images and ; remove the individual channel offsets. ; ; ; EXPLANATION: ; When called the program determines the median value per pixel ; per channel for the first 15 channels (0-14). At the time this ; was written the last channel was not functioning do to a ; wiring error, so future use of this procedure should include ; the last channel. The channel offsets are also removed by ; median filtering across the channels. ; ; CALLING SEQUENCE: ; remove_pattern3 , 'imlist' ; INPUTS: ; imlist - a filename for a file containing a list of images ; that need to be pattern corrected. ; ; OPTIONAL INPUTS: ; ; OPTIONAL INPUT KEYWORDS: ; ; OUTPUTS: ; output files will have the same image name as specified in ; the image list but will have the prefix 'p' which stands for ; pattern removed. ; ; OPTIONAL OUTPUTS: ; ; NOTES: ; This procedure requires that the path name for the filelist ; template is set to the appropriate path name. Pleas alter the ; path name for this file accordingly. ; ; PROCEDURE CALLS: ; ; REVISION HISTORY: ;------------------------------------------------------------------------- PRO remove_pattern3, imlist ; creates an array for the pattern to be subtracted. pattern = dblarr(20,240) ;avgpix an array for the average channel offsets. avgpix = dblarr(15) ;an array for the new data newData = dblarr(320,240) ;retreive the file list. files_file=make_array(1, /STRING) restore, '/d1/data1/mirsi/analysis/filelist_template.idl' files_file=read_ascii(imlist, template=filelist_template) filelist=files_file.field1 nfiles=n_elements(filelist) ; loops over the number of images FOR i=0, nfiles-1 DO BEGIN image_name = filelist(i) ;read the data data = READFITS(image_name, header, EXTEN_NO=0) ; develope a pattern noise array FOR y = 0 , 239 DO BEGIN FOR k = 0, 19 DO BEGIN FOR l = 0, 14 DO BEGIN x = l*20 + k avgpix(l) = data(x,y) ENDFOR ; median filter the pattern noise from the channel pattern(k,y) = median(avgpix) ENDFOR ENDFOR ; retrieve the median value across the channels at the bottom of the nmedian = median(data) ;subtract the pattern from the images. FOR l=0,15 DO BEGIN ;find the median offset from the median of the image avgchannel = median(data[l*20:l*20+19,0:239]) - nmedian ;subtract the channel pattern from the ;channel and subtract the median ;channel offset. newData[l*20:l*20+19,*] = data[l*20:l*20+19,*] - pattern[*,*] - avgchannel ENDFOR ; write the image to disk. The image name has a the ; prefix 'p' to designate that the image has gone ; through a Pattern removal. The fits header is updated ; to reflect that the pattern was removed. history = 'Digital noise pattern removed with remove_pattern3.pro' sxaddhist, history, header image_name = 'p' + image_name writefits, image_name, newData, header ENDFOR end