Index: /branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h	(revision 38366)
@@ -191,5 +191,5 @@
 
 int     gfits_uncompress_image 	       PROTO((Header *header, Matrix *matrix, FTable *ftable));
-int     gfits_uncompress_data  	       PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize));
+int     gfits_uncompress_data  	       PROTO((char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize));
 int     gfits_distribute_data  	       PROTO((Matrix *matrix, char *data, int Ndata, int bitpix, int *otile, int oblank, int *ztile, int zblank, float zscale, float zzero));
 
@@ -244,7 +244,9 @@
 int     gfits_fwrite_ftable_range      PROTO((FILE *f, FTable *table, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal));
 int     gfits_get_bintable_column      PROTO((Header *header, FTable *table, char *label, void **data));
+int     gfits_get_bintable_column_raw  PROTO((Header *header, FTable *table, char *label, void **data, char nativeOrder));
 int     gfits_get_bintable_column_type PROTO((Header *header, char *label, char *type, int *Nval));
+void   *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol));
 int     gfits_get_bintable_column_type_by_N  PROTO((Header *header, int N, char *type, int *Nval));
-void   *gfits_get_bintable_column_data PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol));
+void   *gfits_get_bintable_column_data_raw   PROTO((Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder));
 int     gfits_get_table_column         PROTO((Header *header, FTable *table, char *label, void **data));
 int     gfits_get_table_column_type    PROTO((Header *header, char *label, char *type));
@@ -252,5 +254,5 @@
 int     gfits_read_table               PROTO((char *filename, FTable *ftable)); 
 int     gfits_set_bintable_column      PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow));
-int     gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow));
+int     gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder));
 int     gfits_set_table_column         PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow));
 int     gfits_table_column             PROTO((FTable *ftable, char *field, char *mode,...)) OHANA_FORMAT(printf, 3, 4);
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c	(revision 38366)
@@ -165,5 +165,5 @@
 
   // define compression-specific keywords, update header as needed.
-  if (!strcasecmp(zcmptype, "RICE_1")) {
+  if (!strcasecmp(zcmptype, "RICE_1") || !strcasecmp(zcmptype, "RICE_ONE")) {
     if (!gfits_modify (theader, "ZNAME1", "%s", 1, "BLOCKSIZE")) ESCAPE;
     if (!gfits_modify (theader, "ZVAL1", "%d", 1, 32)) ESCAPE;
@@ -195,5 +195,5 @@
     // copy the raw pixels from their native matrix locations to the temporary output buffer
     // for float -> int scaling by zscale, zzero may be applied
-    if (!strcasecmp (zcmptype, "GZIP_2")) {
+    if (!strcasecmp (zcmptype, "GZIP_2") || !strcasecmp (zcmptype, "NONE_2")) {
       if (!gfits_collect_gzp2 (matrix, raw, Nraw, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE;
     } else {
@@ -240,5 +240,10 @@
     // compression modes require swapping after compression (compresssion & decompression
     // operate on native ENDIAN)
-    if (strcasecmp(zcmptype, "GZIP_1") && strcasecmp(zcmptype, "GZIP_2") && strcasecmp(zcmptype, "RICE_1")) {
+    if (strcasecmp(zcmptype, "NONE") && 
+	strcasecmp(zcmptype, "NONE_2") && 
+	strcasecmp(zcmptype, "GZIP_1") && 
+	strcasecmp(zcmptype, "GZIP_2") && 
+	strcasecmp(zcmptype, "RICE_1") && 
+	strcasecmp(zcmptype, "RICE_ONE")) {
       // Nzdata is number of bytes
       if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_data.c	(revision 38366)
@@ -42,5 +42,5 @@
 
   // do not actually compress : this is used for testing
-  if (!strcasecmp(cmptype, "NONE")) {
+  if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_2")) {
     unsigned long Nbytes = Nrawpix * rawpix_size;
 
@@ -85,5 +85,4 @@
     // fprintf (stderr, "%d comp bytes; %d uncomp 'pixels', totals: %d %d\n", Nzdata, Npix, Ninsum, Noutsum);
 
-    char buffer[1000];
     int k;
 
@@ -101,10 +100,7 @@
 	  fprintf (stderr, "Nout: %d, Nrawpix: %d\n", Nout, Nrawpix);
 	  fprintf (stderr, "cmp inp: "); 
-	  for (k = 0; k < Nout; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 
+	  for (k = 0; k < Nout; k++) { fprintf (stderr, "%02hhx", zdata[k]); if (k % 2) fprintf (stderr, " "); } 
 	  fprintf (stderr, "\n");
 	}
-
-	status = fits_rdecomp_short ((unsigned char *) zdata, Nout, (unsigned short *) buffer, Nrawpix, blocksize);
-	myAssert (!status, "failed to rdecomp");
 	break;
 
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_utils.c	(revision 38366)
@@ -174,4 +174,5 @@
 
   if (!strcasecmp(cmptype, "NONE")) return TRUE;
+  if (!strcasecmp(cmptype, "NONE_2")) return TRUE; // do not compress, but shuffle a la GZIP_2
   if (!strcasecmp(cmptype, "GZIP_1")) return TRUE;
   if (!strcasecmp(cmptype, "GZIP_2")) return TRUE;
@@ -190,4 +191,5 @@
   if (!strcasecmp(cmptype, "GZIP_1") || 
       !strcasecmp(cmptype, "GZIP_2") || 
+      !strcasecmp(cmptype, "NONE_2") || 
       !strcasecmp(cmptype, "NONE")) {
     if (out_bitpix ==   8) return (1);
@@ -235,4 +237,5 @@
   if (!strcasecmp(cmptype, "GZIP_1") || 
       !strcasecmp(cmptype, "GZIP_2") || 
+      !strcasecmp(cmptype, "NONE_2") || 
       !strcasecmp(cmptype, "NONE")) {
     if (out_bitpix ==   8) return (1);
@@ -280,4 +283,5 @@
   if (!strcasecmp(cmptype, "GZIP_1") || 
       !strcasecmp(cmptype, "GZIP_2") || 
+      !strcasecmp(cmptype, "NONE_2") || 
       !strcasecmp(cmptype, "NONE")) {
     return (out_bitpix);
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_M.c	(revision 38366)
@@ -271,6 +271,5 @@
 
     // expected output size for this tile
-    // Nout = gfits_tile_size (matrix, otile, ztile);
-    Nout = Nout_alloc;
+    Nout = raw_pixsize*gfits_tile_size (matrix, otile, ztile);
 
     zdata = gfits_varlength_column_pointer (ftable, &zdef, row, &Nzdata);
@@ -284,5 +283,10 @@
     }
 
-    if (strcasecmp(cmptype, "GZIP_1") && strcasecmp(cmptype, "GZIP_2") && strcasecmp(cmptype, "RICE_1")) {
+    if (strcasecmp(cmptype, "NONE") && 
+	strcasecmp(cmptype, "NONE_2") && 
+	strcasecmp(cmptype, "GZIP_1") && 
+	strcasecmp(cmptype, "GZIP_2") && 
+	strcasecmp(cmptype, "RICE_1") && 
+	strcasecmp(cmptype, "RICE_ONE")) {
       // Nzdata is number of bytes
       if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;
@@ -300,5 +304,5 @@
     // XXX the tile must not be > 2GB
     // Nout going in is number of bytes 
-    if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, raw_pixsize)) ESCAPE;
+    if (!gfits_uncompress_data ((char *)zdata, Nzdata, cmptype, optname, optvalue, Noptions, out, &Nout, Nout_alloc, raw_pixsize)) ESCAPE;
 
     if (VERBOSE_DUMP && (row == 0)) {
@@ -323,5 +327,5 @@
 
     // copy the uncompressed pixels into their correct locations 	    
-    if (!strcasecmp(cmptype, "GZIP_2")) {
+    if (!strcasecmp(cmptype, "GZIP_2") || !strcasecmp(cmptype, "NONE_2")) {
       if (!gfits_distribute_gzp2 (matrix, out, Nout, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE;
     } else {
Index: /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/matrix/F_uncompress_data.c	(revision 38366)
@@ -28,11 +28,12 @@
 # define ESCAPE(RET) { fprintf (stderr, "gzip error in %s @ %s:%d\n", __func__, __FILE__, __LINE__); return (RET); }
 
-int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize) {
+int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int Nout_alloc, int out_pixsize) {
 
   int status;
 
   // do not actually uncompress : this is used for testing
-  if (!strcasecmp(cmptype, "NONE")) {
+  if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_2")) {
     memcpy (outdata, zdata, Nzdata);
+    myAssert (*Nout == Nzdata, "invalid size");
     *Nout = Nzdata / out_pixsize;
     return (TRUE);
@@ -42,5 +43,5 @@
     // unsigned long tNout = *Nout * out_pixsize;
     // input value of *Nout is number of BYTES
-    unsigned long tNout = *Nout;
+    unsigned long tNout = Nout_alloc;
 
     // for GZIP data, I need to check for and remove the header on the first block:
@@ -52,4 +53,5 @@
     status = gfits_uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata);
     if (status != Z_OK) ESCAPE(FALSE);
+    myAssert (*Nout == tNout, "uncompressed size mismatch");
     *Nout = tNout / out_pixsize;
     // output value of *Nout is number of PIXELS
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c	(revision 38366)
@@ -2,4 +2,5 @@
 # include <gfitsio.h>
 # include <zlib.h>
+# define VERBOSE_DUMP 0
 
 // the user needs to specify the various compression options:
@@ -36,4 +37,6 @@
 
   int Ntile, ztilelast;
+  if (!ztilelen) ztilelen = srcheader->Naxis[1];
+
   if (srcheader->Naxis[1] % ztilelen) {
     Ntile = srcheader->Naxis[1] / ztilelen + 1;
@@ -75,5 +78,5 @@
     if (!gfits_scan_alt (srcheader, keyword, "%C", 1, fields[i].tformat_cmt)) ESCAPE;
 
-    // XXX this should depend on the field type, but for now just use a single type (GZIP_1)
+    // for now we set all fields to the requested type
     strcpy (fields[i].zctype, zcmptype);
 
@@ -125,4 +128,11 @@
     max_width = MAX(max_width, fields[i].rowsize);
 
+    // RICE can only be used on integer fields
+    if (!strcasecmp (fields[i].zctype, "RICE_1") || !strcasecmp (fields[i].zctype, "RICE_ONE")) {
+      if (!strcmp (fields[i].datatype, "float") || !strcmp (fields[i].datatype, "double")) {
+	strcpy (fields[i].zctype, "GZIP_2");
+      }
+    }
+
     // compression type per column (XXX for now we are just using zcmptype, as set above)
     snprintf (keyword, 81, "ZCTYP%d", i+1);
@@ -152,5 +162,5 @@
 
       // copy the raw pixels from their native matrix locations to the temporary output buffer
-      if (!strcasecmp(fields[i].zctype, "GZIP_2")) {
+      if (!strcasecmp(fields[j].zctype, "GZIP_2") || !strcasecmp(fields[j].zctype, "NONE_2")) {
 	if (!gfits_collect_table_gzp2 (srctable, &fields[j], raw, row_start, Nrows)) ESCAPE;
       } else {
@@ -158,9 +168,31 @@
       }
       
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "c1: ");
+	for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
+	  fprintf (stderr, "%02hhx", raw[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
+      }
+
       // optname, optvalue = NULL, Noptions = 0
       
       int Nraw = Nrows*fields[j].Nvalues; // number of pixels
-      if (!strcmp(fields[j].zctype, "GZIP_1")) {
+      if (!strcasecmp(fields[j].zctype, "GZIP_1")) {
 	if (!gfits_byteswap_zdata (raw, Nraw * fields[j].pixsize, fields[j].pixsize)) ESCAPE;
+      }
+
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "c2: ");
+	for (k = 0; k < Nrows*fields[j].Nvalues*fields[j].pixsize; k++) {
+	  fprintf (stderr, "%02hhx", raw[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
       }
 
@@ -168,6 +200,33 @@
       if (!gfits_compress_data (zdata, &Nzdata, fields[j].zctype, NULL, NULL, 0, raw, Nraw, fields[j].pixsize, 0, 0)) ESCAPE;
       
-      if (strcasecmp(fields[j].zctype, "GZIP_1") && strcasecmp(fields[j].zctype, "GZIP_2") && strcasecmp(fields[j].zctype, "RICE_1")) {
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "c3: ");
+	for (k = 0; k < Nzdata; k++) {
+	  fprintf (stderr, "%02hhx", zdata[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
+      }
+
+      if (strcasecmp(fields[j].zctype, "NONE") &&
+	  strcasecmp(fields[j].zctype, "NONE_2") &&
+	  strcasecmp(fields[j].zctype, "GZIP_1") &&
+	  strcasecmp(fields[j].zctype, "GZIP_2") && 
+	  strcasecmp(fields[j].zctype, "RICE_1") && 
+	  strcasecmp(fields[j].zctype, "RICE_ONE")) {
 	if (!gfits_byteswap_zdata (zdata, Nzdata, fields[j].pixsize)) ESCAPE;
+      }
+
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "c4: ");
+	for (k = 0; k < Nzdata; k++) {
+	  fprintf (stderr, "%02hhx", zdata[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
       }
 
@@ -228,9 +287,14 @@
     for (i = 0; i < Nrows; i++) {
       int row = row_start + i;
-      char *tgt = &raw[i*field->rowsize + k*Nrows*field->Nvalues];
-      char *src = &table->buffer[Nx*row + field->offset + k];
-      for (j = 0; j < field->Nvalues; j++, tgt+=field->pixsize, src++) {
-	*tgt = *src;
-	myAssert (src - raw < field->
+      char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
+# ifdef BYTE_SWAP      
+      char *tblptr = &table->buffer[Nx*row + field->offset + (field->pixsize - k - 1)];
+# else
+      char *tblptr = &table->buffer[Nx*row + field->offset + k];
+# endif
+      for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
+	*rawptr = *tblptr;
+	myAssert (rawptr - raw < Nrows*field->Nvalues*field->pixsize, "oops");
+	myAssert (tblptr - table->buffer < table->header->Naxis[0]*table->header->Naxis[1], "oops");
       }
     }
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c	(revision 38366)
@@ -17,4 +17,9 @@
 
 void *gfits_get_bintable_column_data (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol) {
+  void *data = gfits_get_bintable_column_data_raw (header, table, label, type, Nrow, Ncol, FALSE);
+  return data;
+}
+
+void *gfits_get_bintable_column_data_raw (Header *header, FTable *table, char *label, char *type, off_t *Nrow, int *Ncol, char nativeOrder) {
 
   off_t Nx, Ny;
@@ -87,5 +92,5 @@
     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
       *(short *)Pout = *(short *)Pin*Bscale + Bzero;
@@ -95,5 +100,5 @@
     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
       *(int *)Pout = *(int *)Pin*Bscale + Bzero;
@@ -104,5 +109,5 @@
       for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
 # ifdef BYTE_SWAP
-	SWAP_DBLE;
+	if (!nativeOrder) { SWAP_DBLE; }
 # endif
 	*(int64_t *)Pout = *(int64_t *)Pin;
@@ -111,5 +116,5 @@
       for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
 # ifdef BYTE_SWAP
-	SWAP_DBLE;
+	if (!nativeOrder) { SWAP_DBLE; }
 # endif
 	*(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
@@ -120,5 +125,5 @@
     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
       *(float *)Pout = *(float *)Pin*Bscale + Bzero;
@@ -128,5 +133,5 @@
     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
       *(double *)Pout = *(double *)Pin*Bscale + Bzero;
@@ -176,4 +181,18 @@
   if (!gfits_get_bintable_column_type_by_N (header, N, type, Nval)) return FALSE;
   return (TRUE);
+}
+
+/***********************/
+int gfits_get_bintable_column_raw (Header *header, FTable *table, char *label, void **data, char nativeOrder) {
+
+  char type[16];
+  off_t Nrow;
+  int Ncol;
+
+  char *array = gfits_get_bintable_column_data_raw (header, table, label, type, &Nrow, &Ncol, nativeOrder);
+  if (array == NULL) return (FALSE);
+
+  *data = array;
+  return TRUE;
 }
 
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c	(revision 38366)
@@ -175,5 +175,6 @@
 
 /***********************/
-int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow) {
+// convert the input data array (of the specified intype) to the desired table data type. swap unless nativeOrder is requested
+int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder) {
 
   off_t Nx, Ny;
@@ -256,5 +257,5 @@
       *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -265,5 +266,5 @@
       *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -274,5 +275,5 @@
       *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -283,5 +284,5 @@
       *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -292,5 +293,5 @@
       *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -315,5 +316,5 @@
       *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -324,5 +325,5 @@
       *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -333,5 +334,5 @@
       *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -342,5 +343,5 @@
       *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -351,5 +352,5 @@
       *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -374,5 +375,5 @@
       *(short *)Pout = (*(short *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -383,5 +384,5 @@
       *(int *)Pout = (*(short *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -392,5 +393,5 @@
       *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -401,5 +402,5 @@
       *(float *)Pout = (*(short *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -410,5 +411,5 @@
       *(double *)Pout = (*(short *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -433,5 +434,5 @@
       *(short *)Pout = (*(int *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -442,5 +443,5 @@
       *(int *)Pout = (*(int *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -451,5 +452,5 @@
       *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -460,5 +461,5 @@
       *(float *)Pout = (*(int *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -469,5 +470,5 @@
       *(double *)Pout = (*(int *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -492,5 +493,5 @@
       *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -501,5 +502,5 @@
       *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -510,5 +511,5 @@
       *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -519,5 +520,5 @@
       *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -528,5 +529,5 @@
       *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -551,5 +552,5 @@
       *(short *)Pout = (*(float *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -560,5 +561,5 @@
       *(int *)Pout = (*(float *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -569,5 +570,5 @@
       *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -578,5 +579,5 @@
       *(float *)Pout = (*(float *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -587,5 +588,5 @@
       *(double *)Pout = (*(float *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -610,5 +611,5 @@
       *(short *)Pout = (*(double *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_BYTE;
+      if (!nativeOrder) { SWAP_BYTE; }
 # endif
     }  
@@ -619,5 +620,5 @@
       *(int *)Pout = (*(double *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -628,5 +629,5 @@
       *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
@@ -637,5 +638,5 @@
       *(float *)Pout = (*(double *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_WORD;
+      if (!nativeOrder) { SWAP_WORD; }
 # endif
     }
@@ -646,5 +647,5 @@
       *(double *)Pout = (*(double *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
-      SWAP_DBLE;
+      if (!nativeOrder) { SWAP_DBLE; }
 # endif
     }
Index: /branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c	(revision 38366)
@@ -13,8 +13,10 @@
 # if (VERBOSE_DUMP)
   int i;
-  fprintf (stderr, "%s data: ", message);
-  // for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
-  for (i = 0; i < 16; i++) {
-    fprintf (stderr, "0x%02hhx ", table->buffer[i]);
+  fprintf (stderr, "%s data:\n", message);
+  for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
+    // for (i = 0; i < 16; i++) {
+    fprintf (stderr, "%02hhx", table->buffer[i]);
+    if (i % 2) fprintf (stderr, " ");
+    if (i % 32 == 31) fprintf (stderr, "\n");
   }
   fprintf (stderr, "\n");
@@ -26,13 +28,17 @@
 # if (VERBOSE_DUMP)
   int i;
-  fprintf (stderr, "%s pntr: ", message);
-  for (i = 0; (i < 16) && (i < table->header->Naxis[0]*table->header->Naxis[1]); i++) {
-    fprintf (stderr, "0x%02hhx ", table->buffer[i]);
+  fprintf (stderr, "%s pntr:\n", message);
+  for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
+    fprintf (stderr, "%02hhx", table->buffer[i]);
+    if (i % 2) fprintf (stderr, " ");
+    if (i % 32 == 31) fprintf (stderr, "\n");
   }
   fprintf (stderr, "\n");
 
-  fprintf (stderr, "%s data: ", message);
-  for (i = 0; (i < 16) && (i < table->header->pcount); i++) {
-    fprintf (stderr, "0x%02hhx ", table->buffer[table->heap_start + i]);
+  fprintf (stderr, "%s data:\n", message);
+  for (i = 0; i < table->header->pcount; i++) {
+    fprintf (stderr, "%02hhx", table->buffer[table->heap_start + i]);
+    if (i % 2) fprintf (stderr, " ");
+    if (i % 32 == 31) fprintf (stderr, "\n");
   }
   fprintf (stderr, "\n");
@@ -156,12 +162,50 @@
       if (!zdata) ESCAPE;
     
-      if (strcasecmp(fields[i].zctype, "GZIP_1") && strcasecmp(fields[i].zctype, "GZIP_2") && strcasecmp(fields[i].zctype, "RICE_1")) {
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "u4: ");
+	for (k = 0; k < Nzdata; k++) {
+	  fprintf (stderr, "%02hhx", zdata[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
+      }
+
+      if (strcasecmp(fields[i].zctype, "NONE") && 
+	  strcasecmp(fields[i].zctype, "NONE_2") && 
+	  strcasecmp(fields[i].zctype, "GZIP_1") && 
+	  strcasecmp(fields[i].zctype, "GZIP_2") && 
+	  strcasecmp(fields[i].zctype, "RICE_1") && 
+	  strcasecmp(fields[i].zctype, "RICE_ONE")) {
 	// Nzdata is number of bytes
 	if (!gfits_byteswap_zdata (zdata, Nzdata, fields[i].pixsize)) ESCAPE;
       }
 
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "u3: ");
+	for (k = 0; k < Nzdata; k++) {
+	  fprintf (stderr, "%02hhx", zdata[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
+      }
+
       int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
-      int Nraw = Nraw_alloc; // expected number of pixel: Nrows*fields[i].Nvalues
-      if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, fields[i].pixsize)) ESCAPE;
+      int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
+      if (!gfits_uncompress_data (zdata, Nzdata, fields[i].zctype, NULL, NULL, 0, raw, &Nraw, Nraw_alloc, fields[i].pixsize)) ESCAPE;
+
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "u2: ");
+	for (k = 0; k < Nraw*fields[i].pixsize; k++) {
+	  fprintf (stderr, "%02hhx", raw[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
+      }
 
       if (!strcasecmp(fields[i].zctype, "GZIP_1")) {
@@ -170,4 +214,15 @@
       }
 
+      if (VERBOSE_DUMP) {
+	int k;
+	fprintf (stderr, "u1: ");
+	for (k = 0; k < Nraw*fields[i].pixsize; k++) {
+	  fprintf (stderr, "%02hhx", raw[k]);
+	  if (k % 2) fprintf (stderr, " ");
+	  // if (k % 32 == 31) fprintf (stderr, "\n");
+	}
+	fprintf (stderr, "\n");
+      }
+
       // int valid = (row == 0) && (i == 0);
 
@@ -177,5 +232,5 @@
 
       // copy the raw pixels from their native matrix locations to the temporary output buffer
-      if (!strcasecmp(fields[i].zctype, "GZIP_2")) {
+      if (!strcasecmp(fields[i].zctype, "GZIP_2") || !strcasecmp(fields[i].zctype, "NONE_2")) {
 	if (!gfits_distribute_table_gzp2 (tgttable, &fields[i], raw, row_start, Nrows)) ESCAPE;
       } else {
@@ -233,8 +288,12 @@
     for (i = 0; i < Nrows; i++) {
       int row = row_start + i;
-      char *src = &raw[i*field->rowsize + k*Nrows*field->Nvalues];
-      char *tgt = &table->buffer[Nx*row + field->offset + k];
-      for (j = 0; j < field->Nvalues; j++, tgt+=field->pixsize, src++) {
-	*tgt = *src;
+      char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
+# ifdef BYTE_SWAP      
+      char *tblptr = &table->buffer[Nx*row + field->offset + (field->pixsize - k - 1)];
+# else
+      char *tblptr = &table->buffer[Nx*row + field->offset + k];
+# endif
+      for (j = 0; j < field->Nvalues; j++, tblptr += field->pixsize, rawptr++) {
+	*tblptr = *rawptr;
       }
     }
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/compress.sh	(revision 38366)
@@ -5,5 +5,5 @@
   tapPLAN 88
 
-  foreach mode NONE GZIP_1 GZIP_2 RICE_1
+  foreach mode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE
   # foreach mode GZIP_1
   # foreach mode GZIP_2
@@ -11,5 +11,6 @@
     foreach bitpix 8 16 32 -32 -64
     # foreach bitpix 32
-      if (($mode == RICE_1) && ($bitpix < 0)) continue ; # RICE_1 is for int only
+      if (($mode == RICE_1)   && ($bitpix < 0)) continue ; # RICE_1 is for int only
+      if (($mode == RICE_ONE) && ($bitpix < 0)) continue ; # RICE_1 is for int only
       tapDIAG 2 "===== bitpix = $bitpix, mode = $mode ====="
       test_image_single $bitpix $mode
@@ -29,4 +30,6 @@
  $bitpix = $1
  $cmpmode = $2
+
+ delete -q x z b c d e
 
  mcreate z 8 8
@@ -121,11 +124,20 @@
 macro test_table_all_single_column
 
+  tapPLAN 88
+
   local format cmpmode
 
-  foreach cmpmode NONE GZIP_1
+  foreach cmpmode NONE GZIP_1 GZIP_2 RICE_1 RICE_ONE
     foreach format B I J K E D
+      if (($cmpmode == RICE_1)   && ($format == E)) continue ; # RICE_1 is for int only
+      if (($cmpmode == RICE_ONE) && ($format == E)) continue ; # RICE_1 is for int only
+      if (($cmpmode == RICE_1)   && ($format == D)) continue ; # RICE_1 is for int only
+      if (($cmpmode == RICE_ONE) && ($format == D)) continue ; # RICE_1 is for int only
+      if (($cmpmode == RICE_1)   && ($format == K)) continue ; # RICE_1 is for int only
+      if (($cmpmode == RICE_ONE) && ($format == K)) continue ; # RICE_1 is for int only
       test_table_single_column $cmpmode $format
     end
   end
+  tapDONE
 end
 
@@ -136,16 +148,21 @@
  end
 
- local cmpmode
+ local cmpmode format
  $cmpmode = $1
-
- delete -q x
-
- $NPT = 1000
- create x 0 $NPT
-
- local format
+ $format = $2
+
+ tapDIAG 2 "===== testing $cmpmode $format ====="
+
+ delete -q x dv
+
+ $NPT = 10000
+
+ if ($format == B)
+   create x -128 128
+ else
+   create x 0 $NPT
+ end
 
  $fields = x 
- $format = $2
 
  write -fits test test.raw.tbl $fields -format $format
@@ -157,5 +174,5 @@
  end
 
- echo "===== $cmpmode $format raw ====="
+ tapDIAG 2 "===== $cmpmode $format raw ====="
  data test.raw.tbl
  read -fits test $fields
@@ -163,9 +180,11 @@
  foreach f $fields
    set dv = $f - $f\_raw
-   vstat dv
- end
- delete -q $fields
-
- echo "===== $cmpmode $format cmp ====="
+   vstat -q dv
+   tapOK {abs($MEAN)  < 0.001} "read our raw $cmpmode $format (MEAN  = $MEAN)"
+   tapOK {$SIGMA      < 0.001} "read our raw $cmpmode $format (SIGMA = $SIGMA)"
+ end
+ delete -q $fields
+
+ tapDIAG 2 "===== $cmpmode $format cmp ====="
  data test.cmp.tbl
  read -fits test $fields
@@ -173,6 +192,53 @@
  foreach f $fields
    set dv = $f - $f\_raw
-   vstat dv
- end
+   vstat -q dv
+   tapOK {abs($MEAN)  < 0.001} "read our cmp $cmpmode $format (MEAN  = $MEAN)"
+   tapOK {$SIGMA      < 0.001} "read our cmp $cmpmode $format (SIGMA = $SIGMA)"
+ end
+
+ if ($cmpmode == NONE) return; # funpack will not recognize NONE
+ if ($cmpmode == RICE_ONE) return; # funpack will not recognize RICE_ONE for tables
+ if (($cmpmode == GZIP_2) && ($format == B)) return; # GZIP_2 invalid for B
+
+ tapDIAG 2 "===== $cmpmode $format fpack ====="
+
+ # try to run fpack on ours
+ if (1)
+   tapEXEC /bin/cp -f test.raw.tbl test.fpk.tbl
+   tapEXEC fpack -table -F test.fpk.tbl
+   
+   data test.fpk.tbl
+   read -fits test $fields
+   
+   foreach f $fields
+     set dv = $f - $f\_raw
+     vstat -q dv
+     tapOK {abs($MEAN)  < 0.001} "read fpack $cmpmode $format (MEAN  = $MEAN)"
+     tapOK {$SIGMA      < 0.001} "read fpack $cmpmode $format (SIGMA = $SIGMA)"
+   end
+   delete -q $fields
+ end
+
+ break -auto off
+ echo $cmpmode $format
+ exec ls test.cmp.tbl test.fpk.tbl | fields -x 0 PCOUNT  ZCTYP1
+ break -auto on
+
+ tapDIAG 2 "===== $cmpmode $format funpack ====="
+
+ # try to run fpack on ours
+ tapEXEC /bin/cp -f test.cmp.tbl test.fun.tbl
+ tapEXEC funpack -F test.fun.tbl
+
+ data test.fun.tbl
+ read -fits test $fields
+
+ foreach f $fields
+   set dv = $f - $f\_raw
+   vstat -q dv
+   tapOK {abs($MEAN)  < 0.001} "read funpack $cmpmode $format (MEAN  = $MEAN)"
+   tapOK {$SIGMA      < 0.001} "read funpack $cmpmode $format (SIGMA = $SIGMA)"
+ end
+ delete -q $fields
 end
 
@@ -199,5 +265,5 @@
  delete -q x y z 
 
- $NPT = 1000
+ $NPT = 10000
  create x 0 $NPT
  set y = x^2
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/imagecomp.c	(revision 38366)
@@ -5,14 +5,7 @@
 int test_compress (int bitpix, char *zcmptype);
 
-// char *cmptype[] = {"NONE", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL};
-// char *cmptype[] = {"NONE", "GZIP_1", "RICE_1", "RICE_ONE", NULL};
-// int bitpix[] = {8, 16, 32, -32, -64, 0};
-
-// char *cmptype[] = {"NONE", "GZIP_1", NULL};
-// char *cmptype[] = {"PLIO_1", NULL};
-// int bitpix[] = {8, 16, 32, 0};
-
-char *cmptype[] = {"GZIP_2", NULL};
-int bitpix[] = {-32, 0};
+// char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "PLIO_1", "RICE_1", "RICE_ONE", "HCOMPRESS_1", NULL};
+char *cmptype[] = {"NONE", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", NULL};
+int bitpix[] = {8, 16, 32, -32, -64, 0};
 
 int main (int argc, char **argv) {
@@ -25,19 +18,9 @@
   for (i = 0; cmptype[i]; i++) {
     for (j = 0; bitpix[j]; j++) {
+      if (!strcasecmp (cmptype[i], "RICE_1") && (bitpix[j] < 0)) continue;
+      if (!strcasecmp (cmptype[i], "RICE_ONE") && (bitpix[j] < 0)) continue;
       test_compress (bitpix[j], cmptype[i]);
     }
   }
-
-  // test_compress ( 16, "NONE");
-  // test_compress ( 32, "NONE");
-  // test_compress (-32, "NONE");
-  // test_compress (-64, "NONE");
-  // 
-  // test_compress (  8, "GZIP_1");
-  // test_compress ( 16, "GZIP_1");
-  // test_compress ( 32, "GZIP_1");
-  // test_compress (-32, "GZIP_1");
-  // test_compress (-64, "GZIP_1");
-
   exit (0);
 }
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c	(revision 38365)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/tablecomp.c	(revision 38366)
@@ -4,4 +4,5 @@
 
 int test_compress (char *zcmptype);
+int test_compress_single_full (char *zcmptype);
 
 int main (int argc, char **argv) {
@@ -10,10 +11,15 @@
 
   diag ("libfits tablecomp.c tests");
+
+  test_compress_single_full ("GZIP_1");
+  test_compress_single_full ("RICE_1");
 
   test_compress (NULL);
   test_compress ("NONE");
+  test_compress ("NONE_2");
   test_compress ("GZIP_1");
   test_compress ("GZIP_2");
-  // test_compress ("GZIP_1");
+  test_compress ("RICE_1");
+  test_compress ("RICE_ONE");
 
   exit (0);
@@ -31,4 +37,5 @@
   ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
 
+  ok (gfits_define_bintable_column (&header, "B", "VAL", "val", "none", 1.0, 0.0), "defined byte column");
   ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
   ok (gfits_define_bintable_column (&header, "J", "ID",  "ID", "none", 1.0, 0.0),  "defined int column");
@@ -40,4 +47,5 @@
 
   int Nval = 1000;
+  char  *VAL;  ALLOCATE (VAL, char,   Nval);
   short *SEQ;  ALLOCATE (SEQ, short,  Nval);
   int    *ID;  ALLOCATE (ID,  int,    Nval);
@@ -47,4 +55,5 @@
   int i;
   for (i = 0; i < Nval; i++) {
+    VAL[i] = i + 32;
     SEQ[i] = i;
     ID[i] = 10000*i + 100*i;
@@ -54,4 +63,5 @@
 
   // add the columns to the output array
+  ok (gfits_set_bintable_column (&header, &ftable, "VAL", VAL, Nval), "set byte   table column");
   ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
   ok (gfits_set_bintable_column (&header, &ftable,  "ID",  ID, Nval), "set int    table column");
@@ -84,4 +94,5 @@
   off_t Nrow;
 
+  char   *VAL_t = gfits_get_bintable_column_data (outheader, outtable, "VAL", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"),   "read byte   table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
   short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
   int     *ID_t = gfits_get_bintable_column_data (outheader, outtable,  "ID", type, &Nrow, &Ncol); ok (!strcmp (type, "int"),    "read int    table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
@@ -90,4 +101,5 @@
 
   // count mismatched values
+  int Nvalue = 0;
   int Nseq = 0;
   int  Nid = 0;
@@ -95,4 +107,5 @@
   int   Ny = 0;
   for (i = 0; i < Nval; i++) {
+    if (VAL[i] != VAL_t[i]) Nvalue++;
     if (SEQ[i] != SEQ_t[i]) Nseq++;
     if ( ID[i] !=  ID_t[i]) Nid++;
@@ -101,8 +114,9 @@
   }
 
-  ok (!Nseq, "short  values match (input vs output)");
-  ok (!Nid,  "int    values match (input vs output)");
-  ok (!Nx,   "float  values match (input vs output)");
-  ok (!Ny,   "double values match (input vs output)");
+  ok (!Nvalue, "byte   values match (input vs output)");
+  ok (!Nseq,   "short  values match (input vs output)");
+  ok (!Nid,    "int    values match (input vs output)");
+  ok (!Nx,     "float  values match (input vs output)");
+  ok (!Ny,     "double values match (input vs output)");
 
   gfits_free_header (&header);
@@ -115,2 +129,73 @@
 }
 
+int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE"
+
+  Header header;
+  FTable ftable;
+
+  diag ("--- starting test_compress with zcmptype %s ---", zcmptype);
+  ok (gfits_init_header (&header), "inited the header");
+  ok (gfits_init_table (&ftable), "inited the table");
+
+  ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header");
+
+  ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column");
+  
+  // generate the output array that carries the data
+  ok (gfits_create_table (&header, &ftable), "created the basic table");
+
+  int Nval = 1000;
+  short *SEQ;  ALLOCATE (SEQ, short,  Nval);
+  
+  int i;
+  for (i = 0; i < Nval; i++) {
+    SEQ[i] = i;
+  }     
+
+  // add the columns to the output array
+  ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short  table column");
+
+  Header *outheader = &header;
+  FTable *outtable = &ftable;
+
+  if (zcmptype) {
+    Header cmpheader;
+    FTable cmptable;
+    cmptable.header = &cmpheader;
+    ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table");
+
+    Header rawheader;
+    FTable rawtable;
+    rawtable.header = &rawheader;
+    ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table");
+    
+    gfits_free_header (&cmpheader);
+    gfits_free_table (&cmptable);
+
+    outheader = &rawheader;
+    outtable  = &rawtable;
+  }
+
+  char type[16];
+  int Ncol;
+  off_t Nrow;
+
+  short  *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"),  "read short  table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols");
+
+  // count mismatched values
+  int Nseq = 0;
+  for (i = 0; i < Nval; i++) {
+    if (SEQ[i] != SEQ_t[i]) Nseq++;
+  }
+
+  ok (!Nseq,   "short  values match (input vs output)");
+
+  gfits_free_header (&header);
+  gfits_free_table (&ftable);
+  if (zcmptype) {
+    gfits_free_header (outheader);
+    gfits_free_table (outtable);
+  }
+  return TRUE;
+}
+
Index: /branches/eam_branches/ohana.20150429/src/libfits/test/tap.dvo
===================================================================
--- /branches/eam_branches/ohana.20150429/src/libfits/test/tap.dvo	(revision 38366)
+++ /branches/eam_branches/ohana.20150429/src/libfits/test/tap.dvo	(revision 38366)
@@ -0,0 +1,116 @@
+# -*-sh-*-
+
+if (not($?TAP_BREAK)) set TAP_BREAK = 0
+if (not($?TAP_VERBOSE)) set TAP_VERBOSE = 0
+
+macro tapEXEC
+  if ($0 < 3) 
+    echo "USAGE: tapEXEC (command)"
+    break
+  end
+
+  local i cmd result
+
+  $cmd = ""
+  for i 1 $0
+    $cmd = $cmd $$i
+  end
+
+  if ($TAP_VERBOSE >= 2) echo $cmd
+
+  break -auto off
+  exec $cmd >& tap.log
+  $result = $STATUS
+  break -auto on
+
+  if (not($result)) 
+    exec cat tap.log
+    echo "not ok : $cmd"
+    $TAP_NFAIL ++
+    $TAP_LAST = 0
+    if ($TAP_BREAK)
+     break
+    end
+  else
+    if ($TAP_VERBOSE >= 1) echo "ok : $cmd"
+    $TAP_LAST = 1
+  end
+  $TAP_NDONE ++
+end
+
+macro tapOK
+  if ($0 != 3) 
+    echo "USAGE: tapOK (condition) (message)"
+    break
+  end
+
+  if ($1)
+    if ($TAP_VERBOSE >= 1)
+      echo "ok : $2"
+    end
+    $TAP_LAST = 1
+  else
+    echo "not ok : $2"
+    $TAP_NFAIL ++
+    $TAP_LAST = 0
+    if ($TAP_BREAK)
+     break
+    end
+  end
+  $TAP_NDONE ++
+end
+
+macro tapPLAN
+  if ($0 != 2) 
+    echo "USAGE: tapPLAN (Ntests)"
+    break
+  end
+
+  $TAP_NTEST = $1
+  $TAP_NFAIL = 0
+  $TAP_NSKIP = 0
+  $TAP_NDONE = 0
+  if (not($?TAP_BREAK)) set TAP_BREAK = 0
+end
+
+macro tapDIAG
+  if ($0 != 3) 
+    echo "USAGE: tapDIAG (level) (message)"
+    break
+  end
+
+  if ($TAP_VERBOSE >= $1) echo "$2"
+end
+
+macro tapSKIP
+  if ($0 != 2) 
+    echo "USAGE: tapSKIP (nskip)"
+    break
+  end
+
+  $TAP_NSKIP += $1
+  $TAP_NDONE += $1
+end
+
+macro tapDONE
+  if ($0 != 1) 
+    echo "USAGE: tapDONE"
+    break
+  end
+
+  if ($TAP_NDONE != $TAP_NTEST) 
+    echo "planned tests ($TAP_NTEST) not equal to done tests ($TAP_NDONE)"
+  end
+
+  if ($TAP_NFAIL) 
+    echo "failed $TAP_NFAIL of $TAP_NDONE"
+  end
+
+  if ($TAP_NSKIP) 
+    echo "skipped $TAP_NSKIP of $TAP_NDONE"
+  end
+
+  if ($TAP_NFAIL + $TAP_NSKIP == 0) 
+    echo "passed $TAP_NDONE tests"
+  end
+end
