Home > reduc > support > rfioWrapper.m

rfioWrapper

PURPOSE ^

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

SYNOPSIS ^

function d = rfiWrapper(d, plotparams, parm, field);

DESCRIPTION ^

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

  function d = rfiWrapper(d, plotparams, parm, field)

    reduceData function that calls the rfi algorithm with
    parameters parm.


    sjcm

    Modified Oct 8, 2010 (MAS):  Switched in new RFI flagging for noise
    diode events.

    Modified Dec 20, 2010 (MAS):  Switched in generalized RFI flagging for
    all data.  Removed distinction and need for two rfi flagging sessions.

    Modified Jan 7, 2011 (MAS):  Got rid of the stageNum parameter.
    
    3/29/2011 (SJCM):  no plotting but saving plots

    Modified Apr 15, 2011 (MAS):  Updated to latest algorithm.  
    Added support for user parameters.  Added spatial flagging.

    Modified Sep 10, 2012 (MAS):  Updated to handle "aggressive"
    parameter, rather than the previous set of 11.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function d = rfiWrapper(d, plotparams, parm, field);
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function d = rfiWrapper(d, plotparams, parm, field)
0006 %
0007 %    reduceData function that calls the rfi algorithm with
0008 %    parameters parm.
0009 %
0010 %
0011 %    sjcm
0012 %
0013 %    Modified Oct 8, 2010 (MAS):  Switched in new RFI flagging for noise
0014 %    diode events.
0015 %
0016 %    Modified Dec 20, 2010 (MAS):  Switched in generalized RFI flagging for
0017 %    all data.  Removed distinction and need for two rfi flagging sessions.
0018 %
0019 %    Modified Jan 7, 2011 (MAS):  Got rid of the stageNum parameter.
0020 %
0021 %    3/29/2011 (SJCM):  no plotting but saving plots
0022 %
0023 %    Modified Apr 15, 2011 (MAS):  Updated to latest algorithm.
0024 %    Added support for user parameters.  Added spatial flagging.
0025 %
0026 %    Modified Sep 10, 2012 (MAS):  Updated to handle "aggressive"
0027 %    parameter, rather than the previous set of 11.
0028 %
0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0030 
0031 [d,q] = logcal(d, 'stokes');
0032 if (~q)
0033   disp('Stokes step not yet applied.  You need to do that first.');
0034   disp(' ')
0035 %  d=checkstatus(d);
0036   return
0037 end
0038 [d,q] = logcal(d, 'rfi');
0039 if (q)
0040   disp('RFI flagging has already been applied')
0041   disp(' ')
0042 %  d=checkstatus(d);
0043   return
0044 end
0045 
0046 
0047 % Check which type of data we're using.
0048 parFlag = checkpar(parm, 'alpha');
0049 if(parFlag)
0050   alphaType  = parm.alpha.type; % 0/1/2: filtered/classic/polonly
0051 else
0052   % check if we're running interactively so we can set what we want.
0053   if(plotparams.interactive==1)
0054     display('You are running in interactive mode');
0055     alphaType = 4;
0056     while(alphaType<0 || alphaType>3)
0057       alphaType = input('What type of correction did you apply?  [0-FILTERED, 1-CLASSIC, 2-POLONLY] ');
0058     end
0059   else
0060     display('No correction type specified, defaulting to classic data.');
0061     alphaType  = 1;
0062   end
0063 end
0064 
0065 
0066 
0067 % check if we have the flagging parameters
0068 parFlag = checkpar(parm, 'rfio');
0069 if(parFlag)
0070   flagParamsRfi = readRFIParameters(d.array.frame.utc(1), ...
0071       alphaType, parm.rfio.aggressive);
0072 else
0073   display('Using Default RFI flagging parameters');
0074   flagParamsRfi = readRFIParameters(d.array.frame.utc(1), ...
0075       alphaType, 3);
0076 end
0077 
0078 
0079 % check if we have the coord parameter.
0080 parFlag = checkpar(parm, 'coord');
0081 if(parFlag)
0082   flagParamsPositional = parm.coord.hemisphere;
0083 else
0084   display('Using Default Positional RFI flagging parameters');
0085   flagParamsPositional = 1;
0086 end
0087 
0088 
0089 % Deglitch Flagging (not yet migrated to here...):
0090 % XXX
0091 
0092 %---------------------------------------------
0093 % Positional Flagging:
0094 %---------------------------------------------
0095 [horzFlag satFlag] = flagRFI_pos2(d,flagParamsPositional);
0096 
0097 preFlag = horzFlag | satFlag ;
0098 
0099 flags.old.bit = d.flags.bit;
0100 flags.new.bit.fast = repmat(preFlag, [1 3]);
0101 
0102 setPlotDisplay(plotparams.plot);
0103 % plot the positional flagging
0104 [d, outFlags] = packd(d, flags, 'none', 'positional', plotparams, ...
0105     'Positional Flagging Plots', field, []);
0106 
0107 % user positional flags
0108 userPosFlags = (outFlags.new.out>0) - (flags.new.bit.fast>0) ~= 0;
0109 userPosVec   = sum(userPosFlags,2)>0;
0110 
0111 % set all of these bits accordingly
0112 d = setNewFlag(d, repmat(horzFlag, [1 3]), 'horizon');
0113 d = updateFlags(d, 1);
0114 
0115 d = setNewFlag(d, repmat(satFlag, [1 3]), 'satellite');
0116 d = updateFlags(d, 1);
0117 
0118 d = setNewFlag(d, userPosFlags, 'pos_user');
0119 d = updateFlags(d, 1);
0120 
0121 % add user flags to preFlag
0122 preFlag = preFlag | userPosVec;
0123 
0124 %---------------------------------------------
0125 % Statistical Flagging:
0126 %---------------------------------------------
0127 display('Statistical RFI Flagging');
0128 flag = flagRFI_std(d,preFlag,flagParamsRfi);
0129 flags.old.bit = d.flags.bit;
0130 flags.new.bit.fast = repmat(flag, [1 3]);
0131 
0132 % plot the data
0133 setPlotDisplay(plotparams.plot);
0134 [d, outFlags] = packd(d, flags, 'none', 'rfi', plotparams, 'RFI Plots', field, []);
0135 d = setNewFlag(d, outFlags.new.out, 'rfi');
0136 d = updateFlags(d, 1);
0137 
0138 d = logcal(d, 'rfi');
0139 
0140 return;
0141 
0142 
0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0144 function d=checkstatus(d)
0145 
0146 disp('Would you like to view the plots?')
0147 
0148 if (query)
0149   d = packd(d, [], 'none', 'rfi', 0, 'RFI Plots', '');
0150 end
0151 
0152 disp(' ')
0153 
0154

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