fileName='C:\Users\PaulMartellock\Temp\MPDRWaveforms.xlsm';
SpreadSheetTable = readtable(fileName,'sheet','stc');

%

StcTable=SpreadSheetTable(:,8:12);
StcTable

%

savejson('Stc',StcTable, 'stcfile.json');

%
% at this point need to open the mpdrRadarConfig file and add stcFile.json to the end of it....

ConfigFile=loadjson('mpdrRadarConfig.json');
ConfigFile.Stc.FirstSample

%
% create a vector that scales the data as if there was no stc...

StcScaleVec=ones(1,ConfigFile.cipMetaData.priSize);
[StcVecLen,~]=size(ConfigFile.Stc.FirstSample);
startDelay=10;
for ii = 1:StcVecLen-1
    StcScaleVec(ConfigFile.Stc.FirstSample(ii)+1+startDelay:ConfigFile.Stc.LastSample(ii)+1+startDelay)=ConfigFile.Stc.Multiplier(ii);
end
figure, plot(StcScaleVec);
figure, plot(20*log10(StcScaleVec));

%

StcScale=repmat(StcScaleVec,8,1,160);

%
% test using data collected via CW tone injected into system at the Lr and Sr RF frequency

myRadar = mpdrRadar('mpdrRadarConfig.json');
myRadar.openDataRecordFile('mpdr_20210524_Stc9330MCwTone2_1.dat','C:\Users\PaulMartellock\Working\MPDRCalibrationRecordings');

%

myCip=cipCube(myRadar);
myCip.loadCip();
myCip.calibrate();

%

myCip.stcCorr();
[cipData,cipMetaData] = myCip.getCipCube();
plotCube(cipData,cipMetaData,['Time Domain Mag: ' cipMetaData.Filename],'Mag');


%

SumLrChan=uint32(radChan.sumLr);
SumSrChan=uint32(radChan.sumSr);
fig=plotChan(cipData,cipMetaData,SumLrChan,['Time Domain Mag: ' cipMetaData.Filename],'Mag',1);
plot(20*log10(StcScaleVec));
% scaledData=cipData.*StcScale;
plotChan(scaledData,cipMetaData,SumLrChan,['Time Domain Mag: ' cipMetaData.Filename],'Mag',1);

%

plotChan(scaledData,cipMetaData,SumSrChan,['Time Domain Mag: ' cipMetaData.Filename],'Mag',1);

%

