Home > reduc > flag > updateFlags.m

updateFlags

PURPOSE ^

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

SYNOPSIS ^

function d = updateFlags(d, flagPol);

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  function d = updateFlags(d, flagPol);

  this function just makes sure all your flag fields agree

    if you have a flag in channel 1 or 6 and flagPol set, it will flag all the
    corresponding polarization channels as well.

   out is Nby3 where 3 = [I1, Pol, I2];

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function d = updateFlags(d, flagPol);
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function d = updateFlags(d, flagPol);
0006 %
0007 %  this function just makes sure all your flag fields agree
0008 %
0009 %    if you have a flag in channel 1 or 6 and flagPol set, it will flag all the
0010 %    corresponding polarization channels as well.
0011 %
0012 %   out is Nby3 where 3 = [I1, Pol, I2];
0013 %
0014 %  sjcm
0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0016 
0017 % damn you oliver!!!
0018 fastDim2 = size(d.flags.fast,2);
0019 
0020 
0021 % basically we should just update the d.flags.bit, and the othere will fall
0022 % out of it.
0023 
0024 if(nargin==1)
0025   flagPol = 1;
0026 end
0027 
0028 if(~isfield(d.flags, 'bit'))
0029   display('Nothing to update');
0030   return;
0031 end
0032 
0033 display('Updating all flags to reflect new flags');
0034 
0035 
0036 
0037 % slowest rate should flag all rates
0038 slowSlow  = d.flags.bit.slow;
0039 slowMed   = repmat(d.flags.bit.slow, [1 5]);
0040 slowMed   = slowMed';
0041 slowMed   = slowMed(:);
0042 slowFast  = repmat(d.flags.bit.slow, [1 100]);
0043 slowFast  = slowFast';
0044 slowFast  = slowFast(:);
0045 slowFast  = repmat(slowFast, [1 fastDim2]);
0046 
0047 % faster rate should only flag slower rate if all faster rate is flagged for
0048 % a given time sample  (hence the bitand)
0049 medFast   = repmat(d.flags.bit.medium, [1 20]);
0050 medFast   = medFast';
0051 medFast   = medFast(:);
0052 medFast   = repmat(medFast, [1 fastDim2]);
0053 medMed    = d.flags.bit.medium;
0054 medSlow1  = reshape(d.flags.bit.medium, [5 length(d.flags.bit.medium)/5]);
0055 medSlow  = arrayBitand(medSlow1);
0056 medSlow  = medSlow';
0057 
0058 
0059 % now for fast rate (which will always be of dim 3 at this point)
0060 
0061 fastFast  = d.flags.bit.fast;
0062 fastTrans = bitand(bitand(fastFast(:,1), fastFast(:,2)), fastFast(:,3));
0063 
0064 fastMed   = reshape(fastTrans, [20 length(fastTrans)/20]);
0065 fastMed   = arrayBitand(fastMed);
0066 fastMed   = fastMed';
0067 
0068 fastSlow  = reshape(fastMed, [5 length(fastMed)/5]);
0069 fastSlow  = arrayBitand(fastSlow);
0070 fastSlow  = fastSlow';
0071 
0072 % NO LONGER HAVE SWITCH STATES
0073 
0074 % now we put it all together
0075 bitSlow = bitor(slowSlow, medSlow);
0076 bitSlow = bitor(bitSlow,  fastSlow);
0077 
0078 bitMed = bitor(slowMed, medMed);
0079 bitMed = bitor(bitMed,  fastMed);
0080 
0081 bitFast = bitor(slowFast, medFast);
0082 bitFast = bitor(bitFast,  fastFast);
0083 
0084 % replace the flags
0085 d.flags.bit.slow   = bitor(d.flags.bit.slow,bitSlow);
0086 d.flags.bit.medium = bitor(d.flags.bit.medium, bitMed);
0087 d.flags.bit.fast   = bitor(d.flags.bit.fast, bitFast);
0088 
0089 % same for the other ones
0090 d.flags.slow   = d.flags.slow   | d.flags.bit.slow>0;
0091 d.flags.medium = d.flags.medium | d.flags.bit.medium>0;
0092 d.flags.fast   = d.flags.fast   | d.flags.bit.fast>0;
0093 
0094 % next we flag the polarization channels if any of the total intensity
0095 % channels are flagged
0096 if(flagPol)
0097   ind = d.flags.fast(:,1) | d.flags.fast(:,3);
0098   d.flags.fast(ind,2) = 1;
0099     
0100   d.flags.bit.fast(:,2) = arrayBitor(d.flags.bit.fast);
0101 end
0102 
0103 
0104 return;
0105 
0106 
0107

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