Index: /trunk/Ohana/src/imclean/Makefile
===================================================================
--- /trunk/Ohana/src/imclean/Makefile	(revision 3518)
+++ /trunk/Ohana/src/imclean/Makefile	(revision 3519)
@@ -14,5 +14,5 @@
 #  
 INCS	= 	-I$(INC) -I$(LINC) -I$(XINC)
-LIBS	= 	-L$(LLIB) -lFITS -lohana -lm 
+LIBS	= 	-L$(LLIB) -lohana -lFITS -lm 
 CFLAGS	=	-o $*.$(ARCH).o $(INCS)
 CCFLAGS	=	$(INCS) $(LIBS) 
@@ -23,5 +23,5 @@
 $(SRC)/AdjustHeader.$(ARCH).o	$(SRC)/find_group.$(ARCH).o \
 $(SRC)/find_trails.$(ARCH).o	$(SRC)/find_line.$(ARCH).o \
-$(SRC)/LoadStarsDophot.$(ARCH).o $(SRC)/wstars.$(ARCH).o	\
+$(SRC)/wstars.$(ARCH).o	        $(SRC)/LoadStarsDophot.$(ARCH).o \
 $(SRC)/LoadStarsSex.$(ARCH).o	$(SRC)/LoadStarsChad.$(ARCH).o	\
 $(SRC)/wfits.$(ARCH).o
Index: /trunk/Ohana/src/imclean/include/imclean.h
===================================================================
--- /trunk/Ohana/src/imclean/include/imclean.h	(revision 3518)
+++ /trunk/Ohana/src/imclean/include/imclean.h	(revision 3519)
@@ -31,50 +31,20 @@
 char **KEYWORD, **KEYVALU, **KEYFMT;
 
-typedef struct {
-  double X;
-  double Y;
-  double M, dM;
-  char   dophot;
-  double sky;
-  double fx, fy, df;
-  double Mgal, Map;
-} StarsOld;
-
-typedef struct {
-  float X;
-  float Y;
-  float M;
-  float dM;
-  float Mgal;
-  float Map;
-  float sky;
-  float fx;
-  float fy;
-  float df;
-  char  dophot;
-  char  dummy[3];
-} Stars;
-
-Stars *LoadStars ();
-Stars *LoadStarsChad ();
-Stars *LoadStarsSex ();
-
-Stars *LoadStarsDophot (char *filename, int *nstars, Header *header);
-Stars *LoadStarsChad (char *filename, int *nstars, Header *header);
-Stars *LoadStarsSex (char *filename, int *nstars, Header *header);
+SMPData *LoadStarsDophot (char *filename, int *nstars, Header *header);
+SMPData *LoadStarsChad (char *filename, int *nstars, Header *header);
+SMPData *LoadStarsSex (char *filename, int *nstars, Header *header);
 
 void ConfigInit (int *argc, char **argv);
 void AdjustHeader (Header *header);
-void sort_stars (Stars *X, int N);
-void find_trails (Stars *stars, int Nstars);
-int find_group (Stars *stars, char *mark, int Npts, int i, double *ANGLE);
-void wstars (char *filename, Stars *stars, int Nstars, Header *header);
+void sort_stars (SMPData *X, int N);
+void find_trails (SMPData *stars, int Nstars);
+int find_group (SMPData *stars, char *mark, int Npts, int i, double *ANGLE);
+void wstars (char *filename, SMPData *stars, int Nstars, Header *header);
 
-void fix_total (Stars *stars, int Nstars, Header *header);
-int find_line (Stars *stars, char *mark, int Npts, int i, double *M, double *B, double Angle);
-void find_better_line (Stars *stars, char *mark, int Npts, int i, double *M, double *B, int axis);
+void fix_total (SMPData *stars, int Nstars, Header *header);
+int find_line (SMPData *stars, char *mark, int Npts, int i, double *M, double *B, double Angle);
+void find_better_line (SMPData *stars, char *mark, int Npts, int i, double *M, double *B, int axis);
 
 void help ();
 void args (int argc, char **argv);
-int ConvertStars (Stars *data, int size, int nitems);
-void wfits (char *filename, Stars *stars, int Nstars, Header *header);
+void wfits (char *filename, SMPData *stars, int Nstars, Header *header);
Index: /trunk/Ohana/src/imclean/src/LoadStarsChad.c
===================================================================
--- /trunk/Ohana/src/imclean/src/LoadStarsChad.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/LoadStarsChad.c	(revision 3519)
@@ -3,8 +3,8 @@
 # define HIST_BINS 150
 
-Stars *LoadStarsChad (char *filename, int *nstars, Header *header) {
+SMPData *LoadStarsChad (char *filename, int *nstars, Header *header) {
 
   FILE *f;
-  Stars *stars;
+  SMPData *stars;
   int NSTARS, Nstars, i, N;
   int status;
@@ -30,5 +30,5 @@
   Nstars = 0;
   NSTARS = 500;
-  ALLOCATE (stars, Stars, NSTARS);
+  ALLOCATE (stars, SMPData, NSTARS);
 
   /* for now assume file 'header' is fixed-format */
@@ -92,5 +92,5 @@
     if (Nstars == NSTARS - 1) {
       NSTARS += 500;
-      REALLOCATE (stars, Stars, NSTARS);
+      REALLOCATE (stars, SMPData, NSTARS);
     }
   }
Index: /trunk/Ohana/src/imclean/src/LoadStarsDophot.c
===================================================================
--- /trunk/Ohana/src/imclean/src/LoadStarsDophot.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/LoadStarsDophot.c	(revision 3519)
@@ -5,8 +5,8 @@
 /* m = 0.1*Mhist[i] */
 
-Stars *LoadStarsDophot (char *filename, int *nstars, Header *header) {
+SMPData *LoadStarsDophot (char *filename, int *nstars, Header *header) {
 
   FILE *f;
-  Stars *stars;
+  SMPData *stars;
   int NSTARS, Nstars, i, Nline, N;
   int type, status;
@@ -38,5 +38,5 @@
   Nstars = 0;
   NSTARS = 500;
-  ALLOCATE (stars, Stars, NSTARS);
+  ALLOCATE (stars, SMPData, NSTARS);
 
   /* read average values from first line */
@@ -112,5 +112,5 @@
 	if (Nstars == NSTARS - 1) {
 	  NSTARS += 500;
-	  REALLOCATE (stars, Stars, NSTARS);
+	  REALLOCATE (stars, SMPData, NSTARS);
 	}
       }
Index: /trunk/Ohana/src/imclean/src/LoadStarsSex.c
===================================================================
--- /trunk/Ohana/src/imclean/src/LoadStarsSex.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/LoadStarsSex.c	(revision 3519)
@@ -5,8 +5,8 @@
 /* good for sextractor */
 
-Stars *LoadStarsSex (char *filename, int *nstars, Header *header) {
+SMPData *LoadStarsSex (char *filename, int *nstars, Header *header) {
 
   FILE *f;
-  Stars *stars;
+  SMPData *stars;
   int NSTARS, Nstars, i, Nline, N;
   int type, status;
@@ -37,5 +37,5 @@
   Nstars = 0;
   NSTARS = 500;
-  ALLOCATE (stars, Stars, NSTARS);
+  ALLOCATE (stars, SMPData, NSTARS);
 
   /* read in data from obj file */
@@ -105,5 +105,5 @@
       if (Nstars == NSTARS - 1) {
 	NSTARS += 500;
-	REALLOCATE (stars, Stars, NSTARS);
+	REALLOCATE (stars, SMPData, NSTARS);
       }
     }
Index: unk/Ohana/src/imclean/src/addastro.c
===================================================================
--- /trunk/Ohana/src/imclean/src/addastro.c	(revision 3518)
+++ 	(revision )
@@ -1,56 +1,0 @@
-# include <ohana.
-
-main (int argc, char **argv) {
-
-  Header header;
-  Stars *stars;
-  int Nstars;
-
-  ConfigInit (&argc, argv);
-
-  args (argc, argv);
-
-  /* load in FITS header from image */
-  if (!fits_read_header (argv[1], &header)) {
-    fprintf (stderr, "ERROR: can't find image file %s\n", argv[1]);
-    exit (1);
-  }
-
-  AdjustHeader (&header);
-  
-  switch (MODE) {
-  case DOPHOT:
-    stars = LoadStarsDophot (argv[2], &Nstars, &header);
-    break;
-  case CHAD:
-    stars = LoadStarsChad (argv[2], &Nstars, &header);
-    break;
-  case SEXTRACT:
-    stars = LoadStarsSex (argv[2], &Nstars, &header);
-    break;
-  default: 
-    fprintf (stderr, "unknown mode: %d\n", MODE);
-    exit (1);
-  }
-
-  sort_stars (stars, Nstars);
-  find_trails (stars, Nstars);  
-  fix_total (stars, Nstars, &header);
-
-  wstars (argv[3], stars, Nstars, &header); 
-
-  fprintf (stderr, "SUCCESS\n");
-  exit (0);
-
-}
-
-/* based on fstat and markstar:
-
-   0) load config data, global parameters 
-   1) load header
-   2) load data from *.obj file
-   3) eliminate bad star types: 6, 8
-   4) identify trails
-   5) get statistics on remaining stars
-
-*/
Index: /trunk/Ohana/src/imclean/src/find_group.c
===================================================================
--- /trunk/Ohana/src/imclean/src/find_group.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/find_group.c	(revision 3519)
@@ -1,5 +1,5 @@
 # include "imclean.h"
 
-int find_group (Stars *stars, char *mark, int Npts, int i, double *ANGLE) {
+int find_group (SMPData *stars, char *mark, int Npts, int i, double *ANGLE) {
  
   int j, N, bin, Ndegbin;
Index: /trunk/Ohana/src/imclean/src/find_line.c
===================================================================
--- /trunk/Ohana/src/imclean/src/find_line.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/find_line.c	(revision 3519)
@@ -1,5 +1,5 @@
 # include "imclean.h"
 
-int find_line (Stars *stars, char *mark, int Npts, int i, double *M, double *B, double Angle) {
+int find_line (SMPData *stars, char *mark, int Npts, int i, double *M, double *B, double Angle) {
   
   int j, N;
@@ -73,5 +73,5 @@
 
 
-void find_better_line (Stars *stars, char *mark, int Npts, int i, double *M, double *B, int axis) {
+void find_better_line (SMPData *stars, char *mark, int Npts, int i, double *M, double *B, int axis) {
   
   int j, N;
@@ -150,5 +150,5 @@
 }
 
-void fix_total (Stars *stars, int Nstars, Header *header) {
+void fix_total (SMPData *stars, int Nstars, Header *header) {
   
   int Ngood, i;
Index: /trunk/Ohana/src/imclean/src/find_trails.c
===================================================================
--- /trunk/Ohana/src/imclean/src/find_trails.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/find_trails.c	(revision 3519)
@@ -1,5 +1,5 @@
 # include "imclean.h"
 
-void find_trails (Stars *stars, int Nstars) {
+void find_trails (SMPData *stars, int Nstars) {
 
   int i;
Index: /trunk/Ohana/src/imclean/src/imclean.c
===================================================================
--- /trunk/Ohana/src/imclean/src/imclean.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/imclean.c	(revision 3519)
@@ -4,5 +4,5 @@
 
   Header header;
-  Stars *stars;
+  SMPData *stars;
   int Nstars;
 
Index: /trunk/Ohana/src/imclean/src/sort_stars.c
===================================================================
--- /trunk/Ohana/src/imclean/src/sort_stars.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/sort_stars.c	(revision 3519)
@@ -1,8 +1,8 @@
 # include "imclean.h"
 
-void sort_stars (Stars *X, int N) {
+void sort_stars (SMPData *X, int N) {
 
   int l,j,ir,i;
-  Stars tX;
+  SMPData tX;
   
   if (N < 1) return;
Index: /trunk/Ohana/src/imclean/src/star_stats.c
===================================================================
--- /trunk/Ohana/src/imclean/src/star_stats.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/star_stats.c	(revision 3519)
@@ -1,5 +1,5 @@
 # include "imclean.h"
 
-star_stats (Header *header, Stars *stars, int Nstars) {
+star_stats (Header *header, SMPData *stars, int Nstars) {
 
   int i;
Index: /trunk/Ohana/src/imclean/src/wfits.c
===================================================================
--- /trunk/Ohana/src/imclean/src/wfits.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/wfits.c	(revision 3519)
@@ -1,5 +1,5 @@
 # include "imclean.h"
 
-void wfits (char *filename, Stars *stars, int Nstars, Header *header) {
+void wfits (char *filename, SMPData *stars, int Nstars, Header *header) {
 
   Matrix matrix;
@@ -18,26 +18,6 @@
   fits_create_matrix (header, &matrix);
     
-  /* create bintable header */
-  fits_create_table_header (&theader, "BINTABLE", "SMPFILE");
-
-  /* define bintable layout */
-  fits_define_bintable_column (&theader, "E",    "X_PIX",      "x coord",              "pixels",                         1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "Y_PIX",      "y coord",              "pixels",                         1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "MAG_RAW",    "inst mags",            "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "MAG_ERR",    "inst mag error",       "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "MAG_GAL",    "galaxy mag",           "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "MAG_AP",     "aperture mag",         "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "LOG_SKY",    "log-10 of sky",        "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "FWHM_X",     "semi-major",           "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "FWHM_Y",     "semi-minor",           "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "E",    "THETA",      "ellipse angle",        "mags",                           1.0, 0.0); 
-  fits_define_bintable_column (&theader, "B",    "DOPHOT",     "dophot type",          "",                              1.0, 0.0);
-  fits_define_bintable_column (&theader, "3A",   "DUMMY",      "padding",              "",                              1.0, 0.0);
-
-  /* create table, add data values */
-  fits_create_table (&theader, &table);
-
-  ConvertStars (stars, sizeof (Stars), Nstars);
-  fits_add_rows (&table, (char *) stars, Nstars, sizeof (Stars));
+  table.header = &theader;
+  fits_table_set_SMPData (&table, stars, Nstars);
 
   fits_write_header  (filename, header);
@@ -47,60 +27,2 @@
   exit (0);
 }
-
-# define SWAP_BYTE(X) \
-  tmp = byte[X+0]; byte[X+0] = byte[X+1]; byte[X+1] = tmp;
-# define SWAP_WORD(X) \
-  tmp = byte[X+0]; byte[X+0] = byte[X+3]; byte[X+3] = tmp; \
-  tmp = byte[X+1]; byte[X+1] = byte[X+2]; byte[X+2] = tmp;
-# define SWAP_DBLE(X) \
-  tmp = byte[X+0]; byte[X+0] = byte[X+7]; byte[X+7] = tmp; \
-  tmp = byte[X+1]; byte[X+1] = byte[X+6]; byte[X+6] = tmp; \
-  tmp = byte[X+2]; byte[X+2] = byte[X+5]; byte[X+5] = tmp; \
-  tmp = byte[X+3]; byte[X+3] = byte[X+4]; byte[X+4] = tmp;
-
-# ifdef linux
-# define BYTE_SWAP
-# endif
-
-# ifdef sid
-# define BYTE_SWAP
-# endif
-
-# ifdef dec
-# define BYTE_SWAP
-# endif
-
-# define STARS_SIZE 44
-
-int ConvertStars (Stars *data, int size, int nitems) {
-
-  int i;
-  unsigned char *byte, tmp;
-
-# ifdef BYTE_SWAP
-
-  if (size != STARS_SIZE) {
-    fprintf (stderr, "mismatch in type sizes (Stars) %d vs %d\n", size, STARS_SIZE);
-    return (FALSE);
-  }
-
-  byte = (char *) data;
-  for (i = 0; i < nitems; i++, byte += size) {
-    SWAP_WORD (0);   /* R */
-    SWAP_WORD (4);   /* Y */
-    SWAP_WORD (8);   /* M */
-    SWAP_WORD (12);  /* dM */
-    SWAP_WORD (16);  /* Mgal */
-    SWAP_WORD (20);  /* Map */
-    SWAP_WORD (24);  /* sky */
-    SWAP_WORD (28);  /* fx */
-    SWAP_WORD (32);  /* fy */
-    SWAP_WORD (36);  /* df */
-  }
-  return (TRUE);
-
-# else
-  return (TRUE);
-# endif  
-} 
-
Index: /trunk/Ohana/src/imclean/src/wstars.c
===================================================================
--- /trunk/Ohana/src/imclean/src/wstars.c	(revision 3518)
+++ /trunk/Ohana/src/imclean/src/wstars.c	(revision 3519)
@@ -2,5 +2,5 @@
 # define NCHAR 66 /* 65 char EXCLUDING return */
 
-void wstars (char *filename, Stars *stars, int Nstars, Header *header) {
+void wstars (char *filename, SMPData *stars, int Nstars, Header *header) {
   
   int i, Nchar;
Index: /trunk/Ohana/src/libautocode/Makefile
===================================================================
--- /trunk/Ohana/src/libautocode/Makefile	(revision 3518)
+++ /trunk/Ohana/src/libautocode/Makefile	(revision 3519)
@@ -28,8 +28,10 @@
 
 LIBOBJ = \
+$(SRC)/smpdata.$(ARCH).o \
 $(SRC)/spectrum.$(ARCH).o \
 $(SRC)/spectrum-ascii.$(ARCH).o
 
 LIBINC = \
+$(INC)/smpdata.h \
 $(INC)/spectrum.h \
 $(INC)/spectrum-ascii.h
Index: /trunk/Ohana/src/libautocode/def/smpdata.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/smpdata.d	(revision 3518)
+++ /trunk/Ohana/src/libautocode/def/smpdata.d	(revision 3519)
@@ -2,4 +2,6 @@
 STRUCT  SMPData
 EXTNAME SMPFILE
+TYPE    BINTABLE
+SIZE    44
 
 # elements of data structure / FITS table
Index: /trunk/Ohana/src/libohana/Makefile
===================================================================
--- /trunk/Ohana/src/libohana/Makefile	(revision 3518)
+++ /trunk/Ohana/src/libohana/Makefile	(revision 3519)
@@ -47,4 +47,5 @@
 
 AOBJ = \
+$(ASRC)/smpdata.$(ARCH).o \
 $(ASRC)/spectrum.$(ARCH).o \
 $(ASRC)/spectrum-ascii.$(ARCH).o
