Index: /trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO.c	(revision 13135)
+++ /trunk/psModules/src/objects/pmSourceIO.c	(revision 13136)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-26 01:20:29 $
+ *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-03 00:12:03 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -41,5 +41,5 @@
 
 // translations between psphot object types and dophot object types
-int pmSourceDophotType (pmSource *source)
+int pmSourceGetDophotType (pmSource *source)
 {
     switch (source->type) {
@@ -65,4 +65,36 @@
     }
     return (0);
+}
+
+// translations between psphot object types and dophot object types
+bool pmSourceSetDophotType (pmSource *source, int type)
+{
+    if (type == 4) {
+	source->mode |= PM_SOURCE_MODE_FAIL;
+    }
+    if (type == 7) {
+	source->mode |= PM_SOURCE_MODE_POOR;
+    }
+    if (type == 10) {
+	source->mode |= PM_SOURCE_MODE_SATSTAR;
+    }
+
+    switch (type) {
+      case 1:
+      case 4:
+      case 7:
+      case 10:
+	source->type = PM_SOURCE_TYPE_STAR; 
+	return true;
+      case 2:
+	source->type = PM_SOURCE_TYPE_EXTENDED; 
+	return true;
+      case 8:
+	source->type = PM_SOURCE_TYPE_DEFECT; 
+	return true;
+      default:
+	return false;
+    }
+    return false;
 }
 
@@ -323,13 +355,14 @@
         // this header block is new, write it to disk
         if (hdu->header != file->header) {
-            outhead = psMetadataCopy (NULL, hdu->header);
+	    // XXX I was building a new copy, why?  supplement the output header
+            // outhead = psMetadataCopy (NULL, hdu->header);
 
             // add EXTNAME, EXTHEAD, EXTTYPE to header
             // psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTNAME", PS_META_REPLACE, "extension name", headname);
-            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTDATA", PS_META_REPLACE, "name of table extension", dataname);
-            psMetadataAddStr (outhead, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE");
+            psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTDATA", PS_META_REPLACE, "name of table extension", dataname);
+            psMetadataAddStr (hdu->header, PS_LIST_TAIL, "EXTTYPE", PS_META_REPLACE, "extension type", "IMAGE");
             if (!file->phu) {
                 // this hdu->header acts as the PHU: set EXTEND to be true
-                psMetadataAddBool (outhead, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
+                psMetadataAddBool (hdu->header, PS_LIST_TAIL, "EXTEND", PS_META_REPLACE, "this file has extensions", true);
             }
 
@@ -337,15 +370,14 @@
             updates = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
             if (updates) {
-                psMetadataCopy (outhead, updates);
+                psMetadataCopy (hdu->header, updates);
             }
             updates = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.HEADER");
             if (updates) {
-                psMetadataCopy (outhead, updates);
+                psMetadataCopy (hdu->header, updates);
             }
 
-            psFitsWriteBlank (file->fits, outhead, headname);
+            psFitsWriteBlank (file->fits, hdu->header, headname);
             psTrace ("pmFPAfile", 5, "wrote ext head %s (type: %d)\n", file->filename, file->type);
             file->header = hdu->header;
-            psFree (outhead);
         }
 
