Index: trunk/psphot/src/psModulesUtils.c
===================================================================
--- trunk/psphot/src/psModulesUtils.c	(revision 6522)
+++ trunk/psphot/src/psModulesUtils.c	(revision 6571)
@@ -1,232 +1,3 @@
 # include "psModulesUtils.h"
-
-// extract config informatin from config data or from image header, if specified
-// XXX EAM : this function should be replaced with Paul's image/header/metadata load scheme
-psF32 pmConfigLookupF32 (bool *status, psMetadata *config, psMetadata *header, char *name) {
-
-    char *source;
-    char *keyword;
-    psF32 value;
-    psMetadataItem *item;
-
-    // look for the entry in the config collection
-    item = psMetadataLookup (config, name);
-    if (item == NULL) {
-	psLogMsg ("pmConfigLookupF32", 2, "no key %s in config data, trying as header keyword", name);
-	value = psMetadataLookupF32 (status, header, name);
-	if (*status == false) {
-	    psAbort ("pmConfigLookupF32", "no key %s in header", name);
-	}
-	*status = true;
-	return (value);
-    }	
-
-    // I'm either expecting a string, with the name "HD:keyword"...
-    if (item->type == PS_DATA_STRING) {
-	source = item->data.V;
-	if (!strncasecmp (source, "HD:", 3)) {
-	    keyword = &source[3]; 
-	    value = psMetadataLookupF32 (status, header, keyword);
-	    if (*status == false) {
-		psAbort ("pmConfigLookupF32", "no key %s in config", name);
-	    }
-	    *status = true;
-	    // psFree (item);
-	    return (value);
-	}	
-    }
-
-    //  ... or a value (F32?)
-    if (item->type == PS_DATA_F32) {
-	value = item->data.F32;
-	// psFree (item);
-	return (value);
-    }
-
-    *status = false;
-    psError(PS_ERR_UNKNOWN, true, "invalid item");
-    return (0);
-}
-
-bool pmModelFitStatus (pmModel *model) {
-
-    bool status;
-
-    pmModelFitStatusFunc statusFunc = pmModelFitStatusFunc_GetFunction (model->type);
-    status = statusFunc (model);
-
-    return (status);
-}
-
-pmModel *pmModelSelect (pmSource *source) {
-    switch (source->type) {
-      case PM_SOURCE_STAR:
-	return source->modelPSF;
-	
-      case PM_SOURCE_EXTENDED:
-	return source->modelEXT;
-	
-      default:
-	return NULL;
-    }
-    return NULL;
-}
-
-bool pmSourcePhotometry (float *fitMag, float *obsMag, pmModel *model, psImage *image, psImage *mask) {
-
-    float obsSum = 0;
-    float fitSum = 0;
-    float sky = model->params->data.F32[0];
-
-    *fitMag = 99.0;
-    *obsMag = 99.0;
-
-    pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type);
-    fitSum = modelFluxFunc (model->params);
-    if (fitSum <= 0) return false;
-    if (!isfinite(fitSum)) return false;
-    *fitMag = -2.5*log10(fitSum);
-
-    for (int ix = 0; ix < image->numCols; ix++) {
-	for (int iy = 0; iy < image->numRows; iy++) {
-	    if (mask->data.U8[iy][ix]) continue;
-	    obsSum += image->data.F32[iy][ix] - sky;
-	}
-    }
-    if (obsSum <= 0) return false;
-    *obsMag = -2.5*log10(obsSum);
-
-    return (true);
-} 
-
-// force the fitted sky to meet the source flux at outer radius 
-bool pmModelSkyOffset (pmModel *model, float x, float y, float radius) {
-
-    float flux;
-
-    psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
-
-    pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
-    psVector *params = model->params;
-  
-    coord->data.F32[0] = x + radius;
-    coord->data.F32[1] = y;
-    flux = modelFunc (NULL, params, coord);
-    params->data.F32[0] = flux;
-
-    psFree (coord);
-
-    return true;
-}
-
-pmModel *pmModelCopy (pmModel *model) {
-
-    pmModel *new = pmModelAlloc (model->type);
-    
-    new->chisq  = model->chisq;
-    new->nDOF   = model->nDOF;
-    new->nIter  = model->nIter;
-    new->status = model->status;
-    new->radius = model->radius;
-
-    for (int i = 0; i < new->params->n; i++) {
-        new->params->data.F32[i]  = model->params->data.F32[i];
-        new->dparams->data.F32[i] = model->dparams->data.F32[i];
-    }
-    
-    return (new);
-}
-
-float pmSourceCrossProduct (pmSource *Mi, pmSource *Mj) {
-
-    int Xs, Xe, Ys, Ye;
-    int xi, xj, yi, yj;
-    int xIs, xJs, yIs, yJs;
-    int xIe, yIe;
-    float flux, wt;
-
-    psImage *Pi = Mi->pixels;
-    psImage *Pj = Mj->pixels;
-
-    psImage *Wi = Mi->weight;
-
-    psImage *Ti = Mi->mask;
-    psImage *Tj = Mj->mask;
-
-    Xs = PS_MAX (Pi->col0, Pj->col0);
-    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
-    
-    Ys = PS_MAX (Pi->row0, Pj->row0);
-    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
-    
-    xIs = Xs - Pi->col0;
-    xJs = Xs - Pj->col0;
-    yIs = Ys - Pi->row0;
-    yJs = Ys - Pj->row0;
-
-    xIe = Xe - Pi->col0;
-    yIe = Ye - Pi->row0;
-
-    // note that this is addressing the same image pixels,
-    // though only if both are source not model images
-    flux = 0;
-    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
-	for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
-	    if (Ti->data.U8[yi][xi]) continue;
-	    if (Tj->data.U8[yj][xj]) continue;
-	    wt = Wi->data.F32[yi][xi];
-	    if (wt > 0) {
-		flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
-	    } 
-	}
-    }
-    return (flux);
-}
-
-float pmSourceCrossWeight (pmSource *Mi, pmSource *Mj) {
-
-    int Xs, Xe, Ys, Ye;
-    int xi, xj, yi, yj;
-    int xIs, xJs, yIs, yJs;
-    int xIe, yIe;
-    float flux, wt;
-
-    psImage *Pi = Mi->pixels;
-    psImage *Pj = Mj->pixels;
-
-    psImage *Wi = Mi->weight;
-
-    psImage *Ti = Mi->mask;
-    psImage *Tj = Mj->mask;
-
-    Xs = PS_MAX (Pi->col0, Pj->col0);
-    Xe = PS_MIN (Pi->col0 + Pi->numCols, Pj->col0 + Pj->numCols);
-    
-    Ys = PS_MAX (Pi->row0, Pj->row0);
-    Ye = PS_MIN (Pi->row0 + Pi->numRows, Pj->row0 + Pj->numRows);
-    
-    xIs = Xs - Pi->col0;
-    xJs = Xs - Pj->col0;
-    yIs = Ys - Pi->row0;
-    yJs = Ys - Pj->row0;
-
-    xIe = Xe - Pi->col0;
-    yIe = Ye - Pi->row0;
-
-    // note that this is addressing the same image pixels,
-    // though only if both are source not model images
-    flux = 0;
-    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
-	for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
-	    if (Ti->data.U8[yi][xi]) continue;
-	    if (Tj->data.U8[yj][xj]) continue;
-	    wt = Wi->data.F32[yi][xi];
-	    if (wt > 0) {
-		flux += 1.0 / wt;
-	    } 
-	}
-    }
-    return (flux);
-}
 
 static void ppConfigFree (ppConfig *config) {
