#!/bin/bash
# Get OD for different repump rf powers from the transmission data obtained using get_od.sh (programs/fwm_programs/OD_switching)
# Output column format
# Col1 - repump AOM rf power
# Col2 - Optical density
# Col3 - error in OD from fit

for f in $(ls transmission*.dat)
do
	# Extract AOM rf power the filename.
	rf=$(echo $f | grep -E -o "[0-9]\.[0-9]*")

	# OD and error in OD obtained from the fit (gnuplot file: plot.gnu).
	od=$(gnuplot -e "filename='"$f"'" plot.gnu 2>&1 | tail -n 1)

	# print rf power, OD and error in OD
	echo $rf " " $od
	echo $rf " " $od >> od.dat
done

