Index: /trunk/Ohana/src/addstar/src/sky_tessalation.c
===================================================================
--- /trunk/Ohana/src/addstar/src/sky_tessalation.c	(revision 13644)
+++ /trunk/Ohana/src/addstar/src/sky_tessalation.c	(revision 13645)
@@ -25,5 +25,5 @@
 int sky_tessalation_triangles (FITS_DB *db, int level, int Nmax) {
 
-  int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ltop, Nimages;
+  int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ltop, Nout, Nimages;
   double Ntop, fLtop;
   SkyTriangle *base, *tri, *new;
@@ -60,4 +60,5 @@
 
   // for each base triangle, subdivide the rest of the way and save
+  Nout = 0;
   for (i = 0; i < Nbase; i++) {
     ALLOCATE (tri, SkyTriangle, 1);
@@ -74,5 +75,6 @@
     for (j = 0; j < Ntriangles; j++) {
       sky_triangle_to_image (&image[j], &tri[j]);
-      snprintf (image[j].name, 32, format, j);
+      snprintf (image[j].name, 32, format, Nout);
+      Nout++;
     }  
     Nimages = Ntriangles;
@@ -93,5 +95,5 @@
 int sky_tessalation_squares (FITS_DB *db, int level, int Nmax) {
 
-  int i, j, Ndigit, Ntriangles, Nbase, Ntotal, Ntop, Ltop, Nout, Nx, Ny;
+  int i, j, Nname, Ndigit, Ntriangles, Nbase, Ntotal, Ntop, Ltop, Nout, Nx, Ny;
   double fLtop;
   SkyTriangle *base, *tri, *new;
@@ -131,4 +133,5 @@
 
   // for each base triangle, subdivide the rest of the way and save
+  Nname = 0;
   for (i = 0; i < Nbase; i++) {
     ALLOCATE (tri, SkyTriangle, 1);
@@ -152,5 +155,6 @@
       if (!strcmp(image[j].coords.ctype, "DROP")) continue;
       memcpy (&out[Nout], &image[j], sizeof(Image));
-      snprintf (out[Nout].name, 32, format, j);
+      snprintf (out[Nout].name, 32, format, Nname);
+      Nname++;
       Nout++;
     }  
@@ -249,8 +253,12 @@
 int sky_subdivide_image (Image *output, Image *input, int Nx, int Ny) {
 
-  int i, j, N, NX, NY;
+  int i, j, N, NX, NY, Ndigit;
+  char format[24];
 
   NX = input[0].NX/(double)Nx + 0.5;
   NY = input[0].NY/(double)Ny + 0.5;
+
+  Ndigit = (int)(log10(Nx*Ny)) + 1 ;
+  snprintf (format, 24, "%s.%%0%dd", input[0].name, Ndigit);
 
   N = 0;
@@ -259,4 +267,5 @@
 
       memcpy (&output[N], &input[0], sizeof(Image));
+      snprintf (output[N].name, 32, format, N);
 
       // output[0].coords = input[0].coords;
