Index: /trunk/DataStore/scripts/dsgetfileset
===================================================================
--- /trunk/DataStore/scripts/dsgetfileset	(revision 27904)
+++ /trunk/DataStore/scripts/dsgetfileset	(revision 27905)
@@ -17,5 +17,5 @@
 use File::Basename qw( basename );
 
-my ($uri, $outdir, $timeout, $skip_checks, $no_proxy, $verbose);
+my ($uri, $outdir, $timeout, $skip_checks, $unpack, $no_proxy, $verbose);
 
 GetOptions(
@@ -24,4 +24,5 @@
     'timeout|t=s'       => \$timeout,
     'skip-checks'       => \$skip_checks,
+    'unpack'            => \$unpack,
     'no-proxy'          => \$no_proxy,
     'verbose|v'         => \$verbose,
@@ -89,4 +90,24 @@
         exit $status;
     }
+
+    if ($unpack) {
+        my $file_type = `file $outfile`;
+        if ($file_type =~ /FITS/) {
+            my $packed_file = "${outfile}.fz";
+            rename $outfile, $packed_file
+                or die "failed to rename $outfile $packed_file";
+
+            # unpack the fits file and delete the input
+            # This works whether or not the file is compressed
+            $command = "funpack -D $packed_file";
+            print "$command\n" if $verbose;
+            $rc = system $command;
+            if ($rc) {
+                my $status = $rc >> 8;
+                print STDERR "failed to funpack $outfile: rc: $rc status: $status\n";
+                exit $status;
+            }
+        }
+    }
 }
 
@@ -129,4 +150,8 @@
 
 Do not load proxy environment variables.
+
+=item * --unpack
+
+Uncompress fits files if compressed
 
 Optional.
