Python / Cython code for my thesis: Water property rights in regulated rivers