Home > reduc > support > stokesWrapper.m

stokesWrapper

PURPOSE ^

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

SYNOPSIS ^

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

DESCRIPTION ^

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

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

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