#ifndef PM_FLAT_NORMALIZE_H
#define PM_FLAT_NORMALIZE_H

#include "pslib.h"

// Normalise the flat-field measurements (f_ij = g_i s_j where f_ij is the flux recorded for chip i and
// integration j, g_i is the gain for the i-th chip, s_j is the flux of the source in the j-th integration).
// Return the source flux in each integration.
psVector *pmFlatNormalize(bool *converge, // Did we converge?
                          psVector *chipGains, // Initial guess of the chip gains; modified for return
                          const psImage *fluxLevels, // Fluxes for each integration (row) and chip (col)
                          unsigned int maxIter, // Maximum number of iterations
                          float tolerance // Tolerance level before dying
                         );

#endif
