Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c	(revision 38522)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c	(revision 38523)
@@ -5,10 +5,14 @@
 
 // examine the header sets and set the Image entries for the the valid images
-int LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
+Catalog *LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, unsigned int *Ncatalog, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
 
   off_t Nskip, Nvalid, NVALID;
   int i, j, Nhead, Ndata;
   uint32_t parentID = UINT32_MAX;
-  Stars *inStars;
+
+  int ncatalog = 0;
+  int NCATALOG = Nimages;
+  Catalog *catalog = NULL;
+  ALLOCATE (catalog, Catalog, NCATALOG);
 
   if (images[0] == NULL) {
@@ -76,6 +80,6 @@
     fseeko (f, Nskip, SEEK_SET); 
 	 
-    inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar);
-    if (!inStars) {
+    status = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar, &catalog[ncatalog]);
+    if (!status) {
       // XXX need to free the data here or in ReadStarsFITS on error
       continue;
@@ -91,12 +95,16 @@
       fseeko (f, Nskip, SEEK_SET); 
       
-      if (!ReadXradFITS (f, headers[Nxrad], inStars, images[0][Nvalid].nstar)) {
+      if (!ReadXradFITS (f, headers[Nxrad], &catalog[ncatalog], images[0][Nvalid].nstar)) {
 	fprintf (stderr, "problem reading the radial flux data for %s\n", headerSets[i].extdata);
       }
     }
 
-    inStars = FilterStars (inStars, &images[0][Nvalid], Nvalid, options);
-    *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar);
-    FREE (inStars);
+    FilterStars (&catalog[ncatalog], &images[0][Nvalid], Nvalid, options);
+
+    // XXX merge catalogs here : I should only have one output catalog!
+
+    // XXX need to merge here?
+    // *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar);
+    // FREE (inStars);
 
     Nvalid++;
@@ -115,2 +123,5 @@
 }
 
+// thoughts:
+// 1) I read the data from a single image file into a catalog structure (instead of Stars)
+// 2) merge these into a single catalog here or in LoadData above?
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c	(revision 38522)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c	(revision 38523)
@@ -1,16 +1,15 @@
 # include "addstar.h"
 
-Stars *LoadStars (char *filename, unsigned int *Nstars, Image **images, off_t *Nimages, AddstarClientOptions *options) {
+Catalog *LoadStars (char *filename, unsigned int *Ncatalog, Image **images, off_t *Nimages, AddstarClientOptions *options) {
 
   off_t *extsize;
   int i, Nfile, mode;
-  Stars *stars;
 
   AddstarFile *file = LoadFilenames (&Nfile, filename, options);
 
   *Nimages = 0;
-  *Nstars = 0;
+  *Ncatalog = 0;
   *images = NULL;
-  stars = NULL;
+  Catalog *catalog = NULL;
 
   for (i = 0; i < Nfile; i++) {
@@ -23,5 +22,6 @@
     // load PMM data if specified (these are not stored as FITS-tables)
     if (PMM_CCD_TABLE != NULL) {
-      LoadDataPMM (f, file[i].imagename, images, Nimages, &stars, Nstars);
+      *Ncatalog = 1;
+      // XXX catalog = LoadDataPMM (f, file[i].imagename, images, Nimages);
       continue;
     }
@@ -58,5 +58,6 @@
     // if these are SDSS data, load with SDSS-specific wrapper
     if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) {
-      LoadDataSDSS (f, file[i].imagename, images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
+      *Ncatalog = 1;
+      // XXX catalog = LoadDataSDSS (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets);
       goto next_file;
     }
@@ -64,9 +65,10 @@
     // if these are SDSS data, load with SDSS-specific wrapper
     if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) {
-      LoadDataUKIRT (f, file[i].imagename, images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
+      *Ncatalog = 1;
+      // XXX catalog = LoadDataUKIRT (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets);
       goto next_file;
     }
 
-    LoadData (f, &file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets, options);
+    catalog = LoadData (f, &file[i], images, Nimages, Ncatalog, headers, extsize, headerSets, NheaderSets, options);
 
   next_file:
@@ -91,5 +93,5 @@
 
   AddstarFileFree (file, Nfile);
-  return stars;
+  return catalog;
 }
 
