Diaphragm calculations in python