Automated area under the curve (AUC) calculation with Grace

less than 1 minute read

Published:

I wish I have an elegant solution for this like automated linear regression, but I don’t. This solution that I came up with is hacky, but it works.

cat << EOF > integrate.par
integrate(s0)
EOF

grace data.agr -param integrate.par -saveall data.temp.agr -hardcopy -noprint
tail -2 data.temp.agr | awk 'NR==1{printf "%.2f\n", $2}'

In essence, call integrate.par to calculate the area under the curve of your data in s0. Grace will plot a cumulative sum and append it to the .agr file. So we just need to extract the last value of the cumulative sum, which can be found in the penultimate line (thus the tail -2).

Told ya it’s hacky.

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...