0001 function d = alphaWrapper(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('Alpha correction has been applied');
0018 disp(' ')
0019 d=checkstatus(d);
0020 return
0021 end
0022
0023
0024 parFlag = checkpar(parm, 'alpha');
0025 if(parFlag)
0026 flagParams = [parm.alpha.jump parm.alpha.flat];
0027 alphaType = parm.alpha.type;
0028 solveAlpha = parm.alpha.solve;
0029 else
0030 display('No flagging in alpha correction');
0031 flagParams = [1.5 0.004];
0032
0033 if(plotparams.interactive==1)
0034 display('You are running in interactive mode');
0035 alphaType = 4;
0036 solveAlpha = 0;
0037 while(alphaType<0 | alphaType>3)
0038 alphaType = input('What type of correction do you want? [0-FILTERED, 1-CLASSIC, 2-POLONLY]');
0039 end
0040 else
0041 display('No alpha correction type specified, defaulting to 1 on un-filtered data');
0042 alphaType = 1;
0043 solveAlpha = 0;
0044 end
0045 end
0046
0047
0048 autoFlag = checkpar(parm, 'autorun');
0049 if(autoFlag)
0050 autoFlag = parm.autorun.flag;
0051 else
0052 autoFlag = 0;
0053 end
0054
0055
0056 isup2date = checkAlphaDatabase((d.array.frame.utc(1)));
0057 if(~isup2date)
0058
0059 if(plotparams.interactive==1)
0060 display('Your alpha database is not up to snuff');
0061 display('Would you like to solve it from the data in this track?');
0062 solveAlpha = query;
0063 end
0064 end
0065
0066
0067
0068 [off1StartPos onEndPos off2EndPos onStartPos off1EndPos off2StartPos] = calcNoiseIndices(d);
0069 d.correction.alpha.indices = [off1StartPos onEndPos off2EndPos onStartPos];
0070 d.correction.alpha.indices2 = [off1StartPos onEndPos off2EndPos onStartPos ...
0071 off1EndPos off2StartPos];
0072 d.correction.alpha.type = alphaType;
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 switch(alphaType)
0097 case 1
0098 d = assembleAlphaStreams(d,'CLASSIC');
0099
0100 if(solveAlpha)
0101 [tA,Ac,Gc] = calculateAlpha(d,'CLASSIC');
0102 d = applyAlpha(d, tA, Ac, Gc,'CLASSIC');
0103 else
0104
0105
0106 d = applyAlpha(d,'CLASSIC');
0107 printDisclaimer1;
0108 end
0109 flags.old.bit = d.flags.bit;
0110 flags.new.bit.fast = zeros(size(flags.old.bit.fast));
0111
0112
0113
0114
0115
0116
0117 setPlotDisplay(plotparams.plot);
0118 display('Plotting data');
0119
0120
0121
0122
0123 [d, outFlags] = packd(d, flags, 'none', 'alpha', plotparams, 'Alpha Plots', field);
0124 d = setNewFlag(d, outFlags.new.out, 'alpha');
0125 d = updateFlags(d, 1);
0126
0127 d = logcal(d, 'alpha');
0128
0129
0130 case 2
0131 d = assembleAlphaStreams(d,'POLONLY');
0132 if(solveAlpha)
0133 [tA,Ac,Gc] = calculateAlpha(d,'POLONLY');
0134 d=applyAlpha(d, tA, Ac, Gc,'POLONLY');
0135 else
0136
0137 d = applyAlpha(d,'POLONLY');
0138 end
0139 display('No plot for you');
0140 printDisclaimer2;
0141
0142
0143
0144
0145 d = logcal(d, 'alpha');
0146
0147 otherwise
0148
0149 d = assembleAlphaStreams(d,'FILTERED');
0150 if(solveAlpha)
0151 [tA,Af,Gf] = calculateAlpha(d,'FILTERED');
0152 d = applyAlpha(d, tA, Af, Gf,'FILTERED');
0153 else
0154
0155 d = applyAlpha(d,'FILTERED');
0156 end
0157 printDisclaimerFilter;
0158
0159 d = logcal(d, 'alpha');
0160
0161 end
0162
0163
0164
0165
0166
0167
0168 return;
0169
0170
0171
0172 function d=checkstatus(d, flags)
0173
0174 disp('Would you like to view the plots?')
0175
0176 if (query)
0177 d = packd(d, d.flags, 'none', 'alpha', 0, 'Alpha Plots', '');
0178 end
0179
0180 disp(' ')
0181
0182 return;
0183
0184
0185
0186 function printDisclaimer1()
0187
0188 disp('====================ATTENTION=====================');
0189 disp('You have now alpha calibrated your data');
0190 disp('Your antenna0.receiver.data structure has changed');
0191 disp('If the calibration thus far has worked, your');
0192 disp('columns in antenna0.receiver.data now correspond to:');
0193 disp('[TSKY_1 TLOAD_1 U1 Q1 U2 Q2 <U> <Q> TSKY_2 TLOAD_2]');
0194 disp('i.e. 10 Column format');
0195 disp('====================ATTENTION=====================');
0196
0197 return;
0198
0199
0200
0201 function printDisclaimerFilter()
0202
0203 disp('====================ATTENTION=====================');
0204 disp('You have now alpha calibrated your data');
0205 disp('Your antenna0.receiver.data structure has changed');
0206 disp('If the calibration thus far has worked, your');
0207 disp('columns in antenna0.receiver.data now correspond to:');
0208 disp('[ ((I+V)/2-TA) Q1 U2 (I-V)/2-TB]');
0209 disp('i.e. 4 Column format');
0210 disp('====================ATTENTION=====================');
0211
0212 return;
0213
0214
0215
0216 function printDisclaimer2()
0217
0218
0219 disp('====================ATTENTION=====================');
0220 disp('You have now alpha calibrated your data');
0221 disp('Your antenna0.receiver.data structure has changed');
0222 disp('If the calibration thus far has worked, your');
0223 disp('columns in antenna0.receiver.data now correspond to:');
0224 disp('[(TSKY_1-TLOAD_1) U1 Q1 U2 Q2 <U> <Q> (TSKY_2-TLOAD_2)]');
0225 disp('i.e. 8 Column format');
0226 disp('====================ATTENTION=====================');
0227
0228
0229 return;
0230