Open the input event file Read the observing mode from the input event file if SD20mode is False Read from the EPN_CTI CCF coefficients and template values Loop over each event set coefficients(a,b,c) from the event CCD, RAWX, RAWY values set template value from the event CCD, RAWX, RAWY values h = log10(event_pi) - 3.0; f = a + (b + c * h) * h; event_pi = event_pi - template_value * f end of loop else Read from the EPN_SPATIALCTI CCF offsets to apply to PI values Loop over each event set offset from the event epoch, CCD, RAWX, RAWY values event_pi = event_pi - offset end of loop Add the keyword SPATCTIC = 'yes' into the EVENTS header