Index: /trunk/stac/src/Makefile
===================================================================
--- /trunk/stac/src/Makefile	(revision 3659)
+++ /trunk/stac/src/Makefile	(revision 3660)
@@ -6,15 +6,11 @@
 
 STAC = stac.o stacConfig.o stacRead.o stacErrorImages.o stacTransform.o stacCheckMemory.o \
-	stacCombine.o stacInvertMaps.o stacRejection.o stacAreaOfInterest.o stacSize.o stacScales.o
+	stacCombine.o stacInvertMaps.o stacRejection.o stacAreaOfInterest.o stacSize.o stacScales.o \
+	stacHelp.o
 
-SHIFT = shift.o stacConfig.o stacRead.o stacErrorImages.o stacTransform.o stacCheckMemory.o \
+SHIFT = shift.o stacRead.o stacErrorImages.o stacTransform.o stacCheckMemory.o \
 	stacCombine.o stacInvertMaps.o stacSize.o
 
-FITTRANS = fitTrans.o fitTransConfig.o fitTransRead.o stacCheckMemory.o fitTransSolve.o
-
-TEST_SHIFT = testShift.o stacConfig.o stacRead.o stacErrorImages.o stacTransform.o stacCheckMemory.o \
-	stacInvertMaps.o
-
-PHOTSCALE = photScale.o
+SHIFTSIZE = shiftSize.o shiftSizeHelp.o stacWrite.o stacConfig.o stacRead.o stacCheckMemory.o stacSize.o
 
 .PHONY: tags clean empty test profile optimise
@@ -29,21 +25,6 @@
 		$(CC) $(CFLAGS) -o $@ $(SHIFT) $(LDFLAGS) $(OPTFLAGS)
 
-photScale:	$(PHOTSCALE)
-		$(CC) $(CFLAGS) -o $@ $(PHOTSCALE) $(LDFLAGS) $(OPTFLAGS)
-
-calcGrad:	calcGrad.o
-		$(CC) $(CFLAGS) -o $@ calcGrad.o $(LDFLAGS) $(OPTFLAGS)
-
-median:		median.o
-		$(CC) $(CFLAGS) -o $@ median.o $(LDFLAGS) $(OPTFLAGS)
-
-getPixels:	getPixels.o
-		$(CC) $(CFLAGS) -o $@ getPixels.o $(LDFLAGS) $(OPTFLAGS)
-
-fitTrans:	$(FITTRANS)
-		$(CC) $(CFLAGS) -o $@ $(FITTRANS) $(LDFLAGS) $(OPTFLAGS)
-
-testShift:	$(TEST_SHIFT)
-		$(CC) $(CFLAGS) -o $@ $(TEST_SHIFT) $(LDFLAGS) $(OPTFLAGS)
+shiftSize:	$(SHIFTSIZE)
+		$(CC) $(CFLAGS) -o $@ $(SHIFTSIZE) $(LDFLAGS) $(OPTFLAGS)
 
 clean:
@@ -66,5 +47,4 @@
 		-$(RM) test_[0-3].fits.rejmap
 		-$(RM) leaks.dat
-#		./stac -v -k 2.5 -f 0.5 -G 0.96 testout.fits test_0.fits test_1.fits test_2.fits test_3.fits
 		./stac -v testout.fits test_0.fits test_1.fits test_2.fits test_3.fits
 
Index: /trunk/stac/src/shiftSize.c
===================================================================
--- /trunk/stac/src/shiftSize.c	(revision 3660)
+++ /trunk/stac/src/shiftSize.c	(revision 3660)
@@ -0,0 +1,95 @@
+/*
+ * shiftSize:
+ * A stripped-down version of STAC that outputs the necessary size to keep all the pixels in the individual
+ * images within the shifted images.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include "pslib.h"
+#include "stac.h"
+
+int main(int argc, char *argv[])
+{
+    // Set trace levels
+    psTraceSetLevel(".",0);
+#ifdef TESTING
+    psTraceSetLevel("stac.checkMemory",10);
+    psTraceSetLevel("stac.config",10);
+    psTraceSetLevel("stac.read",10);
+    psTraceSetLevel("stac.size",10);
+#endif
+
+    // Set logging level
+    psLogSetLevel(9);
+
+    // Parse command line
+    stacConfig *config = stacConfigAlloc(); // Configuration values
+    const char *programName = argv[0];	// Program name
+
+    float saturated = 65535.0;		// Saturation level
+    float bad = 0.0;			// Bad level
+
+    /* Variables for getopt */
+    int opt;   /* Option, from getopt */
+    extern char *optarg;   /* Argument accompanying switch */
+    extern int optind;   /* getopt variables */
+
+    /* Parse command-line arguments using getopt */
+    while ((opt = getopt(argc, argv, "hv")) != -1) {
+        switch (opt) {
+	  case 'h':
+	    help(programName);
+	    exit(EXIT_SUCCESS);
+	  case 'v':
+            config->verbose++;
+            break;
+	  default:
+	    help(programName);
+	}
+    }
+
+    /* Get the remaining, mandatory values */
+    argc -= optind;
+    argv += optind;
+    if (argc < 1) {
+        help(programName);
+        exit(EXIT_FAILURE);
+    }
+
+    // Get the input files
+    config->inputs = psArrayAlloc(argc);
+    for (int i = 0; i < argc; i++) {
+	config->inputs->data[i] = psAlloc(strlen(argv[i]));
+	strncpy(config->inputs->data[i], argv[i], strlen(argv[i]));
+    }
+
+
+    // Read input files
+    psArray *inputs = stacReadImages(config);
+
+    // Read maps
+    psArray *maps = stacReadMaps(config);
+
+    // Get size
+    stacSize(config, inputs, maps);
+
+    printf("%d %d\n", config->outnx, config->outny);
+
+    // Write out altered maps
+    stacWriteMaps(maps, config);
+
+    psFree(config);
+    psFree(inputs);
+    psFree(maps);
+
+#ifdef TESTING
+    // Check memory for leaks, corruption
+    stacCheckMemory();
+#endif
+
+}
Index: /trunk/stac/src/shiftSizeHelp.c
===================================================================
--- /trunk/stac/src/shiftSizeHelp.c	(revision 3660)
+++ /trunk/stac/src/shiftSizeHelp.c	(revision 3660)
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+void help(const char *name)
+{
+    fprintf (stderr, "shiftSize: Calculate size for output combined image\n"
+	     "Usage: %s [-h] [-v] IN1 IN2...\n"
+	     "where\n"
+	     "\t-h           Help (this info)\n"
+	     "\t-v           Increase verbosity level\n"
+	     "\tIN1, IN2...  Input images, which have associated .map files.\n",
+	     name
+	);
+}
+
Index: /trunk/stac/src/stac.c
===================================================================
--- /trunk/stac/src/stac.c	(revision 3659)
+++ /trunk/stac/src/stac.c	(revision 3660)
@@ -27,5 +27,4 @@
     // Set trace levels
     psTraceSetLevel(".",0);
-    psTraceSetLevel(".psLib", 0);
     psTraceSetLevel("stac.checkMemory",10);
     psTraceSetLevel("stac.config",10);
@@ -55,6 +54,8 @@
     psTrace("stac.time", 1, "I/O completed at %f seconds\n", getTime() - startTime);
 
-    // Get size
-    stacSize(config, inputs, maps);
+    // Get size, if not input
+    if (config->outnx == 0 || config->outny == 0) {
+	stacSize(config, inputs, maps);
+    }
 
     // Invert maps
Index: /trunk/stac/src/stac.h
===================================================================
--- /trunk/stac/src/stac.h	(revision 3659)
+++ /trunk/stac/src/stac.h	(revision 3660)
@@ -217,3 +217,16 @@
     );
 
+
+
+/************************************************************************************************************/
+
+// stacWrite.c
+
+// Write maps out
+bool stacWriteMaps(const psArray *maps,	// Maps to write
+		   const stacConfig *config // Configuration
+    );
+
+/************************************************************************************************************/
+
 #endif
Index: /trunk/stac/src/stacConfig.c
===================================================================
--- /trunk/stac/src/stacConfig.c	(revision 3659)
+++ /trunk/stac/src/stacConfig.c	(revision 3660)
@@ -4,31 +4,6 @@
 #include <getopt.h>
 #include <string.h>
+#include "pslib.h"
 #include "stac.h"
-
-void help(const char *name)
-{
-    fprintf (stderr, "STAC: Simultaneous Telescope Array Combination\n"
-	     "Usage: %s [-h] [-v] [-g GAIN] [-r RN] [-o NX NY] [-S] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k REJ] [-n NREJECT] [-k FRAC] [-G GRAD] OUT IN1 IN2...\n"
-	     "where\n"
-	     "\t-h           Help (this info)\n"
-	     "\t-v           Increase verbosity level\n"
-	     "\t-g           Gain (e/ADU) for detectors\n"
-	     "\t-r           Read noise (e) for detectors\n"
-	     "\t-o NX NY     Size of output image (512, 512)\n"
-	     "\t-S           Save shifted images (false)\n"
-	     "\t-s SAT       Saturation level (65535)\n"
-	     "\t-b BAD       Bad level (0)\n"
-	     "\t-p FILE MAP  Specify file containing star coordinates, with map\n"
-	     "\t-a APER      Aperture size to use for photometry (3 pix)\n"
-	     "\t-k REJ       Rejection level (k-sigma; 3.5)\n"
-	     "\t-n NREJECT   Number of rejection iterations (2)\n"
-	     "\t-f FRAC      Fraction of pixel to be marked before considered bad (0.5)\n"
-	     "\t-d GRAD      Gradient threshold for pixel to be marked (0.0)\n"
-	     "\tOUT          Output image\n"
-	     "\tIN1, IN2...  Input images, which have associated .map files.\n",
-	     name
-	);
-}
-
 
 stacConfig *stacConfigAlloc(void)
Index: /trunk/stac/src/stacHelp.c
===================================================================
--- /trunk/stac/src/stacHelp.c	(revision 3660)
+++ /trunk/stac/src/stacHelp.c	(revision 3660)
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+void help(const char *name)
+{
+    fprintf (stderr, "STAC: Simultaneous Telescope Array Combination\n"
+	     "Usage: %s [-h] [-v] [-g GAIN] [-r RN] [-o NX NY] [-S] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k REJ] [-n NREJECT] [-k FRAC] [-G GRAD] OUT IN1 IN2...\n"
+	     "where\n"
+	     "\t-h           Help (this info)\n"
+	     "\t-v           Increase verbosity level\n"
+	     "\t-g           Gain (e/ADU) for detectors\n"
+	     "\t-r           Read noise (e) for detectors\n"
+	     "\t-o NX NY     Size of output image (512, 512)\n"
+	     "\t-S           Save shifted images (false)\n"
+	     "\t-s SAT       Saturation level (65535)\n"
+	     "\t-b BAD       Bad level (0)\n"
+	     "\t-p FILE MAP  Specify file containing star coordinates, with map\n"
+	     "\t-a APER      Aperture size to use for photometry (3 pix)\n"
+	     "\t-k REJ       Rejection level (k-sigma; 3.5)\n"
+	     "\t-n NREJECT   Number of rejection iterations (2)\n"
+	     "\t-f FRAC      Fraction of pixel to be marked before considered bad (0.5)\n"
+	     "\t-d GRAD      Gradient threshold for pixel to be marked (0.0)\n"
+	     "\tOUT          Output image\n"
+	     "\tIN1, IN2...  Input images, which have associated .map files.\n",
+	     name
+	);
+}
+
