#!/bin/bash -e # Usage: dfm2h5 # # This script converts DFM output consisting of binary files and # associated header files to to HDF5. # # EXAMPLES # Convert all DFM data in a directory # dfm2h5 *.hdr # See the contents of an HDF5 file # h5dump 0100001.h5 # # HDF5 INSTALL # Obtain sources from ftp://ftp.ncsa.uiuc.edu/HDF/HDF5/current/src # gunzip hdf5-1.6.1.tar.gz # tar xvf hdf5-1.6.1.tar # cd hdf5-1.6.1 # make check # make install # This will install in /usr/local/ # To change this default see release_docs/INSTALL # You also may want to install HDF4 and the h4h5tools to convert # to HDF4 for applications that do not yet support HDF5 # # MATLAB # HDF5 support was added to Matlab for version 6.5.1 although # it does not function properly yet. Eventually you should be # able to read an HDF5 file with to following command: # data = hdf5read('0100001.h5','/dataset0') # # Geoffrey Ely gely@ucsd.edu while getopts d opt; do case $opt in d) deleteout="yes" ;; esac done shift `expr $OPTIND - 1` for file in "$@"; do echo $file base="${file%.hdr}" set `cat $file` dims="${1},$(( ${4} - ${2} + 1 )),$(( ${7} - ${5} + 1 )),$(( ${10} - ${8} + 1 ))" outsep=${19} if [ "${outsep}" = "T" ]; then for (( i=${11}; i<=${13}; i=$i+${12} )); do num=`printf "%05d" $i` [ "$deleteout" = "yes" ] && rm -f "${base}${num}.h5" h5import "${base}${num}.bin" -d "$dims" -o "${base}${num}.h5" hdfimport "${base}${num}.bin" -o "${base}${num}.hdf" done else dims="$dims,$(( ( ${13} - ${11} ) / ${12} + 1 ))" [ "$deleteout" = "yes" ] && rm -f "${base}mux.h5" h5import "${base}mux.bin" -d "$dims" -o "${base}mux.h5" fi done