Move some generic numpy helpers out of main analysis file, add a few other helpers