Home > reduc > flag > flagRfactor.m

flagRfactor

PURPOSE ^

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

SYNOPSIS ^

function flags = flagRfactor(d, r_f, flagParams)

DESCRIPTION ^

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

  function flags = flagRfactor(d, r_f, flagParams)


   function to flag the r-factor step of the pipeline.
  
   we compare the ratio of the previous slope to the current slope, and if
   it's less than flagParams (in %), it's not flagged.


  sjcm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function flags = flagRfactor(d, r_f, flagParams)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function flags = flagRfactor(d, r_f, flagParams)
0006 %
0007 %
0008 %   function to flag the r-factor step of the pipeline.
0009 %
0010 %   we compare the ratio of the previous slope to the current slope, and if
0011 %   it's less than flagParams (in %), it's not flagged.
0012 %
0013 %
0014 %  sjcm
0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0016 
0017 keyboard;
0018 % first check is easy, just see if r-factor values are above flagParams(1)
0019 
0020 if(any(abs(r_f)>flagParams(1)))
0021   flags = ones(size(d.antenna0.receiver.dataT));
0022   return;
0023 end
0024 
0025 
0026 % I suppose we should calculate the slope for given sections, and flag them
0027 % if they did not improve on those sections.
0028 
0029 % first we select the data on which to flag.
0030 [dcut  indFast] = cutObs(d, 'source', 'only');
0031 
0032 % before should be the combinations in switchDataT
0033 % after  should be receiver.dataT
0034 
0035 for m=1:6
0036   noCorr(:,m) = ...
0037       0.5*sum(dcut.antenna0.receiver.switchDataT(:,[(m-1)*4+2 ...
0038     (m-1)*4+3]) - ...
0039       dcut.antenna0.receiver.switchDataT(:,[(m-1)*4+1 (m)*4]), 2);
0040 end
0041 withCorr = dcut.antenna0.receiver.dataT;
0042 
0043 % next we calculate the blocks over which to flag
0044 timeVal = (dcut.antenna0.receiver.utc - dcut.antenna0.receiver.utc(1))*24*60;
0045 f = find(diff(timeVal)>0.02);
0046 for m=1:length(f)
0047   if(m==1)
0048     si(m) = 1;
0049   else
0050     si(m) = f(m-1)+1;
0051   end
0052   
0053   if(m==length(f))
0054     ei(m) = length(timeVal);
0055   else
0056     ei(m) = f(m);
0057   end
0058 end
0059 
0060 % next we calculate the slopes before and after the correction, on each of
0061 % these blocks of time;
0062 
0063 slopeNoCorr = zeros(length(ei), 6);
0064 slopeCorr   = zeros(length(ei), 6);
0065 
0066 for m=1:length(ei)
0067   thisX = timeVal(si(m):ei(m));
0068   thisX = thisX - thisX(1);
0069 
0070   thisYno = noCorr(si(m):ei(m),:);
0071   thisYyes= withCorr(si(m):ei(m),:);
0072 
0073   f = find(dcut.flags.fast(si(m):ei(m),:));
0074   thisYno(f) = nan;
0075   thisYyes(f) = nan;
0076   
0077   
0078   [slopeNoCorr(m,:) ynocorr(m,:)] = linfit(thisX, thisYno);
0079   [slopeCorr(m,:)   ycorr(m,:)]   = linfit(thisX, thisYyes);
0080   
0081 end
0082 
0083     
0084     
0085 
0086 
0087 
0088 
0089       
0090 
0091

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