;+ ; NAME: AVERAGE ; ; PURPOSE: ; To compute the sum and the sum of sqaures over dark ; image files. ; ; CATEGORY: ; ; CALLING SEQUENCE: ; AVERAGE,PATHFILES,TIME ; ; INPUTS: ; PATHFILES: A STRING ARRAY of image file names. ; ; TIME: a two byte INTEGER, specifying the exposure time ; of the image files to be included. If no time is ; specified, then by default 60 will be chosen. ; ; KEYWORD PARAMETERS: ; None. ; ; OUTPUTS: ; Four files,for each camera, are created to store the ; output from this procedure. ; ; c:\idl\data\dark\temp.0(1)dk ( 0 if images come from ; camera 0 or a 1 if images come from camera 1): This ; file contains 19 LONG INTEGERS, and is used to stored ; the range of CCD temperatures spanning -49 deg. C to ; -31 deg. C. An ASSOCIATED file can be used to retreive ; this data. ; ; c:\idl\data\dark\number.0(1)dk : This file contains the ; number of dark images used to create the sum and the sum ; of squares for the images corresponding to a CCD temperature ; in the range -49 to -31 deg. C, with each temperature ; differing by unit magnitude. The number of images are stored ; as LONG INTEGERS. An ASSOCIATED file can be used to access ; this data, as for the temperatures. The CCD temperatures ; have been used to index this data, so in the ASSOCIATED ; ARRAY, element zero will correspond to a CCD temperature of ; -49 deg. C, while element 1 will correspond to a temperature ; of -48 deg. C, ect. ; ; c:\idl\data\dark\sum0(1)dk : This file contains the ; sum of the dark images, corresponding to each CCD temperature ; in the range -49 to -31 deg. C. Again, this data can be ; retrieved by using an ASSOCIATED file, which will by an ; array of 19 (LONG) images which are indexed by the CCD ; temperatures. ; ; c:\idl\data\dark\sqsum.0(1)dk : Same as for ...\sum0(1)dk, ; except this file contains the sum of squares of the images. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; None. ; ; RESTRICTIONS: ; This procedure checks if four files of the form ; c:\idl\data\dark\*.0dk and four files of the form ; c:\idl\data\dark\*.1dk, exist. If, at least four files ; of this form exist then the procedure will not create ; and initialize new files for data storage. Consequently, ; the only files that can have the extention, .0dk or .1dk, ; in the directory, c:\idl\data\dark ,are the files mentioned ; above, in the output section. ; Only files that come from the path ; c:\images\dark\cam0 or c:\images\dark\cam1 , ; will be used by this procedure. ; This procedure does not differentiate between types ; of image files, so it is expected that only dark ; image files reside in the either of the directories ; listed above. ; Finally, all files are expected to come from the ; same paths. ; ; PROCEDURE: ; The list of files are first run through the procedure ; JULIAN, to check if any of these files have been previously ; included. For the files that contain new dark images they ; are then seperated by camera number. The files that will ; be used for data storage are created if they do not exist ; already. For the case of camera 0, the list of new dark images ; are then run through the procedure DRKCHKZ, which checks for ; corrupted images. Since, it was found that camera 1 did not ; produce corrupted images, no such procedure exist for camera ; 1 files. Next, the sum, sum of squares, and the number of ; images corresponding to a given CCD temperature are calculated ; and stored in the appropriate files. ; ; MODIFICATION HISTORY: ; Written May 1994, by T A Oliynyk. ; ; June 7, 1994: The CLOSE statements were dropped because they ; were found to be redundant. ;- PRO average,pathfiles,time julian,pathfiles,newfiles,time;check to see which of the files have ;not already been included camnum=STRMID(newfiles(0),18,1);check if the images came from camera ;one or two CASE camnum OF '0':BEGIN ;case where images came for camera one infiles0=FINDFILE('c:\idl\data\dark\*.0dk') ;check if files for data storage ;have all been created IF N_ELEMENTS(infiles0) NE 4 THEN BEGIN ;if not, then initialize files to ;appropriate size OPENW,aunit,'c:\idl\data\dark\temp.0dk',/GET_LUN OPENW,bunit,'c:\idl\data\dark\number.0dk',/GET_LUN OPENW,cunit,'c:\idl\data\dark\sum.0dk',/GET_LUN OPENW,dunit,'c:\idl\data\dark\sqsum.0dk',/GET_LUN temp0=ASSOC(aunit,LONARR(1)) number0=ASSOC(bunit,LONARR(1)) sum0=ASSOC(cunit,LONARR(256,256)) sqsum0=ASSOC(dunit,LONARR(256,256)) FOR l=0, 18 DO BEGIN temp0(l)=LONARR(1) number0(l)=LONARR(1) sum0(l)=LONARR(256,256) sqsum0(l)=LONARR(256,256) ENDFOR FREE_LUN, aunit FREE_LUN, bunit FREE_LUN, cunit FREE_LUN, dunit ENDIF OPENU,aunit,'c:\idl\data\dark\temp.0dk',/GET_LUN OPENU,bunit,'c:\idl\data\dark\number.0dk',/GET_LUN OPENU,cunit,'c:\idl\data\dark\sum.0dk',/GET_LUN OPENU,dunit,'c:\idl\data\dark\sqsum.0dk',/GET_LUN temp0=ASSOC(aunit,LONARR(1)) number0=ASSOC(bunit,LONARR(1)) sum0=ASSOC(cunit,LONARR(256,256)) sqsum0=ASSOC(dunit,LONARR(256,256)) drkchkz,newfiles,in,count ;check for corrupted dark images IF count NE 0 THEN BEGIN FOR i=0,N_ELEMENTS(in)-1 DO BEGIN rdkimg,in(i),header,image ;get the dark image and header information Kih=gethd(header) t=Kih.misc.temp.tcf.mean ;get the CCD temperature IF (t LT (-306)) AND (t GT (-494)) THEN BEGIN limage=LONG(image) j=ROUND((t/10.)+49) ;use CCD temperature as an index temp0(j)=[-49+j] ;store CCD temperature number0(j)=number0(j)+1 ;store number of images for given CCD temp. sum0(j)=limage+ sum0(j) ;calculated and store the sum of the images sqsum0(j)=limage^2+sqsum0(j) ;calculate and store the square of the ;sum of the images ENDIF ENDFOR ENDIF ELSE BEGIN MESSAGE, 'None of these files will be used.',/INFORMATIONAL ENDELSE FREE_LUN, aunit FREE_LUN, bunit FREE_LUN, cunit FREE_LUN, dunit END '1':BEGIN infiles1=FINDFILE('c:\idl\data\dark\*.1dk') IF N_ELEMENTS(infiles1) NE 4 THEN BEGIN OPENW,aunit,'c:\idl\data\dark\temp.1dk',/GET_LUN OPENW,bunit,'c:\idl\data\dark\number.1dk',/GET_LUN OPENW,cunit,'c:\idl\data\dark\sum.1dk',/GET_LUN OPENW,dunit,'c:\idl\data\dark\sqsum.1dk',/GET_LUN temp1=ASSOC(aunit,LONARR(1)) number1=ASSOC(bunit,LONARR(1)) sum1=ASSOC(cunit,LONARR(256,256)) sqsum1=ASSOC(dunit,LONARR(256,256)) FOR l=0, 18 DO BEGIN temp1(l)=LONARR(1) number1(l)=LONARR(1) sum1(l)=LONARR(256,256) sqsum1(l)=LONARR(256,256) ENDFOR FREE_LUN, aunit FREE_LUN, bunit FREE_LUN, cunit FREE_LUN, dunit ENDIF OPENU,aunit,'c:\idl\data\dark\temp.1dk',/GET_LUN OPENU,bunit,'c:\idl\data\dark\number.1dk',/GET_LUN OPENU,cunit,'c:\idl\data\dark\sum.1dk',/GET_LUN OPENU,dunit,'c:\idl\data\dark\sqsum.1dk',/GET_LUN temp1=ASSOC(aunit,LONARR(1)) number1=ASSOC(bunit,LONARR(1)) sum1=ASSOC(cunit,LONARR(256,256)) sqsum1=ASSOC(dunit,LONARR(256,256)) FOR i=0,N_ELEMENTS(newfiles)-1 DO BEGIN rdkimg,newfiles(i),header,image Kih=gethd(header) t=Kih.misc.temp.tcf.mean IF (t LT (-306)) AND (t GT (-494)) THEN BEGIN limage=LONG(image) j=ROUND((t/10.)+49) temp1(j)=[-49+j] number1(j)=number1(j)+1 sum1(j)=limage+ sum1(j) sqsum1(j)=limage^2+sqsum1(j) ENDIF ENDFOR FREE_LUN, aunit FREE_LUN, bunit FREE_LUN, cunit FREE_LUN, dunit END ELSE: BEGIN MESSAGE, 'None of files come from camera 0 or 1.',/INFORMATIONAL END ENDCASE RETURN END