python implementation of MTF calculation