Index: trunk/psastro/src/pmAstrom.c
===================================================================
--- trunk/psastro/src/pmAstrom.c	(revision 5560)
+++ trunk/psastro/src/pmAstrom.c	(revision 5565)
@@ -13,102 +13,16 @@
 }
 
-psPlane *psCoordReadoutToCell (psPlane *cellpix, psPlane *readpix, pmReadout *readout) {
-
-    if (cellpix == NULL) {
-	cellpix = psPlaneAlloc ();
-    }
-
-    cellpix->x = readpix->x*readout->colBins + readout->col0;
-    cellpix->y = readpix->y*readout->rowBins + readout->row0;
-
-    return (cellpix);
-}
-
-psPlane *psCoordCellToReadout (psPlane *readpix, psPlane *cellpix, pmReadout *readout) {
-
-    if (readpix == NULL) {
-	readpix = psPlaneAlloc ();
-    }
-
-    readpix->x = (cellpix->x - readout->col0) / readout->colBins;
-    readpix->y = (cellpix->y - readout->row0) / readout->rowBins;
-
-    return (readpix);
-}
-
-psPlane* psCoordChipToCell_EAM(psPlane* cellCoord,
-                           const psPlane* chipCoord,
-                           const pmCell* cell)
+// sort by mag (descending)
+int pmAstromObjSortByMag (const void **a, const void **b)
 {
-    PS_ASSERT_PTR_NON_NULL(chipCoord, NULL);
-    PS_ASSERT_PTR_NON_NULL(cell, NULL);
-    PS_ASSERT_PTR_NON_NULL(cell->parent, NULL);
-
-    // XXX EAM : why was this being done?
-    // pmCell *tmpCell = pmCellInChip(chipCoord, cell->parent);
-    PS_ASSERT_PTR_NON_NULL(cell->toChip, NULL);
-    psPlaneTransform *tmpChipToCell = p_psPlaneTransformLinearInvert(cell->toChip);
-    PS_ASSERT_PTR_NON_NULL(tmpChipToCell, NULL);
-    cellCoord = psPlaneTransformApply(cellCoord, tmpChipToCell, chipCoord);
-    psFree(tmpChipToCell);
-    return(cellCoord);
-}
-
-bool psastroProjectFPA (pmFPA *fpa, char *starlist, bool toSky) {
-
-    bool status;
-
-    for (int i = 0; i < fpa->chips->n; i++) {
-	pmChip *chip = fpa->chips->data[i];
-	for (int j = 0; j < chip->cells->n; j++) {
-	    pmCell *cell = chip->cells->data[j];
-	    for (int k = 0; k < cell->readouts->n; k++) {
-		pmReadout *readout = cell->readouts->data[k];
-		psArray *stars = psMetadataLookupPtr (&status, readout->analysis, starlist);
-		if (toSky) {
-		    psastroProjectRawstars (stars, readout);
-		} else {
-		    psastroProjectRefstars (stars, readout);
-		}
-	    }
-	}
-    }
-    return true;
-}
- 
-bool psastroProjectRawstars (psArray *stars, pmReadout *readout) {
-
-    pmCell *cell = readout->parent;
-    pmChip *chip = cell->parent;
-    pmFPA  *fpa  = chip->parent;
-
-    for (int i = 0; i < stars->n; i++) {
-	pmAstromObj *star = stars->data[i];
-	psCoordReadoutToCell (&star->cell, &star->pix, readout);
-	psCoordCellToChip (&star->chip, &star->cell, cell);
-	psCoordChipToFPA (&star->FP, &star->chip, chip);
-	psCoordFPAToTP (&star->TP, &star->FP, 0.0, 0.0, fpa);
-	psCoordTPToSky (&star->sky, &star->TP, fpa->projection);
-    }
-    return true;
-}
- 
-bool psastroProjectRefstars (psArray *stars, pmReadout *readout) {
-
-    pmCell *cell = readout->parent;
-    pmChip *chip = cell->parent;
-    pmFPA  *fpa  = chip->parent;
-
-    for (int i = 0; i < stars->n; i++) {
-	pmAstromObj *star = stars->data[i];
-	psCoordSkyToTP (&star->TP, &star->sky, fpa->projection);
-	psCoordTPToFPA (&star->FP, &star->TP, 0.0, 0.0, fpa);
-	psCoordFPAToChip (&star->chip, &star->FP, chip);
-	psCoordChipToCell_EAM (&star->cell, &star->chip, cell);
-	psCoordCellToReadout (&star->pix, &star->cell, readout);
-    }
-    return true;
-}
- 
+    pmAstromObj *A = *(pmAstromObj **)a;
+    pmAstromObj *B = *(pmAstromObj **)b;
+
+    psF32 diff = A->Mag - B->Mag;
+    if (diff > FLT_EPSILON) return (-1);
+    if (diff < FLT_EPSILON) return (+1);
+    return (0);
+}
+
 psArray *pmAstromRadiusMatch (psArray *st1, psArray *st2, psMetadata *config) {
 
