0001 function d = stokesWrapper(d, plotparams, parm, field);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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
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
0042 autoFlag = checkpar(parm, 'autorun');
0043 if(autoFlag)
0044 autoFlag = parm.autorun.flag;
0045 else
0046 autoFlag = 0;
0047 end
0048
0049
0050
0051 if(~isempty(find(d.index.blank.slow)))
0052 calc_rf = 1;
0053 else
0054 calc_rf = 0;
0055 end
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
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
0090 flags.old.bit = d.flags.bit;
0091
0092 if(autoFlag)
0093
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
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
0109
0110
0111
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