pro Puffy_Events_star_region_ndb_counts ;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 ;The program first finds all pixels that have a count greater than THRESHOLD and flags them. Next it ;looks at symmetric regions (star-shaped regions of radius r, where the star approaches a circle as r ;goes to infinity) and checks to see if all the pixels in that region are greater than THRESHOLD. If so ;that event is logged in logfile and all of the pixels are set to zero so that it will not be double counted. ; ; ; ; ;CONSTANTS******************************************************. ;Force some to be floating point integers numpixrd=2048.*2048. ;Size of device Array_Dimension=2048. ;Array Dimension THRESHOLD=100 ;THRESHOLD to flag pixel as Cosmic Ray THRESHOLD_str=string(THRESHOLD,format='(I3)') 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 ;Number of read to use for ramp difference large_cosm_ind_x=[0] ;X Pixel value Array to be Appended large_cosm_ind_y=[0] ;Y Pixel value Array to be Appended max_radius=5 ;Maximum size of region ;FILENAMES****************************************************** Directory='dktest.9May03' file_number_1=5 file_number_str_1=string(file_number_1,format='(I1)') file_number_2=1 file_number_str_2=string(file_number_2,format='(I1)') temp=26 temp_str=string(temp,format='(I2)') read_num_tot=250 readsstr=string(read_num_tot,format='(I3)') ;file_name_1='dark_'+temp_str+'K_'+readsstr+'_min_1_0'+file_number_str_1+'.fits' ;file_name_2='dark_'+temp_str+'K_'+readsstr+'_min_1_0'+file_number_str_2+'.fits' logfile='c:\H2RG_15_EVENTS\'+THRESHOLD_str+'star.txt' ;************************************************************ ;Open the file that statistics will be written to and make table header openw,1,logfile,/append ;Enter the directory that holds the dark current files for the device cd,'\\Rabbit\raid1\Rockwell4\H2RG-015-5.0mu\cold1\'+Directory for ramp_num=2,6 do begin if ramp_num gt 2 then begin ramp2_str=string(ramp_num,format='(I1)') ramp1_str=string(2,format='(I1)') endif else begin ramp2_str=string(2,format='(I1)') ramp1_str=string(3,format='(I1)') endelse file_name_1='dark_'+temp_str+'K_'+readsstr+'_min_1_0'+ramp2_str+'.fits' file_name_2='dark_'+temp_str+'K_'+readsstr+'_min_1_0'+ramp1_str+'.fits' ;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) diff(where(diff lt 0))=0. filename='C:\H2RG_15_EVENTS\'+Directory+'_final_read_diff_'+'_'+temp_str+'K_'+readsstr+'Reads_'+ramp1_str+'_'+ramp2_str+'.fits' Index_string=Directory+'_'+temp_str+'K_'+readsstr+'_'+ramp2_str+'_'+ramp1_str writefits,filename,diff for radius=8,1,-1 do begin gt_thresh=where(diff gt THRESHOLD,length_1) print,size(gt_thresh) for i=double(0),(length_1-1) do begin if ((gt_thresh(i) gt radius*array_dimension) and (gt_thresh(i) lt (array_dimension-radius)*array_dimension) $ and ((gt_thresh(i) mod array_dimension) gt radius) and ((gt_thresh(i) mod array_dimension) lt (array_dimension-radius))) then begin found_less=0 for xy_radius=(-radius),radius do begin for diag_radius=(-radius+abs(xy_radius)),(radius-abs(xy_radius)) do begin if ( (diff(long(gt_thresh(i)+long(xy_radius*array_dimension)+diag_radius)) lt THRESHOLD) $ or (diff(long(gt_thresh(i)+long(xy_radius*array_dimension)+diag_radius)) gt diff(gt_thresh(i)))) then begin found_less=1 break endif endfor if (found_less eq 1) then begin break endif endfor if (found_less eq 0) then begin act_radius=radius+1 if act_radius gt 0 then begin star_indices=array_indices(diff,gt_thresh(i)) print,'act radius',act_radius printf,1,FORMAT='(%"%d\t\t%d\t\t%d\t\t%s")',act_radius,star_indices(0),star_indices(1),Index_string for xy_radius=(-radius),radius do begin for diag_radius=(-radius+abs(xy_radius)),(radius-abs(xy_radius)) do begin diff(long(gt_thresh(i)+long(xy_radius*array_dimension)+diag_radius))=0 endfor endfor endif endif endif endfor endfor endfor close,1 end