Index: trunk/psastro/src/psastroConvert.c
===================================================================
--- trunk/psastro/src/psastroConvert.c	(revision 26259)
+++ trunk/psastro/src/psastroConvert.c	(revision 26897)
@@ -1,5 +1,5 @@
 /** @file psastroConvert.c
  *
- *  @brief 
+ *  @brief
  *
  *  @ingroup libpsastro
@@ -47,7 +47,9 @@
 
     // PSPHOT.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)
-    psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
-    if (sources == NULL)
-        return false;
+    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
+    psAssert (detections, "missing detections?");
+
+    psArray *sources = detections->allSources;
+    psAssert (sources, "missing sources?");
 
     // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?)
@@ -61,13 +63,13 @@
     // XXX need to exit gracefully is inStars->n is 0 (or 1?)
 
-    // we are going to select the brighter Nmax subset for astrometry 
+    // we are going to select the brighter Nmax subset for astrometry
     int nMax = psMetadataLookupS32 (&status, recipe, "PSASTRO.MAX.NRAW");
     if (!status || !nMax) nMax = inStars->n;
 
-    // we are going to select the brighter Nmax subset for astrometry 
+    // we are going to select the brighter Nmax subset for astrometry
     float iMagMax = psMetadataLookupF32 (&status, recipe, "PSASTRO.MAX.INST.MAG.RAW");
     float iMagMin = psMetadataLookupF32 (&status, recipe, "PSASTRO.MIN.INST.MAG.RAW");
 
-    // we are going to select the brighter Nmax subset for astrometry 
+    // we are going to select the brighter Nmax subset for astrometry
     pmSourceMode skip = PM_SOURCE_MODE_DEFAULT;
     char *ignoreList = psMetadataLookupStr (&status, recipe, "PSASTRO.IGNORE");
@@ -75,10 +77,10 @@
       psArray *list = psStringSplitArray (ignoreList, ",", false);
       for (int i = 0; i < list->n; i++) {
-	pmSourceMode mode = pmSourceModeFromString (list->data[i]);
-	if (mode == PM_SOURCE_MODE_DEFAULT) {
-	  psWarning ("unknown source mode in PSASTRO.IGNORE, skipping");
-	  continue;
-	}
-	skip |= mode;
+        pmSourceMode mode = pmSourceModeFromString (list->data[i]);
+        if (mode == PM_SOURCE_MODE_DEFAULT) {
+          psWarning ("unknown source mode in PSASTRO.IGNORE, skipping");
+          continue;
+        }
+        skip |= mode;
       }
       psFree (list);
@@ -97,30 +99,30 @@
 
     for (int i = 0; (i < inStars->n) && (j < rawStars->n); i++) {
-	int n = index->data.S32[i];
-	pmSource *source = sources->data[n];
+        int n = index->data.S32[i];
+        pmSource *source = sources->data[n];
 
         psTrace ("psastro", 6, "mag: %f +/- %f, mode: %x, skip: %x\n", source->psfMag, source->errMag, source->mode, skip);
 
-	if (source->mode & skip) { 
-	  nModeSkip ++;
-	  continue;
-	}
+        if (source->mode & skip) {
+          nModeSkip ++;
+          continue;
+        }
 
-	if ((iMagMax != 0.0) && (source->psfMag > iMagMax)) {
-	  nFaintSkip ++;
-	  continue;
-	}
-	if ((iMagMin != 0.0) && (source->psfMag < iMagMin)) {
-	  nBrightSkip ++;
-	  continue;
-	}
-	if (!isfinite(source->psfMag)) {
-	  nInfSkip ++;
-	  continue;
-	}
-	mMin = PS_MIN (mMin, source->psfMag);
-	mMax = PS_MAX (mMax, source->psfMag);
-	rawStars->data[j] = psMemIncrRefCounter (inStars->data[n]);
-	j++;
+        if ((iMagMax != 0.0) && (source->psfMag > iMagMax)) {
+          nFaintSkip ++;
+          continue;
+        }
+        if ((iMagMin != 0.0) && (source->psfMag < iMagMin)) {
+          nBrightSkip ++;
+          continue;
+        }
+        if (!isfinite(source->psfMag)) {
+          nInfSkip ++;
+          continue;
+        }
+        mMin = PS_MIN (mMin, source->psfMag);
+        mMax = PS_MAX (mMax, source->psfMag);
+        rawStars->data[j] = psMemIncrRefCounter (inStars->data[n]);
+        j++;
     }
     rawStars->n = j;
@@ -147,5 +149,5 @@
 
         // only accept the PSF sources?
-	// XXX drop SATSTAR?
+        // XXX drop SATSTAR?
         // if (source->type != PM_SOURCE_TYPE_STAR) continue;
 
@@ -154,5 +156,5 @@
 
         psF32 *PAR = model->params->data.F32;
-	psF32 *dPAR = model->dparams->data.F32;
+        psF32 *dPAR = model->dparams->data.F32;
 
         pmAstromObj *obj = pmAstromObjAlloc ();
