]> Creatis software - clitk.git/commitdiff
new script for merging dose per energy files
authorMarc Vila-Oliva <vilaoliva@linux15.dg.creatis.insa-lyon.fr>
Thu, 4 Jul 2013 17:06:58 +0000 (19:06 +0200)
committerMarc Vila-Oliva <vilaoliva@linux15.dg.creatis.insa-lyon.fr>
Thu, 4 Jul 2013 17:06:58 +0000 (19:06 +0200)
cluster_tools/mergeDosePerEnergyFile.sh [new file with mode: 0755]

diff --git a/cluster_tools/mergeDosePerEnergyFile.sh b/cluster_tools/mergeDosePerEnergyFile.sh
new file mode 100755 (executable)
index 0000000..f849016
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+set -u
+
+function usage {
+       echo "$0 -i <file1> -j <file2> -o <result>"
+       exit 1
+}
+
+if [ $# != 6 ]
+then
+       usage
+fi
+
+IN1=$2
+IN2=$4
+RESULT=$6
+
+test -f ${IN1} && test -f ${IN2} || usage
+
+TMP="$(mktemp)"
+echo "merging dose file"
+for PARAM in `awk '$1 == "#" {print $3}' ${IN1}`
+do
+        echo "merging ${PARAM}"
+       V1=`awk -v P=${PARAM} '$3 == P {print $4}' ${IN1} `
+       V2=`awk -v P=${PARAM} '$3 == P {print $4}' ${IN2} `
+        V1=`echo ${V1} | sed -e 's/[eE]+*/\*10\^/'`
+        V2=`echo ${V2} | sed -e 's/[eE]+*/\*10\^/'`
+       R=`echo "${V1} + ${V2}" | bc -l`
+        test -z "${R}" && continue
+        echo "# energydose ${PARAM} ${R}" >> ${TMP}
+done
+mv -f ${TMP} ${RESULT}