Index: trunk/ppSim/src/ppSimStars.c
===================================================================
--- trunk/ppSim/src/ppSimStars.c	(revision 14463)
+++ trunk/ppSim/src/ppSimStars.c	(revision 14667)
@@ -1,64 +1,3 @@
 # include "ppSim.h"
-
-#define STAR_RANGE_MIN 4.5              // Minimum pixel range for adding stars, sigma
-#define STAR_BG_FRAC 0.1                // Fraction of background error to go out to when adding stars
-
-// Return star flux at a position
-static inline float starFlux(float x, float y, // Position of interest
-                             float x0, float y0, // Centre of star
-                             float seeing // Seeing FWHM (pixels)
-    )
-{
-#ifdef STAR_GAUSSIAN
-    // Gaussian star
-    return exp(-0.5 * (PS_SQR(x - x0) + PS_SQR(y - y0)) / PS_SQR(seeing));
-#else
-    // Waussian star
-    float z = (PS_SQR(x - x0) + PS_SQR(y - y0)) / (2.0 * PS_SQR(seeing));
-    return 1.0 / (1.0 + z + PS_SQR(z));
-#endif
-}
-
-// Return size of star in pixels
-static inline int starSize(float noise, float peak, float seeing)
-{
-#ifdef STAR_GAUSSIAN
-    // Gaussian star (solving Gaussian)
-    float target = STAR_BG_FRAC * seeing * sqrt(M_2_PI) * noise / peak;
-    return target < 1.0 ? 2.0 * seeing * sqrtf(-logf(target)) + 0.5 : seeing * STAR_RANGE_MIN;
-#else
-    // Waussian star (solving Waussian where z >> 1 and peak/sqrt(bg) >> 1)
-    float target = STAR_BG_FRAC * noise / peak;
-    return PS_MAX(sqrtf(1.0 / target) + 0.5, seeing * STAR_RANGE_MIN);
-#endif
-}
-
-// Add a star into the signal and variance images
-bool ppSimInsertStar(psImage *signal,       // Signal image, to which to add star
-		     psImage *variance,     // Variance image, to which to add star
-		     float x0, float y0,    // Position of star
-		     float peak,            // Peak flux of star
-		     float noise,           // Rough noise estimate
-		     float seeing,          // Seeing for star
-		     const psImage *correction // Exposure correction as a function of position
-    )
-{
-    int size = starSize(noise, peak, seeing); // Size of star
-
-    // Range in image pixels on which to add star
-    int xMin = PS_MAX(0, x0 - size);
-    int xMax = PS_MIN(signal->numCols - 1, x0 + size);
-    int yMin = PS_MAX(0, y0 - size);
-    int yMax = PS_MIN(signal->numRows - 1, y0 + size);
-
-    for (int y = yMin; y <= yMax; y++) {
-        for (int x = xMin; x <= xMax; x++) {
-            float star = peak * correction->data.F32[y][x] * starFlux(x, y, x0, y0, seeing); // Star flux
-            signal->data.F32[y][x] += star;
-            variance->data.F32[y][x] += star;
-        }
-    }
-    return true;
-}
 
 void ppSimStarFree(ppSimStar *star)
@@ -74,2 +13,15 @@
     return star;
 }
+
+void ppSimGalaxyFree(ppSimGalaxy *galaxy)
+{
+    return;
+}
+
+ppSimGalaxy *ppSimGalaxyAlloc () {
+
+    ppSimGalaxy *galaxy = (ppSimGalaxy *) psAlloc(sizeof(ppSimGalaxy));
+    psMemSetDeallocator(galaxy, (psFreeFunc) ppSimGalaxyFree);
+
+    return galaxy;
+}
