function merge_mhd_image {
local merged="$1"
local merged_bin="${merged%.*}.raw"
+ local last_character=${merged#${merged%?}}
shift
echo " ${indent}entering mhd image merger"
echo " ${indent}merger is ${mhdImageMerger}"
then
update_bar ${count} "copying first partial result ${partial}"
cp "${partial}" "${merged}"
- cp "${partial_bin}" "${merged_bin%.*}.${partial_bin##*.}"
+ if test "$last_character" = "d"
+ then
+ cp "${partial_bin}" "${merged_bin%.*}.${partial_bin##*.}"
+ fi
continue
fi
update_bar ${count} "adding ${partial}"
${mhdImageMerger} -t 0 -i "${partial}" -j "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${mhdImageMerger}"
- mv "${merged_bin}" "${merged_bin%.*}.${partial_bin##*.}"
- sed -i "s/$(basename "${merged_bin}")/$(basename "${merged_bin%.*}.${partial_bin##*.}")/" "${merged}"
+ if test "$last_character" = "d" && test "${merged_bin}" != "${merged_bin%.*}.${partial_bin##*.}"
+ then
+ mv "${merged_bin}" "${merged_bin%.*}.${partial_bin##*.}"
+ sed -i "s/$(basename "${merged_bin}")/$(basename "${merged_bin%.*}.${partial_bin##*.}")/" "${merged}"
+ fi
done
end_bar
echo " ${indent}merged ${count} files"
if [[ "${firstpartialoutputfile}" == *Uncertainty* ]]
then
- if test "${firstpartialoutputextension}" == "mhd"
+ if test "${firstpartialoutputextension}" == "mhd" || test "${firstpartialoutputextension}" == "mha"
then
echo "${indent}Uncertainty file found: ${firstpartialoutputfile}"
## search for sum
echo "${indent}${squared_merged_file} found"
## search for NumberOfEvent
totalEvents=0;
- for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+ for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
do
#echo $outputfile
if grep -q 'NumberOfEvent' "${outputdir}/${outputfile}"
warning "${totalEvents} not positive. A at least one stat file (SimulationStatisticActor) must be provided. Error, no uncertainty computed"
return;
fi
+ else
+ error "merge_dispatcher_uncertainty does not handle ${firstpartialoutputfile} files"
fi
fi
echo ""
echo "Merging done. Special case for statistical uncertainty"
-for outputfile in $(find "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/output.*\.(hdr|mhd|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+for outputfile in $(find "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
do
merge_dispatcher_uncertainty "${outputfile}"
done