Home > reduc > apply_loadcorrect_final.m

apply_loadcorrect_final

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function [d]= apply_loadcorrect_final(d,K_best,shift)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 function [d] = apply_loadcorrect_final(d,K_best,shift)

   To apply the correction factor to remove the effect
   of fluctuations in the cold load

   Do this on each of the 12 switched channels
   
   Should check this works over various timescales/ conditions before
   releasing as final

   act
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [d]= apply_loadcorrect_final(d,K_best,shift)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % function [d] = apply_loadcorrect_final(d,K_best,shift)
0006 %
0007 %   To apply the correction factor to remove the effect
0008 %   of fluctuations in the cold load
0009 %
0010 %   Do this on each of the 12 switched channels
0011 %
0012 %   Should check this works over various timescales/ conditions before
0013 %   releasing as final
0014 %
0015 %   act
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 
0019 %Double check lengths of arrays
0020 
0021 t_start = 1;
0022 t_stop = length(d.antenna0.thermal.coldLoad(:,1));
0023 
0024 for chan = 1:size(d.antenna0.receiver.data,2)
0025   
0026   % Get corrections and residuals (check at the moment for plots - can
0027   % remove at later date)
0028   
0029   load_res = d.antenna0.thermal.coldLoad(t_start:t_stop) - mean(d.antenna0.thermal.coldLoad(t_start:t_stop));
0030   
0031   %shifted_load = circshift(d.antenna0.thermal.coldLoad,shift(chan));
0032   
0033   shifted_load = circshift(load_res,shift(chan));
0034   
0035   correction = K_best(chan)*(shifted_load - mean(shifted_load));
0036   
0037   residual = d.antenna0.receiver.data(t_start:t_stop,chan) - ((d.antenna0.receiver.data(t_start:t_stop,chan))- correction);
0038   
0039   
0040 % Some spectrogram plots to check
0041 %
0042 % figure(chan)
0043 %
0044 %
0045 % subplot(2,2,1)
0046 %
0047 % spectrogram(d.antenna0.receiver.pairedData(:,chan),512,16 ,512,100)
0048 % xlim([0 50])
0049 % title('Spectra of original data');
0050 %
0051 % subplot(2,2,2)
0052 %
0053 % spectrogram(d.antenna0.thermal.coldLoad(:),512,16 ,512,100)
0054 % xlim([0 50])
0055 % title('Spectra of cold load data');
0056 %
0057 % subplot(2,2,4)
0058 %
0059 % spectrogram(residual,512,16 ,512,100)
0060 % title('Spectra of residual data - should essentially be load correction')
0061 % xlim([0 50])
0062 %
0063 % % Apply correction to channel data
0064 %
0065 if(isfield(d.antenna0.receiver, 'dataT'))
0066  d.antenna0.receiver.dataT(t_start:t_stop,chan) = ...
0067      (d.antenna0.receiver.dataT(t_start:t_stop,chan))- correction;
0068 else
0069   d.antenna0.receiver.data(t_start:t_stop,chan) = ...
0070       (d.antenna0.receiver.data(t_start:t_stop,chan))- correction;
0071 end
0072 
0073 %
0074 % %
0075 % subplot(2,2,3)
0076 % %figure
0077 % titlenumber = num2str(chan);
0078 % spectrogram(d.antenna0.receiver.pairedData(:,chan),512,16 ,512,100)
0079 % title('Spectra of corrected data')
0080 % xlim([0 50])
0081 % suplabel(['Channel ',titlenumber] ,'t');
0082 %
0083 
0084 end
0085

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005