Python code to run rapid scanning calculations