;xy_offsets ; ;PURPOSE: ; This script will calculate the covariances of the ShackHartman images ; using the distorted grid obtained by averaging all of the positions. pro newest_x_offset_histogram,Date=Date,stats_directory=stats_directory,$ x_center_file=x_center_file,y_center_file=y_center_file,$ depth=depth,x_off=x_off,y_off=y_off,type=type If (not keyword_set(Date)) then Date='10' If (not keyword_set(stats_directory)) then stats_directory='stats' If (not keyword_set(x_center_file)) then x_center_file='newest_x_centers.txt' If (not keyword_set(y_center_file)) then y_center_file='newest_y_centers.txt' If (not keyword_set(depth)) then depth=1 If (not keyword_set(postscript_dir)) then postscript_dir='distorted_postscripts' If (not keyword_set(x_off)) then x_off=0 If (not keyword_set(y_off)) then y_off=0 If (not keyword_set(type)) then type='x_row' stats_directory='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+Date+$ '/ShackHartman/'+stats_directory+'/' postscript_dir='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+Date+$ '/ShackHartman/'+postscript_dir+'/' ;ARRAYS OF FILES offset_files=file_search(stats_directory+'*5132*newest_offsets.txt',count=num_stats_files) ;CONSTANTS num=25 grid_spots=625 index=findgen(625) ;ARRAY REFERENCE 25x25=625 FOR GRID subx=2*indgen(num)-25 ;The x-reference numbers suby=indgen(num)-12 ;The y-reference numbers ;HUGE DATA CUBE x_offset_hor=fltarr(num_stats_files,grid_spots) y_offset_hor=fltarr(num_stats_files,grid_spots) x_offset_ver=fltarr(num_stats_files,grid_spots) y_offset_ver=fltarr(num_stats_files,grid_spots) ;Correlations Cxt_full=fltarr(num_stats_files,num,depth) Cxl_full=fltarr(num_stats_files,num,depth) Cyt_full=fltarr(num_stats_files,num,depth) Cyl_full=fltarr(num_stats_files,num,depth) ;FILL THE DATA CUBES for file_number=0,num_stats_files-1 do begin ;Take the results from the offset.txt files and fill the cube readcol,offset_files(file_number),x_offset,y_offset,format='X,X,f,X,f' ;Obtain the difference ordered in COLUMN, ROW between centroid and grid point if type eq 'x_row' then begin x_offset_hor(file_number,*)=x_offset postscript_name='X_Offset_Row_Histograms.ps' plottitle='X Offsets for Row' endif else if type eq 'y_row'then begin x_offset_hor(file_number,*)=y_offset postscript_name='Y_Offset_Row_Histograms.ps' plottitle='Y Offsets for Row' endif else if type eq 'x_col' then begin x_offset_hor(file_number,*)=x_offset((index mod 25)*25+index/25) postscript_name='X_Offset_Column_Histograms.ps' plottitle='X Offsets for Column' endif else if type eq 'y_col' then begin x_offset_hor(file_number,*)=y_offset((index mod 25)*25+index/25) postscript_name='Y_Offset_Column_Histograms.ps' plottitle='Y Offsets for Column' endif endfor set_plot,'ps' device,filename=Postscript_dir+postscript_name loadct,39 ;load color table 39 device,/color ;allow color on the postscript device,ysize=8.5,/inches ;Height of plot in y device,xsize=10.0,/inches ;Width of plot in x device,yoffset=1.0,/inches ;Y position of lower left corner white='FFFFFF'x black='000000'x !P.CHARSIZE=.7 !P.THICK=4. !p.multi=[0,1,2] for i=0,grid_spots-1 do begin if ((i mod 25) eq 0) then begin plot,[0,file_number],[-6,6],/nodata,$ xtitle='File Number',ytitle='Offset (Pixels)',$ xrange=[0,file_number],yrange=[-6,6],$ title=Plottitle+strtrim(i/25,2) valid_spots=lonarr(25) valid_spot_index=0 num_good_spots=lonarr(25) endif else begin test=where(x_offset_hor(*,i) eq -10,ncomplement=found_spots) if (N_elements(test) ne num_stats_files) then begin oplot,x_offset_hor(*,i),color=10*(i mod 25) valid_spots(valid_spot_index)=i num_good_spots(valid_spot_index)=found_spots valid_spot_index=valid_spot_index+1 endif endelse if (((i mod 25) eq 24) or (i eq 624)) then begin good_spots=where(valid_spots ne 0) if (good_spots(0) ne -1) then begin num_good_spots=num_good_spots(good_spots) valid_spots=valid_spots(good_spots) real_good_spots=x_offset_hor(*,(i-24):i) really_good_spots=real_good_spots(where(real_good_spots ne -10)) meanx=mean(really_good_spots) variancex=variance(really_good_spots) xoffset_max=ceil(max(really_good_spots))+1 xoffset_min=floor(min(really_good_spots))-1 xoffset_hist=histogram(really_good_spots,nbins=60,$ max=xoffset_max-1,min=xoffset_min+1,locations=xoff_locations) plot,xoff_locations,xoffset_hist,psym=10,xtitle='offsets',$ xrange=[-6,6],yrange=[0,1800],ytitle='Number',$ color=black,background=white xyouts,.7,.2,'Mean='+strtrim(meanx,2),/normal xyouts,.7,.25,'Variance='+strtrim(variancex,2),/normal xyouts,.1,.46,'Index Number',/normal for j=0, N_elements(valid_spots)-1 do begin xyouts,.1,.44-.0175*j,strtrim(valid_spots(j),2),/normal xyouts,.15,.44-.0175*j,strtrim(num_good_spots(j),2),/normal endfor endif else begin plot,[-6,6],[0,5000],/nodata endelse endif endfor device,/close set_plot,'x' stop end