0001 function d = read_arc(start, finish, regs, arcdir, calfile)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if(~exist('regs'))
0015 regs=[];
0016 end
0017 if(~exist('arcdir'))
0018 arcdir=[];
0019 end
0020 if(~exist('calfile'))
0021 calfile=[];
0022 end
0023
0024 if(isempty(regs))
0025 regs={'array.frame.received'...
0026 'array.frame.utc double',...
0027 'array.frame.features',...
0028 'antenna0.roach1.LL double',...
0029 'antenna0.roach1.LLfreq double',...
0030 'antenna0.roach1.RR double',...
0031 'antenna0.roach1.RRfreq double',...
0032 'antenna0.roach1.U double',...
0033 'antenna0.roach1.Ufreq double',...
0034 'antenna0.roach1.Utime double',...
0035 'antenna0.roach1.Q double',...
0036 'antenna0.roach1.Qfreq double',...
0037 'antenna0.roach1.Qtime double',...
0038 'antenna0.roach1.load1 double',...
0039 'antenna0.roach1.load1freq double',...
0040 'antenna0.roach1.load2 double',...
0041 'antenna0.roach1.load2freq double',...
0042 'antenna0.roach1.utc double',...
0043 'antenna0.roach2.LL double',...
0044 'antenna0.roach2.LLfreq double',...
0045 'antenna0.roach2.RR double',...
0046 'antenna0.roach2.RRfreq double',...
0047 'antenna0.roach2.U double',...
0048 'antenna0.roach2.Ufreq double',...
0049 'antenna0.roach2.Utime double',...
0050 'antenna0.roach2.Q double',...
0051 'antenna0.roach2.Qfreq double',...
0052 'antenna0.roach2.Qtime double',...
0053 'antenna0.roach2.load1 double',...
0054 'antenna0.roach2.load1freq double',...
0055 'antenna0.roach2.load2 double',...
0056 'antenna0.roach2.load2freq double',...
0057 'antenna0.roach2.utc double',...
0058 'antenna0.roach1.switchstatus double',...
0059 'antenna0.roach2.switchstatus double',...
0060 'antenna0.thermal.ccTemperatureLoad double',...
0061 'antenna0.thermal.ccHeaterCurrent double',...
0062 'antenna0.thermal.lsTemperatureSensors double',...
0063 'antenna0.thermal.utc double',...
0064 'antenna0.roach1.version double',...
0065 'antenna0.servo.fast_az_pos double',...
0066 'antenna0.servo.fast_el_pos double',...
0067 'antenna0.servo.fast_az_err double',...
0068 'antenna0.servo.fast_el_err double',...
0069 'antenna0.servo.utc double',...
0070 'antenna0.tracker.siteActual double',...
0071 'antenna0.tracker.utc double',...
0072 };
0073 end
0074
0075
0076 if(any(size(unique(regs))~=size(regs)))
0077 error('regs should be unique');
0078 end
0079
0080
0081
0082 [defaultDataDir defaultCalFile defaultReaderPath] = whichHostSa();
0083
0084 if(isempty(arcdir))
0085
0086 arcdir = defaultDataDir;
0087 end
0088 if(isempty(calfile))
0089 calfile = defaultCalFile;
0090 end
0091
0092 eval(sprintf('addpath %s', defaultReaderPath));
0093
0094
0095
0096 mjdstartorig = tstr2mjd(start);
0097 mjdstart = mjdstartorig - 5/60/60/24;
0098 mjdstoporig = tstr2mjd(finish);
0099 mjdstop = mjdstoporig + 5/60/60/24;
0100
0101
0102 d = cbassMatReadArcOpt(regs, mjd2string(mjdstart), mjd2string(mjdstop), arcdir, calfile);
0103
0104
0105 d = massageData(d);
0106
0107
0108 d = reshapeRegisters(d);
0109
0110
0111 d = interpRegistersSa(d);
0112
0113
0114
0115
0116 return;
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210 host = strfind(w, 'aslx5');
0211 if(~isempty(host))
0212 hostNum = 7;
0213 defaultDataDir = '/home/cbassuser/cbass_data/arc';
0214 defaultCalfile = '/home/cbassuser/cbass/gcpCbass/control/conf/cbass/cal';
0215 defaultReader = '/home/cbassuser/cbass/gcpCbass/matlab/common/';
0216 end
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231 function d = cutDesiredData(d, mjdstartorig, mjdstoporig)
0232
0233 if(~isfield(d, 'array'))
0234 return;
0235 end
0236
0237 if(~isfield(d, 'antenna0'))
0238 return;
0239 end
0240
0241 if(issubfield(d.antenna0, 'receiver', 'utc'))
0242 indFast = d.antenna0.receiver.utc>=mjdstartorig & ...
0243 d.antenna0.receiver.utc<mjdstoporig;
0244 noRx = 0;
0245 else
0246 indFast = ones(length(d.array.frame.utc)*100,1);
0247 indFast = logical(indFast);
0248 noRx = 1;
0249 end
0250
0251 if(isfield(d.antenna0, 'servo'))
0252 indMed = d.antenna0.servo.utc>=mjdstartorig & ...
0253 d.antenna0.servo.utc<mjdstoporig;
0254 noServo = 0;
0255 else
0256 indMed = ones(length(d.array.frame.utc)*5,1);
0257 indMed = logical(indMed);
0258 noServo = 1;
0259 end
0260
0261 indSlow = d.array.frame.utc>=mjdstartorig & d.array.frame.utc<mjdstoporig;
0262
0263
0264 indF = reshape(indFast, [5 20 length(indSlow)]);
0265 indF = permute(indF, [3 1 2]);
0266 indFs = mean(mean(indF,3),2)==1;
0267
0268 indM = reshape(indMed, [5 length(indSlow)]);
0269 indM = permute(indM, [2 1]);
0270 indMs = mean(indM,2)==1;
0271
0272 ind = indMs & indFs & indSlow;
0273
0274
0275
0276
0277 d = framecut(d, ind, 'regular');
0278
0279 return;
0280