Commits
286 286 | freqEnd=max(freqEnd, localmax+fabs(chanWidths[localmaxpos[0]]/2.0)); |
287 287 | freqStart=min(freqStart, localmin-fabs(chanWidths[localminpos[0]]/2.0)); |
288 288 | } |
289 289 | |
290 290 | } |
291 291 | } |
292 292 | freqMin=freqStart; |
293 293 | freqMax=freqEnd; |
294 294 | } |
295 295 | |
296 - | void VisBufferUtil::getFreqRangeFromRange(casacore::Double& outfreqMin, casacore::Double& outfreqMax, const casacore::MFrequency::Types inFreqFrame, const casacore::Double infreqMin, const casacore::Double infreqMax, vi::VisibilityIterator2& vi, casacore::MFrequency::Types outFreqFrame){ |
296 + | Bool VisBufferUtil::getFreqRangeFromRange(casacore::Double& outfreqMin, casacore::Double& outfreqMax, const casacore::MFrequency::Types inFreqFrame, const casacore::Double infreqMin, const casacore::Double infreqMax, vi::VisibilityIterator2& vi, casacore::MFrequency::Types outFreqFrame){ |
297 297 | |
298 298 | |
299 299 | if(inFreqFrame==outFreqFrame){ |
300 300 | outfreqMin=infreqMin; |
301 301 | outfreqMax=infreqMax; |
302 - | return; |
302 + | return True; |
303 303 | } |
304 304 | |
305 305 | vi.originChunks(); |
306 306 | vi.origin(); |
307 307 | |
308 - | outfreqMin=C::dbl_max; |
309 - | outfreqMax=0; |
310 - | vi::VisBuffer2* vb=vi.getVisBuffer(); |
311 - | ROMSColumns msc(vi.ms()); |
312 - | // The nominal epoch |
313 - | MEpoch ep=msc.timeMeas()(0); |
314 - | |
315 - | // The nominal position |
316 - | String observatory; |
317 - | MPosition pos; |
318 - | if (msc.observation().nrow() > 0) { |
319 - | observatory = msc.observation().telescopeName() |
320 - | (msc.observationId()(0)); |
321 - | } |
322 - | if (observatory.length() == 0 || |
323 - | !MeasTable::Observatory(pos,observatory)) { |
324 - | // unknown observatory, use first antenna |
325 - | pos=msc.antenna().positionMeas()(0); |
326 - | } |
327 - | |
328 - | // The nominal direction |
329 - | MDirection dir=vb->phaseCenter(); |
330 - | MeasFrame mFrame(ep, pos, dir); |
331 - | // The conversion engine: |
332 - | MFrequency::Convert toNewFrame(inFreqFrame, |
333 - | MFrequency::Ref(outFreqFrame, mFrame)); |
334 - | |
308 + | try{ |
309 + | outfreqMin=C::dbl_max; |
310 + | outfreqMax=0; |
311 + | vi::VisBuffer2* vb=vi.getVisBuffer(); |
312 + | ROMSColumns msc(vi.ms()); |
313 + | // The nominal epoch |
314 + | MEpoch ep=msc.timeMeas()(0); |
315 + | |
316 + | // The nominal position |
317 + | String observatory; |
318 + | MPosition pos; |
319 + | if (msc.observation().nrow() > 0) { |
320 + | observatory = msc.observation().telescopeName() |
321 + | (msc.observationId()(0)); |
322 + | } |
323 + | if (observatory.length() == 0 || |
324 + | !MeasTable::Observatory(pos,observatory)) { |
325 + | // unknown observatory, use first antenna |
326 + | pos=msc.antenna().positionMeas()(0); |
327 + | } |
328 + | |
329 + | // The nominal direction |
330 + | MDirection dir=vb->phaseCenter(); |
331 + | MeasFrame mFrame(ep, pos, dir); |
332 + | // The conversion engine: |
333 + | MFrequency::Convert toNewFrame(inFreqFrame, |
334 + | MFrequency::Ref(outFreqFrame, mFrame)); |
335 + | |
335 336 | for (vi.originChunks(); vi.moreChunks();vi.nextChunk()) |
336 337 | { |
337 338 | for (vi.origin(); vi.more();vi.next()){ |
338 339 | //assuming time is fixed in visbuffer |
339 340 | mFrame.resetEpoch(vb->time()(0)/86400.0); |
340 - | |
341 + | |
341 342 | // Reset the direction (ASSUMES phaseCenter is constant in the VisBuffer) |
342 343 | mFrame.resetDirection(vb->phaseCenter()); |
343 344 | Double temp=toNewFrame(infreqMin).getValue().getValue(); |
344 345 | if(temp < outfreqMin) |
345 346 | outfreqMin = temp; |
346 347 | |
347 348 | temp=toNewFrame(infreqMax).getValue().getValue(); |
348 349 | if(temp > outfreqMax) |
349 350 | outfreqMax = temp; |
350 351 | } |
351 352 | } |
353 + | } |
354 + | catch(...){ |
355 + | //Could not do a conversion |
356 + | return False; |
357 + | |
358 + | } |
352 359 | //cerr << "min " << outfreqMin << " max " << outfreqMax << endl; |
353 - | |
360 + | return True; |
354 361 | } |
355 362 | |
356 363 | void VisBufferUtil::convertFrequency(Vector<Double>& outFreq, |
357 364 | const VisBuffer& vb, |
358 365 | const MFrequency::Types freqFrame){ |
359 366 | Int spw=vb.spectralWindow(); |
360 367 | MFrequency::Types obsMFreqType=(MFrequency::Types)(vb.msColumns().spectralWindow().measFreqRef()(spw)); |
361 368 | |
362 369 | // The input frequencies (a reference) |
363 370 | Vector<Double> inFreq(vb.frequency()); |
759 766 | String index=oss.str(); |
760 767 | rowincache=timeAntIndex_p[oldMSId_p][index]; |
761 768 | ///////TESTOO |
762 769 | /* if(rowincache>=0){ |
763 770 | cerr << "msid " << oldMSId_p << " key "<< index << " index " << rowincache<< " " << cachedPointingDir_p[oldMSId_p][rowincache] << endl; |
764 771 | }*/ |
765 772 | ///////////// |
766 773 | //tim.show("retrieved cache"); |
767 774 | }///if usepointing |
768 775 | if(rowincache <0) |
769 - | return vb.phaseCenter(); |
776 + | return getPhaseCenter(vb); |
770 777 | return cachedPointingDir_p[oldMSId_p][rowincache]; |
771 778 | |
772 779 | |
773 780 | |
774 781 | } |
775 782 | |
776 783 | void VisBufferUtil::pointingIndex(Double*& timecol, Int*& antcol, Double*& intervalcol, const Int nrow, const Int ant, const Int ntimes, Double*& ptime, Vector<Int>& indices){ |
777 784 | |
778 785 | indices.resize(ntimes); |
779 786 | |