pro Puffy_Events_08 ;This script will attempt to locate the events on the H2RG-015 that are attributed ;to electron-hole pairs in the CdZnTe 800 um substrate ;CONSTANTS******************************************************. ;Force some to be floating point integers numpixrd=2048.*2048. ;Size of device threshold=300 ;Threshold to flag pixel as Cosmic Ray Gauss_width=14 ;Width of Area to use for Gaussian Fitting min_sig=float(.6) ;Minimum standard deviation required to flag event read_num=123 Array_Dimension=2048. ;FILENAMES****************************************************** file_number_1=1 file_number_str_1=string(file_number_1,format='(I1)') file_number_2=5 file_number_str_2=string(file_number_2,format='(I1)') read_num_tot=125 readsstr=string(read_num_tot,format='(I3)') file_name_1='dark_37K_'+readsstr+'_min_1_0'+file_number_str_1+'.fits' file_name_2='dark_37K_'+readsstr+'_min_1_0'+file_number_str_2+'.fits' ;************************************************************ ;Open the file that statistics will be written to and make table header openw,1,'c:\H2RG_15_EVENTS\PSF'+file_number_str_1+'_'+file_number_str_2+'.txt',/append printf,1 ,"Data for difference between final reads in images" printf,1,FORMAT='(%"%s\n%s\n")',file_name_1,file_name_2 printf,1,FORMAT='(%"Background\tAmplitude\tX Pixel\t\tY Pixel\t\tSigmax\t\tSigmay\t\tSigmar\t\tFile_No")' printf,1 ,"-----------------------------------------------------------------------------------------------------------------------------" ;Enter the directory that holds the dark current files for the device cd,'\\Rabbit\raid1\Rockwell4\H2RG-015-5.0mu\cold1\dktest.16May03' ;If the absolute value of the difference between two images is greater than ;Threshold, flag it is a possible cosmic ray. This method will hopefully eliminate ;hot pixels. The array_indices will be returned ;Vectors for successive reads for first image fits_read,file_name_1,x11,first=long(read_num*numpixrd),last=long((read_num+1)*numpixrd)-1 ;Vectors for successive reads for second image fits_read,file_name_2,x21,first=long(read_num*numpixrd),last=long((read_num+1)*numpixrd)-1 ;For last read, generate image to use for overall events ;if read_num eq (read_num_tot-3) then begin im1=reform(float(x11),2048.,2048.) im2=reform(float(x21),2048.,2048.) diff=float(im2-im1) filename='C:\H2RG_15_EVENTS\dktest.16May03\final_read_diff_'+file_number_str_1+file_number_str_2+'.fits' writefits,filename,diff ;Difference vectors for first and second images. Subtract first read twice; once for each read ;diff1_vec=float(x12-x11) ;diff2_vec=float(x22-x21) ;Get difference between image differentials ;diff_ramp_vec=float(diff2_vec-diff1_vec) ;diff_ramp_arr=reform(float(diff_ramp_vec),2048.,2048.) diff(where(diff lt 0))=0. ;writefits,'C:\dif12.fits',diff_ramp_arr ;tv,bytscl(congrid(diff_ramp_arr,1024,1024),min=-1000,max=1000) ;Try doing math with vectors and then finally making an array total_cosm_vector=where(diff ge 0) poss_cosm_vector=where(diff gt threshold) print,poss_cosm_vector poss_cosm_size=size(poss_cosm_vector) length=long(poss_cosm_size(1)-1) print,length for j=0,length do begin if poss_cosm_vector(j) gt Array_Dimension then begin center=long(poss_cosm_vector(j)) left=long(poss_cosm_vector(j)-1) right=long(poss_cosm_vector(j)+1) upper_left=long(poss_cosm_vector(j)-Array_Dimension-1) upper=long(poss_cosm_vector(j)-Array_Dimension) upper_right=long(poss_cosm_vector(j)-Array_Dimension+1) lower_left=long(poss_cosm_vector(j)+Array_Dimension-1) lower=long(poss_cosm_vector(j)+Array_Dimension) lower_right=long(poss_cosm_vector(j)+Array_Dimension+1) ;Defined 3x3 box to of pixel indices. Check to see whether all of them ;are greater than threshold if ((diff(right) gt threshold) and (diff(left) gt threshold)) then begin if ((diff(upper_left) gt threshold) and (diff(upper) gt threshold) and (diff(upper_right) gt threshold)) then begin if ((diff(lower_left) gt threshold) and (diff(lower) gt threshold) and (diff(lower_right) gt threshold)) then begin large_cosm=array_indices(diff,center) print,large_cosm print,"found adjacent" endif endif endif endif endfor ;At this point I can use the following commented commands to see what ;im1 and im2 look like ;tv,bytscl(congrid(im2,1024,1024)) ;tv,bytscl(congrid(im,1024,1024)) ; ;and their difference ;tv,bytscl(congrid(im-im2,1024,1024),min=-100,max=100) ; ;writefits,'C:\H2RG_015_Events\bif16.fits',im-im2 ;Once we find a good pixel with an event, we should look at how the charge evolved ;over the reads. The following commented code will allow that: ; ;imcube6=readfits('dark_37K_125_min_1_06.fits') ;tv,bytscl(im(*,*,0),min=-100,max=100) ;just for a look ;tv,bytscl(im(*,*,0),min=-100,max=100) ;Plot history of one pixel over time close,1 ;Since x and x2 are one-dimensional vectors, we need to turn them into 2-dimensional ;arrays where the size of each dimension is 2048 end