First full version of photometry script