Index: trunk/psastro/src/psastroChooseRefstars.c
===================================================================
--- trunk/psastro/src/psastroChooseRefstars.c	(revision 9627)
+++ trunk/psastro/src/psastroChooseRefstars.c	(revision 9732)
@@ -11,6 +11,6 @@
     psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, "PSASTRO");
     if (!recipe) {
-	psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");
-	return false;
+        psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");
+        return false;
     }
 
@@ -18,9 +18,9 @@
     pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
     if (!input) {
-	psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n");
-	return false;
+        psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n");
+        return false;
     }
 
-    float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA"); 
+    float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA");
     if (!status) fieldExtra = 0.0;
 
@@ -32,56 +32,56 @@
         psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
         if (!chip->process || !chip->file_exists) { continue; }
-	
-	while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
+
+        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
             psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
             if (!cell->process || !cell->file_exists) { continue; }
 
-	    // process each of the readouts
-	    // XXX there can only be one readout per chip in astrometry, right?
-	    while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
-		if (! readout->data_exists) { continue; }
+            // process each of the readouts
+            // XXX there can only be one readout per chip in astrometry, right?
+            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
+                if (! readout->data_exists) { continue; }
 
-		// read WCS data from the corresponding header
-		pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
+                // read WCS data from the corresponding header
+                pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
 
-		int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1"); 
-		int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2"); 
+                int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1");
+                int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2");
 
-		float minX = -fieldExtra*Nx;
-		float maxX = (1+fieldExtra)*Nx;
-		float minY = -fieldExtra*Ny;
-		float maxY = (1+fieldExtra)*Ny;
+                float minX = -fieldExtra*Nx;
+                float maxX = (1+fieldExtra)*Nx;
+                float minY = -fieldExtra*Ny;
+                float maxY = (1+fieldExtra)*Ny;
 
-		// the refstars is a subset within range of this chip
-		psArray *refstars = psArrayAlloc (100);
+                // the refstars is a subset within range of this chip
+                psArray *refstars = psArrayAllocEmpty (100);
 
-		// select the reference objects within range of this readout
-		// project the reference objects to this chip
-		for (int i = 0; i < refs->n; i++) {
-		    pmAstromObj *ref = pmAstromObjCopy(refs->data[i]);
-	
-		    // XXX why is this still a private function?
-		    p_psProject (ref->TP, ref->sky, fpa->projection);
-		    psPlaneDistortApply (ref->FP, fpa->fromTangentPlane, ref->TP, 0.0, 0.0);
-		    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
+                // select the reference objects within range of this readout
+                // project the reference objects to this chip
+                for (int i = 0; i < refs->n; i++) {
+                    pmAstromObj *ref = pmAstromObjCopy(refs->data[i]);
 
-		    // limit the X,Y range of the refs to the selected chip
-		    if (ref->chip->x < minX) goto skip;
-		    if (ref->chip->x > maxX) goto skip;
-		    if (ref->chip->y < minY) goto skip;
-		    if (ref->chip->y > maxY) goto skip;
+                    // XXX why is this still a private function?
+                    p_psProject (ref->TP, ref->sky, fpa->projection);
+                    psPlaneDistortApply (ref->FP, fpa->fromTangentPlane, ref->TP, 0.0, 0.0);
+                    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
 
-		    psArrayAdd (refstars, 100, ref);
-		skip:
-		    psFree (ref);
-		}
-		psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n);
+                    // limit the X,Y range of the refs to the selected chip
+                    if (ref->chip->x < minX) goto skip;
+                    if (ref->chip->x > maxX) goto skip;
+                    if (ref->chip->y < minY) goto skip;
+                    if (ref->chip->y > maxY) goto skip;
 
-		psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);
-		psFree (refstars);
+                    psArrayAdd (refstars, 100, ref);
+                skip:
+                    psFree (ref);
+                }
+                psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n);
 
-		psastroRefstarSubset (readout);
-	    }
-	}
+                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);
+                psFree (refstars);
+
+                psastroRefstarSubset (readout);
+            }
+        }
     }
 
