of the measurements taken in each state to the mean flux of the orbit, after accounting for the transit if present. The 7-state correction lowers the RMS by a factor 1.5 on average (Figure \[fig:cor7phases\]). Because orbits have a different average flux, the correction cannot be applied for a whole visit at once when extracting these raw lightcurves. However, in the remainder of this work, the average flux of each orbit is adjusted by optimization processes, and the 7-state correction will be applied for each visit instead of each orbit. Using the larger number of data points in a visit, compared to each orbit, provides better estimates of the seven state-dependent flux offsets and also reduces to insignificance the side-effect that fitting these offsets will reduce even random noise simply because each offset is another parameter in the fit.

![Relative flux of XO-2 N as a function of the image index for the 2[$^{\textrm{\scriptsize nd}}$ ]{}orbit of the 2[$^{\textrm{\scriptsize nd}}$ ]{}visit, before (top) and after (bottom) correction of the systematic offset induced by the 7 detector state (astrophysical variation due to the transit has been corrected prior to display). Images sharing the same detector state are connected by lines using 