added spectrum transformation code (still in translation from fortran)