Mercurial > hg > minc-tools
changeset 725:8aa8af50c227
Added support for compressed files.
author | neelin <neelin> |
---|---|
date | Tue, 24 Jan 1995 10:19:09 +0000 |
parents | f5d1d15bf512 |
children | a6256a2f72eb |
files | progs/mincheader/mincheader progs/mincheader/mincheader.man1 |
diffstat | 2 files changed, 57 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/progs/mincheader/mincheader +++ b/progs/mincheader/mincheader @@ -1,9 +1,12 @@ #! /bin/csh -f # Modifications: $Log: mincheader,v $ -# Modifications: Revision 2.0 1994-09-28 10:34:10 neelin -# Modifications: Release of minc version 0.2 +# Modifications: Revision 2.1 1995-01-24 10:19:09 neelin +# Modifications: Added support for compressed files. # Modifications: +# Revision 2.0 94/09/28 10:34:10 neelin +# Release of minc version 0.2 +# # Revision 1.6 94/09/28 10:34:06 neelin # Pre-release # @@ -18,21 +21,55 @@ # # -# Check arguments +# Set defaults +if (! $?TMPDIR) set TMPDIR = /usr/tmp +set header_opts = "-header_only" +set header_only = 1 -if ($#argv != 1) then - echo "Usage: $0 <minc file>" +# Check arguments +set usage = "Usage: $0 [-data] <minc file>" +if (($#argv < 1) || ($#argv > 2)) then + echo "$usage" exit -1 endif -if (("$1" == "-help") || ("$1" == "-h") || ("$1" == "")) then - echo "Usage: $0 <minc file>" - exit +if ($#argv == 1) then + if (("$1" == "-help") || ("$1" == "-h") || ("$1" == "")) then + echo "$usage" + exit -1 + endif +else + if ("$1" != "-data") then + echo "$usage" + exit -1 + endif + set header_opts = "-all_data" + set header_only = 0 + shift endif set file = $1 -# Get variables names (excluding image): remove leading "image", remove word -# "image", collapse multiple blanks to one, remove leading blanks, remove -# trailing blanks, replace blanks with commas -set vars = `mincinfo -varnames $file | sed -e 's/^image //g' -e 's/ image / /g' -e 's/ */ /g' -e 's/^ //' -e 's/ $//' -e 's/ /,/g'` +# Set interrupt handling +onintr cleanup + +# Expand file if needed +set name = $file:t +set tempfile = $TMPDIR/mincheader-$$-$name:r +set dumpfile = `mincexpand $file $tempfile -name_only $header_opts` + +# Dump header only for compressed file +if (("$dumpfile" == "$tempfile") && ($header_only)) then + ncdump -h $dumpfile -ncdump -v "$vars" $1 +# Dump everything if we've got it +else + +# Get variables names (excluding image): remove leading "image", remove word +# "image", collapse multiple blanks to one, remove leading blanks, remove +# trailing blanks, replace blanks with commas + set vars = `mincinfo -varnames $dumpfile | sed -e 's/^image //g' -e 's/ image / /g' -e 's/ */ /g' -e 's/^ //' -e 's/ $//' -e 's/ /,/g'` + ncdump -v "$vars" $dumpfile +endif + + +cleanup: + rm -f $tempfile
--- a/progs/mincheader/mincheader.man1 +++ b/progs/mincheader/mincheader.man1 @@ -8,7 +8,7 @@ .\" software for any purpose. It is provided "as is" without .\" express or implied warranty. .\" -.\" $Header: /private-cvsroot/minc/progs/mincheader/mincheader.man1,v 2.0 1994-09-28 10:34:11 neelin Exp $ +.\" $Header: /private-cvsroot/minc/progs/mincheader/mincheader.man1,v 2.1 1995-01-24 10:19:17 neelin Exp $ .\" .TH MINCHEADER 1 "MINC Image File Format" @@ -17,13 +17,17 @@ .SH SYNOPSIS .B mincheader -<infile> <outfile> +[-data] <infile> .SH DESCRIPTION .I Mincheader prints out the header information for a minc file in cdl format (the netCDF text format). Mincheader simply calls ncdump, writing out all -information except the image data. +information except the image data. If the input file is compressed, +then its header is decompressed and only the header is printed. If the +.I -data +option is given, then the whole file is decompressed and all data +(except the image) is dumped. .SH AUTHOR Peter Neelin