function [templateFrame, rotations] = genReferenceTemplate()

starlinkConstants

% Load reference template rotations from .mat file (generated from exemplar frames analysis).
data = load('referenceTemplate.mat', 'referenceTemplateRotations');
rotations = data.referenceTemplateRotations;

% Zero out edge pilot subcarriers (they have their own 4QAM pattern).
% Edge pilots: k = 488:495 and 528:535 (0-indexed), or 489:496 and 529:536 (1-indexed).
gutterIdx    = [1 2 1023 1024];
edgePilotIdx = [489:496, 529:536];
rotations([gutterIdx edgePilotIdx], :) = -1;

templateIQ = exp(1j * rotations * pi/2);
templateIQ(rotations==-1) = 0;

templateFrame = sqrt(sl.N) * ifft(templateIQ);
templateFrame = [templateFrame(end-sl.Ng+1:end,:); templateFrame];
templateFrame = reshape(templateFrame, [numel(templateFrame) 1]);

end
