Index: trunk/psphot/src/psphotOutput.c
===================================================================
--- trunk/psphot/src/psphotOutput.c	(revision 6522)
+++ trunk/psphot/src/psphotOutput.c	(revision 6571)
@@ -1,153 +1,3 @@
 # include "psphot.h"
-
-static int   extNumber  = -1;
-
-static char *outputName = NULL;
-static char *outputRoot = NULL;
-static char *outputMode = NULL;
-static char *outputFormat = NULL;
-
-static char *extNumberFormat = NULL;
-static char *extNameKey = NULL;
-static char *extRoot    = NULL;
-static char *psfFile    = NULL;
-static char *psfSample  = NULL;
-
-static psFits *outputFits = NULL;
-static FILE   *outputFile = NULL;
-
-bool psphotDataIO (psphotData *data, ppConfig *config, int chip, int cell) {
-
-    // load input data, if depth is appropriate
-    ppImageLoadDepth loadDepth = ppImageCheckDepth (config->recipe, "LOAD.DEPTH");
-    if ((chip == -1) && (cell == -1) && (loadDepth == PP_LOAD_FPA)) {
-        psTrace(__func__, 1, "Loading pixels for FPA...\n");
-        ppImageLoadPixels(data->input, config->database, -1, -1);
-    }
-    if ((chip != -1) && (cell == -1) && (loadDepth == PP_LOAD_CHIP)) {
-	psTrace(__func__, 1, "Loading pixels for chip %d...\n", i);
-        ppImageLoadPixels(data->input, config->database, chip, -1);
-    }
-    if ((chip != -1) && (cell != -1) && (loadDepth == PP_LOAD_CELL)) {
-	psTrace(__func__, 1, "Loading pixels for chip %d, cell %d...\n", i, j);
-        ppImageLoadPixels(data->input, config->database, chip, cell);
-    }
-
-
-
-    if (saveDepth == PP_LOAD_FPA) {
-        psTrace(__func__, 1, "Saving objects for FPA...\n");
-        psphotOutputOpen (file->fpa->phu);
-    }
-
-    ppImageLoadDepth saveDepth = ppImageCheckDepth (config->recipe, "SAVE.DEPTH");
-    
-
-}
-
-void psphotOutputPrep (ppFile *file, ppConfig *config) {
-
-    bool status;
-
-    outputRoot      = psMetadataLookupStr (&status, config->arguments, "OUTPUT_ROOT");
-    if (!status) psAbort ("psphot", "output file not specified");
-
-    outputName      = psMetadataLookupStr (&status, config->recipe, "OUTPUT_NAME");
-    outputMode      = psMetadataLookupStr (&status, config->recipe, "OUTPUT_MODE");
-    outputFormat    = psMetadataLookupStr (&status, config->recipe, "OUTPUT_FORMAT");
-
-    psfFile         = psMetadataLookupStr (&status, config->recipe, "PSF_OUTPUT_FILE");
-    psfSample       = psMetadataLookupStr (&status, config->recipe, "PSF_SAMPLE_FILE");
-
-    // rules to construct output names
-    extNumberFormat = psMetadataLookupStr (&status, config->recipe, "EXTNUMBER_FORMAT");
-    extNameKey      = psMetadataLookupStr (&status, config->recipe, "EXTNAME");
-    extRoot         = psMetadataLookupStr (&status, config->recipe, "EXTROOT");
-
-    headExtname     = psMetadataLookupStr (&status, config->recipe, "HEAD_EXTNAME");
-    dataExtname     = psMetadataLookupStr (&status, config->recipe, "DATA_EXTNAME");
-
-    if (extNumberFormat == NULL) {
-	extNumberFormat = psStringCopy ("%02d");
-    }
-
-    psStringStrip (outputName);
-    psStringStrip (extNameKey);
-    psStringStrip (extRoot);
-
-    // validate the outputMode and outputFormat
-    status = false;
-    status |= !strcasecmp (outputFormat, "TEXT");
-    status |= !strcasecmp (outputFormat, "OBJ");
-    status |= !strcasecmp (outputFormat, "SX");
-    status |= !strcasecmp (outputFormat, "CMP");
-    status |= !strcasecmp (outputFormat, "CMF");
-    if (!status) {
-	psLogMsg ("psphot", PS_LOG_ERROR, "invalid output format %s", outputFormat);
-	exit (1);
-    }
-
-    // validate the outputMode and outputFormat
-    status = false;
-    status |= !strcasecmp (outputMode, "MEF");
-    status |= !strcasecmp (outputMode, "SPLIT");
-    if (!status) {
-	psLogMsg ("psphot", PS_LOG_ERROR, "invalid output mode %s", outputMode);
-	exit (1);
-    }
-
-    // for MEF output, we only allow certain output formats
-    if (!strcasecmp (outputMode, "MEF")) {
-	if (!strcasecmp (outputFormat, "CMF")) goto valid_format;
-	psLogMsg ("psphot", PS_LOG_ERROR, "MEF output mode unavailable");
-	exit (1);
-    }
-valid_format:
-
-    // register background image-file names
-    psphotBackgroundNames (config->arguments);
-
-    // save so freeing config will not drop these references
-    psMemCopy (outputRoot);
-    psMemCopy (outputName);
-    psMemCopy (outputMode);
-    psMemCopy (outputFormat);
-    psMemCopy (extNumberFormat);
-    psMemCopy (extNameKey);
-    psMemCopy (extRoot);
-    psMemCopy (psfFile);
-    psMemCopy (psfSample);
-
-    return;
-}
-
-bool psphotOutputOpen (psMetadata *phu){
-
-    /* outputFile is used by text-format outputs */
-
-    psFree (outputFile);
-    outputFile = psphotOutputName (phu, outputName);
-
-    /* for fits-format output, open outputFits */
-    if (!strcasecmp (outputFormat, "CMF")) {
-	if (outputFits != NULL) {
-	    psFitsClose (outputFits);
-	}
-	outputFits = psFitsOpen (outputFile, "w");
-
-	if (!strcasecmp (outputMode, "MEF")) {
-	    psFitsWriteHeader (outputFits, phu);
-	}
-    }
-    return true;
-}
-
-bool psphotOutputClose (void) {
-
-    if (outputFile != NULL) {
-	psFitsClose (outputFile);
-    }
-    return true;
-}
 
 // output functions: we have several fixed modes (sx, obj, cmp)
@@ -159,26 +9,8 @@
     psMetadata *header = pmReadoutGetHeader (readout);
 
-    psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
     pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
-
-    // starting value is -1
-    extNumber ++;
-
-    // for SPLIT output, we need to open a file for each output call
-    if (!strcasecmp (outputMode, "SPLIT")) {
-	outputFile = psphotSplitName (header);
-    } 
-
-    if (!strcasecmp (outputMode, "MEF")) {
-	headExt = psphotOutputName (header, headExtname);
-	dataExt = psphotOutputName (header, dataExtname);
-    } 
-    if (!strcasecmp (outputMode, "SPLIT")) {
-	dataExt = psphotOutputName (header, dataExtname);
-    } 
-
-    char *residImage = psMetadataLookupStr (&status, arguments, "RESID_IMAGE");
+    // sample PSF images??
     if (psfSample != NULL) psphotSamplePSFs (psf, readout->image, psfSample);
-    if (residImage != NULL) psphotSaveImage (header, readout->image, residImage);
+    if (psfSample != NULL) psphotSamplePSFs (psf, readout->image, psfSample);
 
     if (psfFile != NULL) {
@@ -187,567 +19,4 @@
 	psFree (psfData);
     }
-    if (outputFile == NULL) {
-	psLogMsg ("output", 3, "no data output file selected");
-	return;
-    }
-    if (outputFormat == NULL) {
-	psLogMsg ("output", 3, "no data output format selected");
-	psFree (outputFile);
-	return;
-    }
-    if (!strcasecmp (outputFormat, "SX")) {
-	pmSourcesWriteSX (sources, outputFile);
-	psFree (outputFile);
-	return;
-    }
-    if (!strcasecmp (outputFormat, "OBJ")) {
-	pmSourcesWriteOBJ (sources, outputFile);
-	psFree (outputFile);
-	return;
-    }
-    if (!strcasecmp (outputFormat, "CMP")) {
-	pmSourcesWriteCMP (sources, outputFile, header);
-	psFree (outputFile);
-	return;
-    }
-    if (!strcasecmp (outputFormat, "CMF")) {
-	pmSourcesWriteCMF (sources, header, headExt, dataExt);
-	psFree (outputFile);
-	return;
-    }
-    if (!strcasecmp (outputFormat, "TEXT")) {
-	pmSourcesWriteText (sources, outputFile);
-	psFree (outputFile);
-	return;
-    }
-
-    psAbort ("psphot", "unknown output mode %s", outputFormat);
-}
-
-// dophot-style output list with fixed line width
-bool pmSourcesWriteOBJ (psArray *sources, char *filename) {
-
-    int type;
-    psF32 *PAR, *dPAR;
-    float dmag, apResid;
-
-    psTimerStart ("string");
-
-    psLine *line = psLineAlloc (104);  // 104 is dophot-defined line length
-
-    FILE *f = fopen (filename, "w");
-    if (f == NULL) {
-	psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", filename);
-	return false;
-    }
-
-    // write sources with models 
-    for (int i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-	pmModel *model = pmModelSelect (source);
-	if (model == NULL) continue;
-
-	PAR = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-
-	dmag = dPAR[1] / PAR[1];
-	type = pmSourceDophotType (source);
-	apResid = source->apMag - source->fitMag;
-
-	psLineInit (line);
-	psLineAdd (line, "%3d",   type);
-	psLineAdd (line, "%8.2f", PAR[2]);
-	psLineAdd (line, "%8.2f", PAR[3]);
-	psLineAdd (line, "%8.3f", source->fitMag);
-	psLineAdd (line, "%6.3f", dmag);
-	psLineAdd (line, "%9.2f", PAR[0]);
-	psLineAdd (line, "%9.3f", PAR[4]);
-	psLineAdd (line, "%9.3f", PAR[5]);
-	psLineAdd (line, "%7.2f", PAR[6]);
-	psLineAdd (line, "%8.3f", 99.999);
-	psLineAdd (line, "%8.3f", source->apMag);
-	psLineAdd (line, "%8.2f\n", apResid);
-	fwrite (line->line, 1, line->Nline, f);
-    }
-    fclose (f);
-    psFree (line);
-    fprintf (stderr, "%f seconds for %d objects with psLine\n", psTimerMark ("string"), (int)sources->n);
-
-    psTimerStart ("string");
-
-    f = fopen ("test.obj", "w");
-    if (f == NULL) {
-	psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", "test.obj");
-	return false;
-    }
-
-    char *string;
-    // write sources with models 
-    for (int i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-	pmModel *model = pmModelSelect (source);
-	if (model == NULL) continue;
-
-	PAR = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-
-	dmag = dPAR[1] / PAR[1];
-	type = pmSourceDophotType (source);
-	apResid = source->apMag - source->fitMag;
-
-	string = NULL;
-	psStringAppend (&string, "%3d",   type);
-	psStringAppend (&string, "%8.2f", PAR[2]);
-	psStringAppend (&string, "%8.2f", PAR[3]);
-	psStringAppend (&string, "%8.3f", source->fitMag);
-	psStringAppend (&string, "%6.3f", dmag);
-	psStringAppend (&string, "%9.2f", PAR[0]);
-	psStringAppend (&string, "%9.3f", PAR[4]);
-	psStringAppend (&string, "%9.3f", PAR[5]);
-	psStringAppend (&string, "%7.2f", PAR[6]);
-	psStringAppend (&string, "%8.3f", 99.999);
-	psStringAppend (&string, "%8.3f", source->apMag);
-	psStringAppend (&string, "%8.2f\n", apResid);
-	fwrite (string, 1, strlen(string), f);
-	psFree (string);
-    }
-    fclose (f);
-    fprintf (stderr, "%f seconds for %d objects with psString\n", psTimerMark ("string"), (int)sources->n);
-
-    return true;
-}
-
-// elixir-mode / sextractor-style output list with fixed line width
-bool pmSourcesWriteSX (psArray *sources, char *filename) {
-
-    psF32 *PAR, *dPAR;
-    float dmag;
-
-    psLine *line = psLineAlloc (110);  // 110 is sextractor line length
-
-    FILE *f = fopen (filename, "w");
-    if (f == NULL) {
-	psLogMsg ("WriteSourceSX", 3, "can't open output file for output %s\n", filename);
-	return false;
-    }
-
-    // write sources with models 
-    for (int i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-	pmModel *model = pmModelSelect (source);
-	if (model == NULL) continue;
-
-	PAR = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-
-	// pmSourceSextractType (source, &type, &flags); XXX EAM : implement me...
-
-	dmag = dPAR[1] / PAR[1];
-
-	psLineInit (line);
-	psLineAdd (line, "%5.2f", 0.0); // should be type
-	psLineAdd (line, "%11.3f", PAR[2]);
-	psLineAdd (line, "%11.3f", PAR[3]);
-	psLineAdd (line, "%9.4f", source->fitMag);
-	psLineAdd (line, "%9.4f", dmag);
-	psLineAdd (line, "%13.4f", PAR[0]);
-	psLineAdd (line, "%9.2f", 0.0); // should be FWHMx
-	psLineAdd (line, "%9.2f", 0.0); // should be FWHMy
-	psLineAdd (line, "%6.1f", 0.0); // should be Theta
-	psLineAdd (line, "%9.4f", 99.999); // should be MAG_ISO
-	psLineAdd (line, "%9.4f", source->apMag);
-	psLineAdd (line, "%4d\n", 0); // should be flags
-	fwrite (line->line, 1, line->Nline, f);
-    }
-    fclose (f);
-    return true;
-}
-
-// elixir-style pseudo FITS table (header + ascii list)
-bool pmSourcesWriteCMP (psArray *sources, char *filename, psMetadata *header) {
-
-    int i, type;
-    psMetadataItem *mdi;
-    psF32 *PAR, *dPAR;
-    float dmag, lsky;
-    bool status;
-
-    // find config information for output header
-    float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
-    if (!status) ZERO_POINT = 25.0;
-
-    // write necessary information to output header
-    psMetadataAdd (header, PS_LIST_TAIL, "NSTARS",   PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n);
-
-    // create file, write-out header
-    psFits *fits = psFitsOpen (filename, "w");
-
-    // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0
-    mdi = psMetadataLookup (header, "NAXIS");
-    mdi->data.S32 = 0;
-    mdi->type = PS_DATA_S32;
-
-    // psMetadataAdd (header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0);
-    psFitsWriteHeader (header, fits);
-    psFitsClose (fits);
-
-    // re-open, add data to end of file
-    FILE *f = fopen (filename, "a+");
-    if (f == NULL) {
-	psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", filename);
-	return false;
-    }
-    fseek (f, 0, SEEK_END);
-
-    psLine *line = psLineAlloc (67);  // 66 is imclean-defined line length
-
-    // write sources with models first 
-    for (i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-	pmModel *model = pmModelSelect (source);
-	if (model == NULL) continue;
-
-	PAR = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-
-	dmag = dPAR[1] / PAR[1];
-	type = pmSourceDophotType (source);
-	lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]);
-
-	psLineInit (line);
-	psLineAdd (line, "%6.1f ", PAR[2]);
-	psLineAdd (line, "%6.1f ", PAR[3]);
-	psLineAdd (line, "%6.3f ", PS_MIN (99.999, source->fitMag + ZERO_POINT));
-	psLineAdd (line, "%03d ",  PS_MIN (999, (int)(1000*dmag)));
-	psLineAdd (line, "%2d ",   type);
-	psLineAdd (line, "%3.1f ", lsky);
-	psLineAdd (line, "%6.3f ", 99.999); // should be 'Mgal
-	psLineAdd (line, "%6.3f ", PS_MIN (99.999, source->apMag + ZERO_POINT)); 
-	psLineAdd (line, "%6.2f ", PAR[4]); // should be 'FHWM x'
-	psLineAdd (line, "%6.2f ", PAR[5]); // should be 'FHWM y'
-	psLineAdd (line, "%5.1f\n", 0);	// should be theta
-	fwrite (line->line, 1, line->Nline, f);
-    }
-    fclose (f);
-    return true;
-}
-
-// elixir-style FITS table output (header + table in 1st extension)
-// this format consists of a header derived from the image header
-// followed by a zero-size matrix, followed by the table data
-bool pmSourcesWriteCMF (psArray *sources, char *filename, psMetadata *header) {
-
-    psArray *table;
-    psMetadataItem *mdi;
-    psMetadata *row;
-    psMetadata *theader;
-    int i, type;
-    psF32 *PAR, *dPAR;
-    float dmag, lsky;
-    bool status;
-
-    // find config information for output header
-    float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
-
-    table = psArrayAlloc (sources->n);
-    table->n = 0;
-
-    for (i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-	pmModel *model = pmModelSelect (source);
-	if (model == NULL) continue;
-
-	PAR = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-
-	dmag = dPAR[1] / PAR[1];
-	type = pmSourceDophotType (source);
-	lsky = (PAR[0] < 1.0) ? 0.0 : log10(PAR[0]);
-
-	row = psMetadataAlloc ();
-	psMetadataAdd (row, PS_LIST_TAIL, "X_PIX",   PS_DATA_F32, "", PAR[2]);
-	psMetadataAdd (row, PS_LIST_TAIL, "Y_PIX",   PS_DATA_F32, "", PAR[3]);
-	psMetadataAdd (row, PS_LIST_TAIL, "MAG_RAW", PS_DATA_F32, "", source->fitMag + ZERO_POINT);
-	psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", (int)(1000*dmag));
-	psMetadataAdd (row, PS_LIST_TAIL, "MAG_GAL", PS_DATA_F32, "", 32.0);
-	psMetadataAdd (row, PS_LIST_TAIL, "MAG_AP",  PS_DATA_F32, "", source->apMag + ZERO_POINT);
-	psMetadataAdd (row, PS_LIST_TAIL, "LOG_SKY", PS_DATA_F32, "", lsky);
-	psMetadataAdd (row, PS_LIST_TAIL, "FWHM_X",  PS_DATA_F32, "", type); 
-	psMetadataAdd (row, PS_LIST_TAIL, "FWHM_Y",  PS_DATA_F32, "", PAR[4]);
-	psMetadataAdd (row, PS_LIST_TAIL, "THETA",   PS_DATA_F32, "", PAR[5]);
-	psMetadataAdd (row, PS_LIST_TAIL, "DOPHOT",  PS_DATA_STRING, "", "0");
-	psMetadataAdd (row, PS_LIST_TAIL, "DUMMY",   PS_DATA_STRING, "", "123");
-    
-	psArrayAdd (table, 100, row);
-	psFree (row);
-    }
-
-    // write the correct number of sources in the header
-    psMetadataAdd (header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", table->n);
-    psMetadataAdd (header, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
-
-    // set NAXIS to 0 (we don't write out the data array)
-    mdi = psMetadataLookup (header, "NAXIS");
-    mdi->data.S32 = 0;
-    mdi->type = PS_DATA_S32;
-
-    // create the basic table header
-    theader = psMetadataAlloc ();
-    psMetadataAdd (theader, PS_LIST_HEAD, "EXTNAME", PS_DATA_STRING, "extension name", "SMPFILE");
-
-    // write out the header and table
-    psFits *fits = psFitsOpen (filename, "w");
-    psFitsWriteHeader (header, fits);
-    psFitsWriteTable (fits, theader, table);
-    psFitsClose (fits);
-
-    return true;
-}
-
-/***** Text Output Methods *****/
-
-bool pmSourcesWriteText (psArray *sources, char *filename) {
-
-    char *name = (char *) psAlloc (strlen(filename) + 10);
-
-    sprintf (name, "%s.psf.dat", filename);
-    pmModelWritePSFs (sources, name);
-
-    sprintf (name, "%s.ext.dat", filename);
-    pmModelWriteEXTs (sources, name);
-
-    sprintf (name, "%s.nul.dat", filename);
-    pmModelWriteNULLs (sources, name);
-
-    sprintf (name, "%s.mnt.dat", filename);
-    pmMomentsWriteText (sources, name);
-
-    psFree (name);
-    return true;
-}
-
-// write the PSF sources to an output file
-bool pmModelWritePSFs (psArray *sources, char *filename) {
-
-    double dPos, dMag;
-    int i, j;
-    FILE *f;
-    psF32 *PAR, *dPAR;
-    pmModel  *model;
-
-    f = fopen (filename, "w");
-    if (f == NULL) {
-	psLogMsg ("pmModelWritePSFs", 3, "can't open output file for moments%s\n", filename);
-	return false;
-    }
-
-    // write sources with models first 
-    for (i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-	if (source->type != PM_SOURCE_STAR) continue;
-	model = source->modelPSF;
-	if (model == NULL) continue;
-
-	PAR  = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-	
-	// dPos is positional error, dMag is mag error
-	dPos = hypot (dPAR[2], dPAR[3]);
-	dMag = dPAR[1] / PAR[1];
-
-	fprintf (f, "%7.1f %7.1f  %7.1f %8.4f  %7.4f %7.4f  ", 
-		 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos);
-
-	for (j = 4; j < model->params->n; j++) {
-	    fprintf (f, "%9.6f ", PAR[j]);
-	}
-	fprintf (f, " : ");
-	for (j = 4; j < model->params->n; j++) {
-	    fprintf (f, "%9.6f ", dPAR[j]);
-	}
-	fprintf (f, ": %8.4f %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n", 
-		 source[0].apMag, source[0].type, source[0].mode, 
-		 log10(model[0].chisq/model[0].nDOF), 
-		 source[0].moments->SN, 
-		 model[0].radius,
-		 model[0].nDOF, 
-		 model[0].nIter);
-    }
-    fclose (f);
-    return true;
-}
-
-// dump the sources to an output file
-bool pmModelWriteEXTs (psArray *sources, char *filename) {
-
-    double dPos, dMag;
-    int i, j;
-    FILE *f;
-    psF32 *PAR, *dPAR;
-    pmModel  *model;
-
-    f = fopen (filename, "w");
-    if (f == NULL) {
-	psLogMsg ("pmModelWriteEXTs", 3, "can't open output file for moments%s\n", filename);
-	return false;
-    }
-
-    // write sources with models first 
-    for (i = 0; i < sources->n; i++) {
-	pmSource *source = (pmSource *) sources->data[i];
-
-	if (source->type != PM_SOURCE_EXTENDED) continue;
-	model = pmSourceMagnitudes (source, NULL, 0.0);
-	if (model == NULL) continue;
-
-	PAR  = model->params->data.F32;
-	dPAR = model->dparams->data.F32;
-	
-	// dPos is shape error
-	// XXX these are hardwired for SGAUSS
-	dPos = hypot ((dPAR[4] / PAR[4]), (dPAR[5] / PAR[5]));
-	dMag = dPAR[1] / PAR[1];
-
-	fprintf (f, "%7.1f %7.1f  %7.1f %8.4f  %7.4f %7.4f  ", 
-		 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos);
-
-	for (j = 4; j < model->params->n; j++) {
-	    fprintf (f, "%9.6f ", PAR[j]);
-	}
-	fprintf (f, " : ");
-	for (j = 4; j < model->params->n; j++) {
-	    fprintf (f, "%9.6f ", dPAR[j]);
-	}
-	fprintf (f, ": %7.4f  %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n", 
-		 source->apMag, 
-		 source[0].type, source[0].mode,
-		 log10(model[0].chisq/model[0].nDOF), 
-		 source[0].moments->SN, 
-		 model[0].radius, 
-		 model[0].nDOF, 
-		 model[0].nIter);
-    }
-    fclose (f);
-    return true;
-}
-
-// dump the sources to an output file
-bool pmModelWriteNULLs (psArray *sources, char *filename) 
-{
-
-    int i;
-    FILE *f;
-    pmMoments *moment = NULL;
-    pmSource *source = NULL;
-
-    f = fopen (filename, "w");
-    if (f == NULL) {
-	psLogMsg ("DumpObjects", 3, "can't open output file for moments%s\n", filename);
-	return false;
-    }
-
-    pmMoments *empty = pmMomentsAlloc ();
-
-    // write sources with models first 
-    for (i = 0; i < sources->n; i++) {
-	source = sources->data[i];
-
-	// skip these sources (in PSF or EXT)
-	if (source->type == PM_SOURCE_STAR) continue;
-	if (source->type == PM_SOURCE_EXTENDED) continue;
-	    
-	if (source->moments == NULL) {
-	    moment = empty;
-	} else {
-	    moment = source->moments;
-	}
-
-	fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %8.1f %7.1f %7.1f %7.1f  %4d %2d\n", 
-		 source->peak->x, source->peak->y, source->peak->counts, 
-		 source->moments->x, source->moments->y, 
-		 source->moments->Sx, source->moments->Sy, 
-		 source->moments->Sum, source->moments->Peak, 
-		 source->moments->Sky, source->moments->SN, 
-		 source->moments->nPixels, source->type); 
-    }
-    fclose (f);
-    psFree (empty);
-    return true;
-}
-
-// write the moments to an output file
-bool pmMomentsWriteText (psArray *sources, char *filename)
-{
-
-    int i;
-    FILE *f;
-    pmSource *source = NULL;
-
-    f = fopen (filename, "w");
-    if (f == NULL) {
-        psLogMsg ("pmMomentsWriteText", 3, "can't open output file for moments%s\n", filename);
-        return false;
-    }
-
-    for (i = 0; i < sources->n; i++) {
-        source = sources->data[i];
-        if (source->moments == NULL)
-            continue;
-        fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %10.1f %7.1f %7.1f %7.1f  %4d %2d %#5x\n",
-                 source->peak->x, source->peak->y, source->peak->counts,
-                 source->moments->x, source->moments->y,
-                 source->moments->Sx, source->moments->Sy,
-                 source->moments->Sum, source->moments->Peak,
-                 source->moments->Sky, source->moments->SN,
-                 source->moments->nPixels, source->type, source->mode);
-    }
-    fclose (f);
-    return true;
-}
-
-// write the peaks to an output file
-bool pmPeaksWriteText (psArray *peaks, char *filename) {
-
-    int i;
-    FILE *f;
-	
-    f = fopen (filename, "w");
-    if (f == NULL) {
-	psLogMsg ("pmPeaksWriteText", 3, "can't open output file for peaks%s\n", filename);
-	return false;
-    }
-
-    for (i = 0; i < peaks->n; i++) {
-	pmPeak *peak = peaks->data[i];
-	if (peak == NULL) continue;
-	fprintf (f, "%5d %5d  %7.1f\n", 
-		 peak->x, peak->y, peak->counts); 
-    }
-    fclose (f);
-    return true;
-}
-
-// translations between psphot object types and dophot object types
-int pmSourceDophotType (pmSource *source) {
-
-    switch (source->type) {
-
-      case PM_SOURCE_DEFECT:
-      case PM_SOURCE_SATURATED:
-	return (8);
-
-      case PM_SOURCE_STAR:
-	if (source->mode & PM_SOURCE_SATSTAR) return (10);
-	if (source->mode & PM_SOURCE_POOR) return (7);
-	if (source->mode & PM_SOURCE_FAIL) return (4);
-	return (1);
-
-      case PM_SOURCE_EXTENDED:
-	return (2);
-
-      default:
-	return (0);
-    }
-    return (0);
 }
 
