;PRO TESTCALIMAGE
;
;PURPOSE:
;	This script deals with the ShackHartmann test-calibration image.  It
;	is called TestCalImage.gs6 and opens with DS9.
;
;	The optimal coordinates of the grid and their offsets with respect to 
;	a 25-pixel-spaced uniform grid centered at the same center are printed
;	to a file
;
;CALLING SEQUENCE:
;	TestCalImage,[[Image_Dir],Stats_Dir]
;
;KEYWORDS:
;	Image_Dir: The directory in which TestCalImage.gs6 is stored
;	Stats_Dir: The directory where the coordinates and offset will be 
;		   written
;	DATE:      The string '10','11',or '12' corresponding to
;                  2005-05-10,2005-05-11, and 2005-05-12
;
;OUTPUS:
;	[stats_dir]/Calibrated_grid.txt
;

pro test_cal, Date=Date, Image_Dir=Image_Dir, Stats_Dir=Stats_Dir

If (not keyword_set(Date)) then Date='11'
If (not keyword_set(x_center)) then x_center=[542]
If (not keyword_set(y_center)) then y_center=[465]
If (not keyword_set(stats_dir)) then stats_dir='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+date+'/ShackHartman/stats/'
If (not keyword_set(image_dir)) then image_dir='/a/pippin01/Volumes/u08/lsst/CPanalysis/ShackHartmann_Cal/'


raw_file=image_dir+'TestCalImage.fits'
coo_file=image_dir+'TestCalImage.fits.coo.1'
mag_file=image_dir+'TestCalImage.fits.mag.1'

subx=2*indgen(num)-25           ;The x-reference numbers
suby=indgen(num)-12             ;The y-reference numbers
box=11                          ;The distance used for finding spot

fiducial=[1,2,3,4,5,6,7,8,18,19,20,21,22,23,24,25,$
          26,27,28,29,30,31,45,46,47,48,49,50,$
          51,52,53,54,55,72,73,74,75,$
          76,77,78,79,98,99,100,$
          101,102,103,123,124,125,$
          126,127,149,150,$
          151,152,174,175,$
          176,200,$
          201,225,$
          238,239,$
          261,262,263,264,265,266,$
          286,287,288,289,290,291,$
          301,302,303,304,305,306,307,308,309,$
          310,311,312,313,314,315,316,$
          317,318,319,320,321,322,323,324,325,$
          336,337,338,339,340,341,$
          361,362,363,364,365,366,$
          388,389,$
          401,425,$
          426,427,449,450,$
          451,452,452,473,474,475,$
          476,477,478,498,499,500,$
          501,502,503,504,522,523,524,525,$
          526,527,528,529,530,546,547,548,549,550,$
          551,552,553,554,555,556,570,571,572,573,574,575,$
          576,577,578,579,580,581,582,594,595,596,597,598,599,600,$
          601,602,603,604,605,606,607,608,609,617,618,619,620,621,$
          622,623,624,625]-1

;Figure out the new reference grid, applied around x_center and y_center
x_ref_col=12.5*subx+x_center[0]
y_ref_col=25.0*suby+y_center[0]

stop

end



