extract function

Extract or replace parts of a spectrum