Home > reduc > support > rfactorWrapper.m

rfactorWrapper

PURPOSE ^

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

SYNOPSIS ^

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

DESCRIPTION ^

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

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

    reduceData function that calls the r-factor calculation and applies the
    correction to the data.

    sjcm

   3/30/2011 sjcm:  save plots without displaying them.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function d = rfactorWrapper(d, plotparams, parm, field);
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 %  function d = rfactorWrapper(d, plotparams, parm, field);
0006 %
0007 %    reduceData function that calls the r-factor calculation and applies the
0008 %    correction to the data.
0009 %
0010 %    sjcm
0011 %
0012 %   3/30/2011 sjcm:  save plots without displaying them.
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 
0015 [d,q] = logcal(d, 'rfactor');
0016 if (q)
0017   disp('r-factor correction has already been applied')
0018   disp(' ')
0019   d=checkstatus(d);
0020   return
0021 end
0022 
0023 % check if we have the flagging parameters
0024 parFlag = checkpar(parm, 'rfactor');
0025 
0026 if(parFlag)
0027   flagParams = [parm.rfactor.maxVal parm.rfactor.slope parm.rfactor.smooth];
0028 else
0029   display('Using Default rfactor parameters');
0030   flagParams = [2 30 10];
0031 end
0032 
0033 
0034 % check if we're autoflagging
0035 autoFlag = checkpar(parm, 'autorun');
0036 if(autoFlag)
0037   autoFlag = parm.autorun.flag;
0038 else
0039   autoFlag = 0;
0040 end
0041 
0042 
0043 % if we have data to calculate the r-factor
0044 if(~isempty(find(d.index.blank.slow)))
0045   calc_rf = 1;
0046 else
0047   calc_rf = 0;
0048 end
0049 
0050 
0051 %if(calc_rf)
0052 %  display('Calculating the r-factor correction');
0053 %  r_f = calculateRfactor(d);
0054 %else
0055 %  display('Applying saved r-factor correction');
0056 %  % first we load the correction
0057 %  r_f = getRfactor(last(d.array.frame.utc(1)));
0058 %end
0059 
0060 % apply it
0061 %rval =  [1.9,1.8,1.8,1.7];
0062 %dcorr = calculateStokes2_samer(d, r_f, flagParams(3), rval);
0063 
0064 alphaType  = parm.alpha.type;
0065 switch alphaType
0066     case 1
0067         selection = 'CLASSIC';
0068     case 2
0069         selection = 'POLONLY';
0070     otherwise
0071         selection = 'FILTERED';
0072 end
0073 disp(['Calling calculateStokes with ' selection ' flag'])
0074 d = calculateStokes(d,selection);
0075 
0076 
0077 % set up the flags
0078 flags.old.bit = d.flags.bit;
0079 % flag it
0080 if(autoFlag)
0081   %  flags.new.bit = flagRfactor(d, r_f, flagParams);
0082   flags.new.bit.fast = zeros(size(flags.old.bit.fast));
0083 else
0084   flags.new.bit.fast = zeros(size(flags.old.bit.fast));
0085 end
0086 
0087 % plot it up
0088 setPlotDisplay(plotparams.plot);
0089 [d outFlags] = packd(d, flags, 'none', 'rfactor', plotparams, 'R-Factor correction Plots', field);
0090 
0091 d = setNewFlag(d, outFlags.new.out, 'rfactor');
0092 d = updateFlags(d, 1);
0093 
0094 d = logcal(d, 'rfactor');
0095 
0096 % now we really don't need the switch data. even though it's too late.
0097 d.antenna0.receiver = rmfield(d.antenna0.receiver, 'switchData');
0098 
0099 
0100 return;
0101 
0102 
0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0104 function d=checkstatus(d)
0105 
0106 disp('Would you like to view the plots?')
0107 
0108 if (query)
0109   d = packd(d, [], 'none', 'rfactor', 0, 'R-Factor correction Plots', '');
0110 end
0111 
0112 disp(' ')
0113 
0114

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