pro Puffy_Events_03 ;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=2000 ;Threshold to flag pixel as Cosmic Ray ;j=long(0) ;Open the file that statistics will be written to and make table header ; ;openw,1,"c:\PSF.txt",/append 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' for read_number=4,124 do begin print,read_number ;Take in the last two reads of a given file and get the difference between them fits_read,'dark_37K_125_min_1_01.fits',x,first=long((read_number-1)*numpixrd),last=long(read_number*numpixrd)-1 fits_read,'dark_37K_125_min_1_01.fits',x2,first=long(read_number*numpixrd),last=long((read_number+1)*numpixrd)-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 im=reform(float(x),2048.,2048.) im2=reform(float(x2),2048.,2048.) diff=float(im2-im) print, size(diff) ;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 poss_cosm_vector=where(abs(diff) gt threshold) if poss_cosm_vector(0) ne -1 then begin poss_cosm_indices=array_indices(diff,poss_cosm_vector) poss_cosm_size=size(poss_cosm_indices) print,poss_cosm_size(0) if poss_cosm_size(0) eq 1 then begin length=0 endif else begin length=long(poss_cosm_size(2)-1) print,length endelse for j=0,length do begin ;Define the Area With which to fit the Gaussian around (x_pix,y_pix) ;Deal with Left Border, Center values, then Right Border x_pix=poss_cosm_indices(0,j) ;Left Border if x_pix lt 5 then begin xstart=0 xfinish=xstart+9 x=findgen(10)+xstart endif ;Center Values if x_pix ge 5 and x_pix le 2043 then begin xstart=poss_cosm_indices(0,j)-5 xfinish=xstart+9 x=findgen(10)+xstart print,xstart print,xfinish endif ;Right Border if xstart gt 2044 then begin xfinish=2047 xstart=xfinish-9 x=findgen(10)+xstart endif ;Deal with Upper Border, Center Values, then Lower Border y_pix=poss_cosm_indices(1,j) ;Upper Border if y_pix lt 5 then begin ystart=0 yfinish=ystart+9 y=findgen(10)+ystart endif ;Center Values if y_pix ge 5 and y_pix le 2043 then begin ystart=poss_cosm_indices(1,j)-5 yfinish=ystart+9 y=findgen(10)+ystart endif ;Lower Border if ystart gt 2044 then begin yfinish=2047 ystart=yfinish-9 y=findgen(10)+ystart endif gauss_area=diff(xstart:xfinish,ystart:yfinish) my_gauss_elip=mpfit2dpeak(gauss_area,gauss_elip_params,x,y) my_gauss_circ=mpfit2dpeak(gauss_area,gauss_circ_params,x,y,/circular) ;printf,1,gauss_elip_params(0),gauss_elip_params(1),gauss_elip_params(2),gauss_elip_params(3),gauss_circ_params(2),name, FORMAT='(3F0)' printf,1,FORMAT='(%"%d\t\t%d\t\t%4.0f\t\t%4.0f\t\t%6.4f\t\t%6.4f\t\t%6.4f")',gauss_elip_params(0),gauss_elip_params(1),gauss_elip_params(4),gauss_elip_params(5),gauss_elip_params(2),gauss_elip_params(3),gauss_circ_params(2) print,gauss_elip_params print,gauss_circ_params endfor endif ;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) ; endfor 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 end