Index: /trunk/Mars/mfileio/MWriteFitsFile.cc
===================================================================
--- /trunk/Mars/mfileio/MWriteFitsFile.cc	(revision 19725)
+++ /trunk/Mars/mfileio/MWriteFitsFile.cc	(revision 19726)
@@ -464,5 +464,5 @@
       {
 
-      ofits* fitsTable = new ofits();
+      ofits* fitsTable = new zofits();
       fitsTable->AllowCommentsTrimming(true);
       TString dol = fileNameNoExt;
@@ -476,7 +476,11 @@
           dol = dol(0, dol.Length()-5);
       }
+      if (dol(dol.Length()-8, dol.Length()) == ".fits.fz")
+      {
+          dol = dol(0, dol.Length()-8);
+      }
       dol += "_";
       dol += i_table->first;
-      dol += ".fits";
+      dol += ".fits.fz";
       fitsTable->open(dol.Data());
       *fLog << inf << "Opening FITS file: " << dol.Data() << endl;
@@ -551,5 +555,5 @@
          dol2 += "_";
          dol2 += i_table->first;
-         dol2 += ".fits";
+         dol2 += ".fits.fz";
 
          if (fOpenOption == "RECREATE") 
@@ -1150,5 +1154,19 @@
 //    *fLog << warn << "In table " << tableName << " Adding column |" << truncatedName << "| |" << truncatedComment << "| |" << count << "| |" << typeChar;
 //    *fLog << warn << "| Real: "<< columnName << " comment: " << comment << endl;
-    fFitsTables[tableName]->AddColumn(count, typeChar, truncatedName, unit, truncatedComment);
+
+    if (count>=1440 && colWidth>count)
+    {
+        vector<uint16_t> processing;
+        if (count>1440)
+            processing.push_back(FITS::kFactSmoothing);
+        processing.push_back(FITS::kFactHuffman16);
+
+        const FITS::Compression comp(processing, FITS::kOrderByRow);
+        fFitsTables[tableName]->AddColumn(comp, count, typeChar, truncatedName, unit, truncatedComment);
+
+        *fLog << inf2 << "FITS: Compressing '" << truncatedName << "' [" << count << "]" << endl;
+    }
+    else
+        fFitsTables[tableName]->AddColumn(count, typeChar, truncatedName, unit, truncatedComment);
 }
 
