Data analysis code for KPP project