Index: trunk/psLib/src/fits/psFits.c
===================================================================
--- trunk/psLib/src/fits/psFits.c	(revision 12801)
+++ trunk/psLib/src/fits/psFits.c	(revision 14868)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-11 17:01:50 $
+ *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-17 21:35:35 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -562,4 +562,68 @@
 
 
+bool psFitsSetCompression(
+    psFits* fits,                       ///< psFits object to close
+    psFitsCompressionType type,         ///< type of compression
+    int ndim,                           ///< number of dim in tile size array
+    long *tilesize,                     ///< pointer to an array defining compression tile size
+    int noisebits,                      ///< noise bits
+    int scale,                          ///< hcompress scale
+    int smooth                          ///< hcompress smothing
+)
+{
+    // convert psFitsCompressionType to cfitsio compression types
+    int comptype;
+    switch (type) {
+        case PS_FITS_COMPRESS_NONE:
+            comptype = 0x0;
+            break;
+        case PS_FITS_COMPRESS_GZIP:
+            comptype = GZIP_1;
+            break;
+        case PS_FITS_COMPRESS_RICE:
+            comptype = RICE_1;
+            break;
+        case PS_FITS_COMPRESS_HCOMPRESS:
+            comptype = HCOMPRESS_1;
+            break;
+        case PS_FITS_COMPRESS_PLIO:
+            comptype = PLIO_1;
+            break;
+        default:
+            psError(PS_ERR_UNKNOWN, true, "invalid psFitsCompressionType");
+            return false;
+    }
+
+    int status = false;
+    fits_set_compression_type(fits->fd, comptype, &status);
+    if (!status) {
+        goto ERROR;
+    }
+    fits_set_tile_dim(fits->fd, ndim, tilesize, &status);
+    if (!status) {
+        goto ERROR;
+    }
+    fits_set_noise_bits(fits->fd, noisebits, &status);
+    if (!status) {
+        goto ERROR;
+    }
+#if FITS_HCOMP
+    fits_set_hcomp_scale(fits->fd, scale, &status);
+    if (!status) {
+        goto ERROR;
+    }
+    fits_set_hcomp_smooth(fits->fd, smooth, &status);
+    if (!status) {
+        goto ERROR;
+    }
+#endif // FITS_HCOMP
+
+ERROR:
+    fits_set_compression_type(fits->fd, 0x0, &status);
+    psError(PS_ERR_UNKNOWN, true, "failed to configure compression - disabling");
+    return false;
+}
+
+
 psDataType p_psFitsTypeFromCfitsio(int datatype)
 {
