Commits
168 168 | Double timeInterval, |
169 169 | Bool addDefaultSortColumns, |
170 170 | Bool storeSorted) |
171 171 | : MSIter() |
172 172 | { |
173 173 | bms_p=mss; |
174 174 | curMS_p=0; |
175 175 | lastMS_p=-1; |
176 176 | storeSorted_p=storeSorted; |
177 177 | interval_p=timeInterval; |
178 + | prevFirstTimeStamp_p = -1.0; |
178 179 | this->construct2(sortColumns,addDefaultSortColumns); |
179 180 | |
180 181 | } |
181 182 | |
182 183 | void MSIter2::origin() |
183 184 | { |
184 185 | // Reset time comparer, if present |
185 186 | // (Ensures repeatability!) |
186 187 | if (timeComp_p) timeComp_p->setOffset(0.0); |
187 188 | |
219 220 | bms_p[0].keywordSet().isDefined("SORT_COLUMNS")) { |
220 221 | // note that we use the order of the first MS for all MS's |
221 222 | Vector<String> colNames = bms_p[0].keywordSet().asArrayString("SORT_COLUMNS"); |
222 223 | uInt n=colNames.nelements(); |
223 224 | cols.resize(n); |
224 225 | for (uInt i=0; i<n; i++) cols[i]=MS::columnType(colNames(i)); |
225 226 | } else { |
226 227 | cols=sortColumns; |
227 228 | } |
228 229 | |
229 - | Bool timeSeen=False, arraySeen=False, ddSeen=False, fieldSeen=False, scanSeen=False; |
230 + | timeInSort_p=False, arrayInSort_p=False, ddInSort_p=False, fieldInSort_p=False; |
231 + | bool scanSeen; |
230 232 | Int nCol=0; |
231 233 | for (uInt i=0; i<cols.nelements(); i++) { |
232 234 | if (cols[i]>0 && |
233 235 | cols[i]<MS::NUMBER_PREDEFINED_COLUMNS) { |
234 - | if (cols[i]==MS::ARRAY_ID && !arraySeen) { arraySeen=True; nCol++; } |
235 - | if (cols[i]==MS::FIELD_ID && !fieldSeen) { fieldSeen=True; nCol++; } |
236 - | if (cols[i]==MS::DATA_DESC_ID && !ddSeen) { ddSeen=True; nCol++; } |
237 - | if (cols[i]==MS::TIME && !timeSeen) { timeSeen=True; nCol++; } |
236 + | if (cols[i]==MS::ARRAY_ID && !arrayInSort_p) { arrayInSort_p=True; nCol++; } |
237 + | if (cols[i]==MS::FIELD_ID && !fieldInSort_p) { fieldInSort_p=True; nCol++; } |
238 + | if (cols[i]==MS::DATA_DESC_ID && !ddInSort_p) { ddInSort_p=True; nCol++; } |
239 + | if (cols[i]==MS::TIME && !timeInSort_p) { timeInSort_p=True; nCol++; } |
238 240 | if (cols[i]==MS::SCAN_NUMBER && !scanSeen) { scanSeen=True; } |
239 241 | } else { |
240 242 | throw(AipsError("MSIter() - invalid sort column")); |
241 243 | } |
242 244 | } |
243 245 | Block<String> columns; |
244 246 | |
245 247 | Int iCol=0; |
246 248 | if (addDefaultSortColumns) { |
247 249 | columns.resize(cols.nelements()+4-nCol); |
248 - | if (!arraySeen) { |
250 + | if (!arrayInSort_p) { |
249 251 | // add array if it's not there |
250 252 | columns[iCol++]=MS::columnName(MS::ARRAY_ID); |
251 253 | } |
252 - | if (!fieldSeen) { |
254 + | if (!fieldInSort_p) { |
253 255 | // add field if it's not there |
254 256 | columns[iCol++]=MS::columnName(MS::FIELD_ID); |
255 257 | } |
256 - | if (!ddSeen) { |
258 + | if (!ddInSort_p) { |
257 259 | // add dd if it's not there |
258 260 | columns[iCol++]=MS::columnName(MS::DATA_DESC_ID); |
259 261 | } |
260 - | if (!timeSeen) { |
262 + | if (!timeInSort_p) { |
261 263 | // add time if it's not there |
262 264 | columns[iCol++]=MS::columnName(MS::TIME); |
263 - | timeSeen = True; |
265 + | timeInSort_p = True; |
264 266 | } |
265 267 | } else { |
266 268 | columns.resize(cols.nelements()); |
267 269 | } |
268 270 | for (uInt i=0; i<cols.nelements(); i++) { |
269 271 | columns[iCol++]=MS::columnName(MS::PredefinedColumns(cols[i])); |
270 272 | } |
271 273 | |
272 274 | if (interval_p==0.0) { |
273 275 | interval_p=DBL_MAX; // semi infinite |
274 276 | } else { |
275 277 | // assume that we want to sort on time if interval is set |
276 - | if (!timeSeen) { |
278 + | if (!timeInSort_p) { |
277 279 | columns.resize(columns.nelements()+1); |
278 280 | columns[iCol++]=MS::columnName(MS::TIME); |
279 281 | } |
280 282 | } |
281 283 | |
282 284 | // now find the time column and set the compare function |
283 285 | Block<CountedPtr<BaseCompare> > objComp(columns.nelements()); |
284 286 | Block<Int> sortOrd(columns.nelements()); |
285 287 | timeComp_p = 0; |
286 288 | Bool fieldBounded(false); |