Copied over more helper functions from ptsrc_photom_flt.