commit 08e59544d03a16367f588645038b26e737559269
parent 81d8ce44788de8a8b4fc45b5af9c82ce1e6e867f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 21 Mar 2016 17:11:34 +0100
Simplify the test_sschiff_cylinder script
Do not regroup the cross_sections in one file and do not split the
inverse cumulative phase functions.
Diffstat:
3 files changed, 11 insertions(+), 48 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -108,8 +108,8 @@ else()
add_test(
NAME test_schiff_cylinder
COMMAND
- ${_env} PATH=$ENV{PATH}:$<TARGET_FILE_DIR:schiff>
- ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_cylinder.sh)
+ ${_env} PATH=$ENV{PATH}:$<TARGET_FILE_DIR:schiff>
+ ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_cylinder.sh)
add_test(
NAME test_schiff_sphere
COMMAND
diff --git a/src/test_schiff_cylinder.sh b/src/test_schiff_cylinder.sh
@@ -28,8 +28,6 @@ Ne=1.3333333333333333333 # Refractive index of the medium
sigma=1.18
R=0.837
-tmpdir=`mktemp -d`
-
# extinction extinction-SE absorption absorption-SE scattering scattering-SE area area-SE
references=(
"1.16026E-04 9.45526E-08 1.13812E-04 9.18322E-08 2.21384E-06 2.82025E-09 1.37239E-02 1.52125E-06"
@@ -339,7 +337,8 @@ x=(8.377720036e-1 1.675530045e+0 2.513288086e+0 3.351046126e+0
2.018997018e+2 2.027374599e+2)
set -e
-cd $tmpdir && echo $tmpdir
+cd `mktemp -d`
+pwd
if [ ! -e $tmppipe ]; then mkfifo $tmppipe; fi
@@ -387,33 +386,20 @@ then
done
fi
-# Split the result file
-csplit --suppress-matched -z -q -f $tmpprefix -b%d $tmpfile /^$/ {*}
-
err=0 # error code
-# Check the estimated cross sections against the references and concatenate the
-# estimation in the cross_sections file
-echo -e \
-"# Cross sections\n"\
-"#\n"\
-"# Each line is formated as 'X W E e A a S s P p' with X the value used to\n"\
-"# compute the cylinder mean radius, 'W' the wavelength in vacuum (expressed in\n"\
-"# micron), 'E', 'A' and 'S' the estimation of the extinction, absorption and\n"\
-"# scattering cross section, respectively, and 'P' the estimated average\n"\
-"# projected area. The 'e', 'a', 's' and 'p' values are the standard error of\n"\
-"# the aforementioned estimations.\n" > cross_sections
+# Check the estimated cross sections against the references
for ((i=0; i < ${#x[@]}; ++i))
do
- xsection=(`cat $tmpprefix$(($i*2)) | sed 's/^\S*\(.*\)$/\1/g' | sed 's/[eE]+*/*10^/g'`)
+ xsection=(`sed -n "$(($i*($nangles+4)+1))p" $tmpfile | sed 's/^\S*\(.*\)$/\1/g' | sed 's/[eE]+*/*10^/g'`)
reference=(`echo ${references[$i]} | sed 's/[eE]+*/*10^/g'`)
- echo -n "${x[$i]} "
-
extinction=$(intersect ${xsection[0]} ${xsection[1]} ${reference[0]} ${reference[1]})
absorption=$(intersect ${xsection[2]} ${xsection[3]} ${reference[2]} ${reference[3]})
scattering=$(intersect ${xsection[4]} ${xsection[5]} ${reference[4]} ${reference[5]})
avg_area=$(intersect ${xsection[6]} ${xsection[7]} ${reference[6]} ${reference[7]})
+
+ echo -n "${x[$i]} "
if [ $extinction -eq 0 -o $absorption -eq 0 -o $scattering -eq 0 -o $avg_area -eq 0 ]
then
echo FAILURE
@@ -421,33 +407,9 @@ do
else
echo OK
fi
-
- echo -n "${x[$i]} " >> cross_sections
- cat $tmpprefix$(($i*2)) >> cross_sections
-done
-
-# Save the inverse cumulative phase functions
-for ((i=0; i < ${#x[@]}; ++i))
-do
- name=inv_cum_$i
-
- echo -e "# Inverse cumulative phase function." > $name
-
- head -n 1 $tmpprefix$(($i*2+1)) | \
- sed "s/\(\S*\)\s\+\(\S*\)\s\+\(\S*\)\s\+\(\S*\)\s\+\(\S*\)\s\+\(\S*\)\s\+\(\S*\)$/"\
-"# wavelength = \1 microns; "\
-"theta-l = \2 radians; "\
-"PF(theta-l) = \3 +\/- \4; "\
-"CDF(theta-l) = \5 +\/- \6; "\
-"n = \7; "\
-"#angles = $nangles/" >> $name
-
- sed '1d' $tmpprefix$(($i*2+1)) >> $name
done
-rm $tmpprefix*
-#rm $tmppipe
-#rm $tmpfile
+rm $tmppipe
exit $err
diff --git a/src/test_schiff_sphere.sh b/src/test_schiff_sphere.sh
@@ -82,6 +82,7 @@ fi
err=0 # error code
+# Check the estimated cross sections against the references
for ((i=0; i < ${#mean_radius[@]}; ++i))
do
xsection=(`sed -n "$(($i*($nangles+4)+1))p" $tmpfile | sed 's/^\S*\(.*\)$/\1/g'`)
@@ -103,4 +104,4 @@ done
rm $tmppipe
-exit 0
+exit $err