Set state CAL/OAL get columns from EVENTS table setup new columns in EVENTS table Get source position from RGS SRCLIST table Get reference attitude from RGS SRCLIST table loop over EXPOSU0n tables call processFramesTable to fill ASPCDSP and ASPCXDSP columns of EXPOSU0n table using gratingAspectAngles(time, referenceAttitude) end loop loop over all times to find elements with available attitude call processEvents to correct BETA, XDSP with attitude drift using phi0=offAxisAngles(referenceAttitude, sourcePos) processEvents{ Calculate corrected beta beta_corr = betaraw + (Qfactor * ASPCDSP / sin(betaraw)) if (cross dispersion) xdsp_corr = xdspRaw + ASPCXDSP } store factor ASPFACT1 in header EVENTS table Qfactor = FoverL * sin(alpha0 + phi0dsp*FoverL) bin BETA_CORR into BETA_CHANNEL bin XDSP_CORR into XDSP_CHANNEL