text: rewrite spectrum calculation