debugging gain_calc.py