Create apply_phi.py