Commits
Suminori Nishie authored aea2861bc84
352 352 | throw AipsError(ss.str()); |
353 353 | } |
354 354 | |
355 355 | //+ |
356 356 | // CAS:8418::Limmited service, |
357 357 | // when indeicated by flag,force to use traditional Linear Interpolation. |
358 358 | //- |
359 359 | |
360 360 | if (getCurrentSplineObj()->isCoefficientReady() == false ) |
361 361 | { |
362 - | //SN05JUN2019: Duplicated message // |
363 - | LogIO os(LogOrigin("PointingDirectionCalculator", "doGetDirection(i)", WHERE)); |
364 - | os << LogIO::WARN << "INSUFFICIENT NUMBER OF POINTING DATA, \n" |
365 - | << "forced to use Linear Interpolation " << LogIO::POST; |
366 - | |
367 362 | useSplineInterpolation_ = false; |
368 363 | } |
369 364 | |
370 - | |
371 - | // Trap // |
372 - | if(accessorId_ == ENCODER) |
373 - | currSpline_ = nullptr; |
374 - | |
375 - | |
376 365 | debuglog << "initializeSplinefromPointingColumn, Normal End." << debugpost; |
377 366 | |
378 367 | // ---org code --- |
379 368 | configureMovingSourceCorrection(); |
380 369 | } |
381 370 | |
382 371 | void PointingDirectionCalculator::setFrame(String const frameType) { |
383 372 | Bool status = MDirection::getType(directionType_, frameType); |
384 373 | if (!status) { |
385 374 | LogIO os(LogOrigin("PointingDirectionCalculator", "setFrame", WHERE)); |
470 459 | uInt const nrowPointing = pointingTimeUTC_.nelements(); |
471 460 | debuglog << "nrowPointing = " << nrowPointing << debugpost; |
472 461 | debuglog << "pointingTimeUTC = " << min(pointingTimeUTC_) << "~" |
473 462 | << max(pointingTimeUTC_) << debugpost; |
474 463 | |
475 464 | for (uInt j = start; j < end; ++j) { |
476 465 | debuglog << "start index " << j << debugpost; |
477 466 | |
478 467 | // doGetDirection call // |
479 468 | |
480 - | // # define OLD_DOGET |
469 + | Vector<Double> direction = doGetDirection(j,currentAntenna); // CAS-8418 args werre changed. |
481 470 | |
482 - | |
483 - | Vector<Double> direction = doGetDirection(j); |
484 - | |
485 - | Vector<Double> direction = doGetDirection(j,currentAntenna); |
486 - | |
487 471 | debuglog << "index for lat: " << (j * increment) |
488 472 | << " (cf. outDirectionFlattened.nelements()=" |
489 473 | << outDirectionFlattened.nelements() << ")" << debugpost; |
490 474 | debuglog << "index for lon: " << (offset + j * increment) |
491 475 | << debugpost; |
492 476 | outDirectionFlattened[j * increment] = direction[0]; |
493 477 | outDirectionFlattened[offset + j * increment] = direction[1]; |
494 478 | } |
495 479 | debuglog << "done antenna " << currentAntenna << debugpost; |
496 480 | } |
497 481 | debuglog << "done getDirection" << debugpost; |
498 482 | return Matrix < Double > (outShape, outDirectionFlattened.data()); |
499 483 | } |
500 484 | |
501 485 | //************************************************** |
502 486 | // CAS-8418 |
503 487 | // doGetDirection(irow) |
504 488 | // - Spline Interpolation is executed, except |
505 489 | // number of data is insufficient |
506 490 | // - Interpolation path in the module was separated. |
507 491 | //*************************************************** |
508 - | |
509 - | Vector<Double> PointingDirectionCalculator::doGetDirection(uInt irow) { |
510 - | debuglog << "doGetDirection(" << irow << "," << lastAntennaIndex_ << ")" << debugpost; |
511 - | |
512 492 | Vector<Double> PointingDirectionCalculator::doGetDirection(uInt irow, uInt antID) { |
513 493 | debuglog << "doGetDirection(" << irow << "," << antID << ")" << debugpost; |
514 - | |
494 + | |
515 495 | // sec:1 Linear , Spline common// |
516 496 | Double currentTime = timeColumn_.convert(irow, MEpoch::UTC).get("s").getValue(); |
517 497 | resetTime(currentTime); |
518 498 | |
519 499 | // search and interpolate if necessary |
520 500 | Bool exactMatch; |
521 501 | uInt const nrowPointing = pointingTimeUTC_.nelements(); |
522 502 | // pointingTableIndexCache_ is not so effective in terms of performance |
523 503 | // simple binary search may be enough, |
524 504 | Int index = binarySearch(exactMatch, pointingTimeUTC_, currentTime, |
545 525 | debuglog << "linear interpolation " << debugpost; |
546 526 | |
547 527 | // commonly used result buffer .. // |
548 528 | Vector<Double> interpolated(2); |
549 529 | |
550 530 | if(useSplineInterpolation_) // SPLINE // |
551 531 | { |
552 532 | //+ |
553 533 | // CAS-8418:: Spline Interpolation section. |
554 534 | //- |
555 - | |
556 535 | |
557 - | // Right action (fortunately) // |
558 - | uInt antID = lastAntennaIndex_; // OLD code with problem: antID must be given from caller. // |
559 - | // Wrong action (appearantly) // |
560 - | uInt antID = 0; // OLD code with problem: antID must be given from caller. // |
561 - | |
562 - | |
563 536 | Double t0 = pointingTimeUTC_[index - 1]; |
564 537 | Double dtime = (currentTime - t0) ; |
565 538 | |
566 539 | // determin section on 'uIndex' |
567 540 | uInt uIndex; |
568 541 | if( index >=1 ){ |
569 542 | uIndex = index-1; |
570 543 | } else if (index > (Int)(nrowPointing-1) ) { |
571 544 | uIndex = nrowPointing-1; |
572 545 | } else { |
675 648 | Double currentTime = |
676 649 | timeColumn_.convert(i, MEpoch::UTC).get("s").getValue(); |
677 650 | resetAntennaPosition(currentAntennaIndex); |
678 651 | debuglog << "currentTime = " << currentTime << " lastTimeStamp_ = " |
679 652 | << lastTimeStamp_ << debugpost; |
680 653 | if (currentTime != lastTimeStamp_) { |
681 654 | resetTime(i); |
682 655 | } |
683 656 | debuglog << "doGetDirection" << debugpost; |
684 657 | |
685 - | |
686 - | Vector<Double> direction = doGetDirection(i); |
687 - | |
688 - | Vector<Double> direction = doGetDirection(i,currentAntennaIndex); |
689 - | |
658 + | Vector<Double> direction = doGetDirection(i,currentAntennaIndex); // CAS-8418 args were changed |
659 + | |
690 660 | return direction; |
691 661 | } |
692 662 | |
693 663 | Vector<uInt> PointingDirectionCalculator::getRowId() { |
694 664 | return selectedMS_->rowNumbers(); |
695 665 | } |
696 666 | |
697 667 | Vector<uInt> PointingDirectionCalculator::getRowIdForOriginalMS() { |
698 668 | return selectedMS_->rowNumbers(*originalMS_, True); |
699 669 | } |
910 880 | //+ |
911 881 | // Initialize Faiure. |
912 882 | //- |
913 883 | |
914 884 | stringstream ss; |
915 885 | ss << "FAILED:: No spline obj, atempted to make. No column on Pointing Table." << endl; |
916 886 | throw AipsError(ss.str()); |
917 887 | |
918 888 | } |
919 889 | |
890 + | //+ |
891 + | // CAS-8418:: |
892 + | // Exporting Internal Status/Object Service |
893 + | //- |
894 + | |
895 + | // Export COEFF: returns Coefficitent Table of the current Spline-Object |
896 + | PointingDirectionCalculator::COEFF PointingDirectionCalculator::exportCoeff() |
897 + | { |
898 + | SplineInterpolation *sp = this->getCurrentSplineObj(); |
899 + | return (sp->getCoeff()); |
900 + | } |
901 + | |
902 + | // Export status of COEFF: returns true if COEFF is available. |
903 + | bool PointingDirectionCalculator::isCoefficientReady() |
904 + | { |
905 + | SplineInterpolation *sp = this->getCurrentSplineObj(); |
906 + | return (sp->isCoefficientReady() ); |
907 + | } |
908 + | |
920 909 | //*************************************************** |
921 910 | // CAS-8418: |
922 911 | // Antenna Boundary (for Pointing Table ) methods |
923 912 | // - create antenna information on Pointing Table. |
924 913 | //*************************************************** |
925 914 | |
926 915 | //+ |
927 916 | // Antenna Boundary Class |
928 917 | //- |
929 918 | class AntennaBoundary { |
1173 1162 | |
1174 1163 | Vector<Double> outval(2); |
1175 1164 | outval[0] = Xs; |
1176 1165 | outval[1] = Ys; |
1177 1166 | |
1178 1167 | debuglog << "SplineInterpolation::calculate() Normal return." << debugpost; |
1179 1168 | |
1180 1169 | return outval; |
1181 1170 | |
1182 1171 | } |
1172 + | |
1183 1173 | |
1184 1174 | } //# NAMESPACE CASA - END |