subroutine gtialign open gti_in open events_in open gti_out read gti_starts read gti_stops foreach ccd create gti_out extension read frame_times foreach frame_time frame_start = get_start(frame_time, time_del, time_offset) foreach gti_start if( gti_start < frame_start ) gti_new_start = frame_start break gti_start loop endif next frame_end = get_end(frame_time, time_del, time_offset) foreach gti_stop if( gti_stop < frame_end ) gti_new_stop = get_end(frame_time-1, time_del, time_offset) break gti_stop loop endif next next write gti_out extension, gti_new_start, gti_new_stop next close files end subroutine gtialign