Index: branches/czw_branch/20170908/pswarp/src/pswarpLoop.c
===================================================================
--- branches/czw_branch/20170908/pswarp/src/pswarpLoop.c	(revision 40128)
+++ branches/czw_branch/20170908/pswarp/src/pswarpLoop.c	(revision 40483)
@@ -58,4 +58,5 @@
     }
 
+    psString refcat = NULL;
     // loop over this section once per input group
     for (int i = 0; i < nInputs; i++) {
@@ -121,4 +122,17 @@
 			    psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "Sources from input astrometry", detections);
 			}
+
+			// Determine the reference catalog used
+			if ((!refcat)&&(astromRO)) {
+			  if ((astromRO->parent->parent->hdu->header)&&(output->fpa->analysis)) {
+			    psMetadataItem *refItem = psMetadataLookup(astromRO->parent->parent->hdu->header, "PSREFCAT");
+			    if (refItem) {
+			      refcat = psMetadataLookupStr(NULL, astromRO->parent->parent->hdu->header, "PSREFCAT");
+			      psMetadataAddStr(output->fpa->analysis, PS_LIST_TAIL, "REFERENCE_CATALOG", PS_META_REPLACE,
+					       "Reference catalog used for calibration.", refcat);
+			    }
+			  }
+			}
+			
 		    }
 
Index: branches/czw_branch/20170908/pswarp/src/pswarpLoopBackground.c
===================================================================
--- branches/czw_branch/20170908/pswarp/src/pswarpLoopBackground.c	(revision 40128)
+++ branches/czw_branch/20170908/pswarp/src/pswarpLoopBackground.c	(revision 40483)
@@ -62,4 +62,5 @@
     pmFPAfileActivate(config->files, true, "PSWARP.BKGMODEL");
 
+    psString refcat = NULL;
     // loop over this section once per input group
     for (int i = 0; i < nInputs; i++) {
@@ -134,4 +135,18 @@
 		    }
 
+		    if (astrom != input) {
+		      pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry
+		      if ((!refcat)&&(astromRO)) {
+			if ((astromRO->parent->parent->hdu->header)&&(output->fpa->analysis)) {
+			  psMetadataItem *refItem = psMetadataLookup(astromRO->parent->parent->hdu->header, "PSREFCAT");
+			  if (refItem) {
+			    refcat = psMetadataLookupStr(NULL, astromRO->parent->parent->hdu->header, "PSREFCAT");
+			    psMetadataAddStr(output->fpa->analysis, PS_LIST_TAIL, "REFERENCE_CATALOG", PS_META_REPLACE,
+					     "Reference catalog used for calibration.", refcat);
+			  }
+			}
+		      }
+		    }
+		    
 		    // re-normalize the BKGMODEL pixels by modified astrometry
 		    for (int x = 0; x < readout->image->numCols; x++) {
Index: branches/czw_branch/20170908/pswarp/src/pswarpUpdateMetadata.c
===================================================================
--- branches/czw_branch/20170908/pswarp/src/pswarpUpdateMetadata.c	(revision 40128)
+++ branches/czw_branch/20170908/pswarp/src/pswarpUpdateMetadata.c	(revision 40483)
@@ -20,4 +20,12 @@
     bool bilevelAstrometry = psMetadataLookupBool (NULL, skycell->analysis, "ASTROMETRY.BILEVEL");
 
+    psString refcat = NULL;
+
+    if ((output)&&(output->analysis)) {    
+      psMetadataItem *refItem = psMetadataLookup(output->analysis, "REFERENCE_CATALOG");
+      if (refItem) {
+	refcat = psMetadataLookupStr (NULL, output->analysis, "REFERENCE_CATALOG");
+      }
+    }
     pmChip *chip;
     while ((chip = pmFPAviewNextChip (view, output, 1)) != NULL) {
@@ -165,4 +173,11 @@
     }
 
+    if (refcat) {
+      if ((output)&&(output->hdu)&&(output->hdu->header)) {
+	psMetadataAddStr(output->hdu->header, PS_LIST_TAIL, "PSREFCAT", PS_META_REPLACE,
+			 "Reference catalog used for calibration", refcat);
+      }
+    }
+    
     // apply the bilevel astrometry elements to the target
     if (bilevelAstrometry) {
