Index: trunk/magic/remove/src/streaksremove.c
===================================================================
--- trunk/magic/remove/src/streaksremove.c	(revision 20708)
+++ trunk/magic/remove/src/streaksremove.c	(revision 20730)
@@ -2,9 +2,4 @@
 #include "libgen.h"
 #include "unistd.h"
-
-// XXX: I don't think we need the lock and unlock functions
-extern bool  sFileLock(sFile * sfile);
-extern bool  sFileUnlock(sFile * sfile);
-extern bool  sFileReplace(sFile *dest, sFile *src);
 
 static nebServer *ourNebServer = NULL;
@@ -343,22 +338,4 @@
 
     return sf;
-}
-
-
-bool
-streakFilesLock(streakFiles *sf)
-{
-    if (sf->inImage->inNebulous ) {
-        // TODO: make the nebulous call to lock the file
-    }
-    return true;
-}
-bool
-streakFilesUnlock(streakFiles *sf)
-{
-    if (sf->inImage->inNebulous ) {
-        // TODO: make the nebulous call to unlock the file
-    }
-    return true;
 }
 
@@ -535,5 +512,5 @@
             return NULL;
         }
-        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "MASK", 0,
+        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "INPUT.MASK", 0,
                 "name of input mask image", argv[argnum]);
         psArgumentRemove(argnum, &argc, argv);
@@ -547,5 +524,5 @@
             return NULL;
         }
-        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "WEIGHT", 0,
+        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "INPUT.WEIGHT", 0,
                 "name of input weight image", argv[argnum]);
         psArgumentRemove(argnum, &argc, argv);
@@ -611,4 +588,5 @@
         streaksremoveExit("", PS_EXIT_DATA_ERROR);
     }
+
     
     // TODO: add keyword indicating that streaks have been removed
@@ -895,4 +873,5 @@
 readAndCopyToOutput(streakFiles *sf)
 {
+    bool    updateAstrometry = false;
     if (sf->inImage->pmfile) {
         // image data from pmFPAfile (diff or warp file)
@@ -909,6 +888,14 @@
     }
     if (!sf->astrom) {
-        psError(PS_ERR_UNKNOWN, false, "failed to set up astrometry for extnsion %d", sf->extnum);
+        psError(PS_ERR_UNKNOWN, false, "failed to set up astrometry for extension %d", sf->extnum);
         streaksremoveExit("", PS_EXIT_UNKNOWN_ERROR);
+    }
+    if (sf->stage == IPP_STAGE_CHIP) {
+        // For the chip level files, copy the WCS from the astrometry file to the header
+        updateAstrometry = true;
+        if (!pmAstromWriteWCS(sf->inImage->header, sf->inAstrom->fpa, sf->chip, 0.001)) {
+            psError(PS_ERR_UNKNOWN, false, "failed to update astrometry for extension %d", sf->extnum);
+            streaksremoveExit("", PS_EXIT_UNKNOWN_ERROR);
+        }
     }
     sf->outImage->header = (psMetadata*) psMemIncrRefCounter(sf->inImage->header);
@@ -930,10 +917,11 @@
 
     // set up the compression parameters
-//    copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
+    //  copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
 
     // XXX: TODO: can we derive these values from the input header?
     // psFitsCompressionGet(sf->inImage->image) gives compression none
     // perhaps we should just use the definition of COMP_IMG in the configuration 
-//    psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
+    //    psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
+
     psFitsSetCompression(sf->recImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
 
@@ -941,4 +929,7 @@
         readImage(sf->inMask, sf->extnum, sf->stage);
         sf->outMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header);
+        if (updateAstrometry) {
+            pmAstromWriteWCS(sf->outMask->header, sf->inAstrom->fpa, sf->chip, 0.001);
+        }
         sf->outMask->image = (psImage*) psMemIncrRefCounter(sf->inMask->image);
         sf->recMask->image = (psImage*) psMemIncrRefCounter(sf->inMask->image);
@@ -955,4 +946,7 @@
         readImage(sf->inWeight, sf->extnum, sf->stage);
         sf->outWeight->header = (psMetadata*) psMemIncrRefCounter(sf->inWeight->header);
+        if (updateAstrometry) {
+            pmAstromWriteWCS(sf->outWeight->header, sf->inAstrom->fpa, sf->chip, 0.001);
+        }
         sf->outWeight->image = (psImage*) psMemIncrRefCounter(sf->inWeight->image);
 
@@ -1450,4 +1444,5 @@
         computeWarpedPixels(sfiles);
     }
+    
 
     if (sfiles->stage == IPP_STAGE_RAW) {
