;+ ; NAME: DRKSTATS ; ; PURPOSE: ; To calculate and store individual means of dark images ; for a given internal and CCD temperature. ; ; CATEGORY: ; ; CALLING SEQUENCE: ; DRKSTATS,FILES,TIME ; ; INPUTS: ; FILES: A STRING ARRAY of file names, including the path. ; ; TIME: A two-byte INTEGER, specifying the exposure time ; of the dark image files to be looked at. ; ; KEYWORD PARAMETERS: ; None. ; ; OUTPUTS: ; TWO FILES: ; ; c:\idl\data\dark\dark0.sts: This file stores the mean of ; dark images from camera 0. The data is stored is ; indexed by CCD and interanal temperatures, where ; the CCD temperature ranges from -48 to -31 deg. C ; and the internal temperature ranges from -5 to 34 deg C. ; ; c:\idl\data\dark\dark1.sts: Sames as above, except is stores ; information about dark images from camera 1. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; None. ; ; RESTRICTIONS: ; 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. ; ; PROCEDURE: ; This procedure require as input a STRING of filenames of ; the type 'c:\images\dark\cam0(1)\....' , for the variable ; 'FILES'. It also requires a two byte iteger for the variable ; 'TIME' . If no 'TIME' is specified then by default 60 will ; be chosen. This procedure takes in the image files named ; by the STRING variable 'FILES' and calculates the mean of ; the image. This mean is then stored in one of the following ; two files 'C:\idl\data\dark0(1).sts'(depending on whether ; the image came from camera one or two). Also stored in this ; file is the internal and CCD temperature at which the image ; was aquired and the number of images for a given internal and ; CCD temperature. ; ; MODIFICATION HISTORY: ; Written May 1994, by T A Oliynyk. ;- PRO drkstats,files,time js_stats,files,time,in ;check to see which of the files entered ;have not already been included camnum=STRMID(in(0),18,1) ;look only for files of the form ;c:\images\dark\cam0(1)\.... CASE camnum OF '0':BEGIN ;Files are from camera 0 infiles=FINDFILE('C:\idl\data\dark\dark0.sts',count=count0) ;Check to see ;if this file exists. IF count0 NE 1 THEN BEGIN ;if not then initialize a file to store the ;the required data OPENW,unit,'C:\idl\data\dark\dark0.sts',/GET_LUN initial=ASSOC(unit,BYTARR(1206)) FOR i=0,719 DO initial(i)=BYTARR(1206) CLOSE,unit FREE_LUN,unit ENDIF OPENU,unit,'C:\idl\data\dark\dark0.sts',/GET_LUN dstat=ASSOC(unit,BYTARR(1206)) FOR i=0, N_ELEMENTS(in)-1 DO BEGIN rdkimg,in(i),hd,im Kih=gethd(hd) intemp=ROUND(kih.misc.temp.tei.mean/10.) ;get internal temperature ccdtemp=ROUND(Kih.misc.temp.tcf.mean/10.) ;get ccd temperature IF (((intemp LE 34) AND (intemp GE -5)) AND ((ccdtemp LE -31) $ AND (ccdtemp GE -48)))THEN BEGIN index=40*(ccdtemp+48)+intemp+5 ;use intemp and ccdtemp to index record=dstat(index) ;the associated array dstat n=FIX(record,4) IF n LT 100 THEN BEGIN ;collect at most 100 dark images for ;a given internal and CCD temperature n=n+1 ;keep track of how may images all collected year=Kih.misc.dt.year ;get date and time month=FIX(Kih.misc.dt.month) day=FIX(Kih.misc.dt.day) second=FIX(Kih.misc.tm.hour)*3600.+FIX(Kih.misc.tm.minute)*60 + $ FIX(Kih.misc.tm.second) js=ymds2js(year,month,day,second) ;convert date and time to julian sec mn=mean(im) ;find mean of image record(0)=BYTE(intemp,0,2) ;store information to appropriate record(2)=BYTE(ccdtemp,0,2) ;position record(4)=BYTE(n,0,2) ptrmn=6 + (n-1)*4 record(ptrmn)=BYTE(mn,0,4) ptrjs=406+ (n-1)*8 record(ptrjs)=BYTE(js,0,8) dstat(index)=record ENDIF ENDIF ENDFOR CLOSE,unit FREE_LUN,unit END '1': BEGIN infiles=FINDFILE('C:\idl\data\dark\dark1.sts',count=count0) IF count0 NE 1 THEN BEGIN OPENW,unit,'C:\idl\data\dark\dark1.sts',/GET_LUN initial=ASSOC(unit,BYTARR(1206)) FOR i=0,719 DO initial(i)=BYTARR(1206) CLOSE,unit FREE_LUN,unit ENDIF OPENU,unit,'C:\idl\data\dark\dark1.sts',/GET_LUN dstat=ASSOC(unit,BYTARR(1206)) FOR i=0, N_ELEMENTS(in)-1 DO BEGIN rdkimg,in(i),hd,im Kih=gethd(hd) intemp=ROUND(kih.misc.temp.tei.mean/10.) ccdtemp=ROUND(Kih.misc.temp.tcf.mean/10.) IF (((intemp LE 34) AND (intemp GE -5)) AND ((ccdtemp LE -31) $ AND (ccdtemp GE -48)))THEN BEGIN index=40*(ccdtemp+48)+intemp+5 record=dstat(index) n=FIX(record,4) IF n LT 100 THEN BEGIN n=n+1 year=Kih.misc.dt.year month=FIX(Kih.misc.dt.month) day=FIX(Kih.misc.dt.day) second=FIX(Kih.misc.tm.hour)*3600.+FIX(Kih.misc.tm.minute)*60 + $ FIX(Kih.misc.tm.second) js=ymds2js(year,month,day,second) mn=mean(im) record(0)=BYTE(intemp,0,2) record(2)=BYTE(ccdtemp,0,2) record(4)=BYTE(n,0,2) ptrmn=6 + (n-1)*4 record(ptrmn)=BYTE(mn,0,4) ptrjs=406+ (n-1)*8 record(ptrjs)=BYTE(js,0,8) dstat(index)=record ENDIF ENDIF ENDFOR CLOSE,unit FREE_LUN,unit END ELSE: BEGIN print,'All of these files have already been included' END ENDCASE RETURN END