finished first draft pulse.py; did not test