#!/bin/bash

function worker {
	echo "preparing data in $1";
	./prepare_abstimes.sh $1;
	./prepare_doffsets.sh $1;
	matlab -nodisplay -r "prepare_offsets('$1'); exit;";
	#prepare data in histogram gnuplot formate
	./prepare_hcounts.sh	$1;
	./prepare_hpercents.sh	$1;
	#generate hostograms based on data
	./make_histograms.sh	$1;
}

if [ $# -eq 0 ]; then
	for dir in `ls -d ../data/*/`; do
		worker ${dir};
	done
else
	worker $1;
fi
