Generalized psf extract script, added median subtraction