pro fiducial, Directory=Directory, filename=filename

x_ref_col=[225,250,278,302,332,353,380,404,428,452,476,502,528,554,578,604,630,$
        654,680,704,730,754,780,806,832]
y_ref_col=[164,188,214,238,264,290,314,340,366,390,414,440,464,490,516,542,568,$
        592,616,642,668,692,718,742,768]

If (not keyword_set(Directory)) then Directory='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-11/ShackHartman/coo/'
If (not keyword_set(filename)) then filename=Directory+'reference_grid.txt'

y_length=n_elements(y_ref_col)
x_length=n_elements(x_ref_col)

get_lun,coo
openw,coo,filename

grid_points=fltarr(3,x_length*y_length)

for y=0,y_length-1 do begin
	for x=0,x_length-1 do begin
		
		grid_points(0,y*y_length+x)=x_ref_col(x)
		grid_points(1,y*y_length+x)=y_ref_col(y)
		grid_points(2,y*y_length+x)=y*y_length+x
		printf,coo,x_ref_col(x),y_ref_col(y),y*y_length+x,format='(f,f,f)'

	
	endfor
endfor

spider_ind=13*x_length+findgen(25)

close,coo
free_lun,coo

;Here are the ID numbers of the grid points that will not be included in the 
;fiducial region

non_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]

non_fiducial=non_fiducial-1

complement,grid_points(2,*),non_fiducial,fiducial_sub_scripts

fiducial_x=grid_points(0,fiducial_sub_scripts)
fiducial_y=grid_points(1,fiducial_sub_scripts)
fiducial_index=grid_points(2,fiducial_sub_scripts)

get_lun,coo1
openw,coo1,Directory+'fiducial_reference.txt'

for j=0, n_elements(fiducial_x(0,*)) -1 do begin

	printf,coo1,fiducial_x(j),fiducial_y(j),fiducial_index(j),$
		format='(d,d,i)'
endfor

close,coo1
free_lun,coo1

stop

end

