Commits
1498 1498 | const auto pointingInterval = act_mspc.interval()(pointingIndex); |
1499 1499 | const auto needInterpolation = (rowTimeInterval < pointingInterval); |
1500 1500 | |
1501 1501 | // 3. Create interpolator if needed |
1502 1502 | Bool dointerp = false; |
1503 1503 | if (havePointings && needInterpolation) { |
1504 1504 | dointerp = true; |
1505 1505 | // Known points are the directions of the specified |
1506 1506 | // POINTING table column, |
1507 1507 | // relative to the reference frame of the POINTING table |
1508 - | if (!isSplineInterpolationReady) { |
1508 + | if (not isSplineInterpolationReady) { |
1509 1509 | interpolator = new SDPosInterpolator(vb, pointingDirCol_p); |
1510 1510 | isSplineInterpolationReady = true; |
1511 1511 | } else { |
1512 1512 | if (not interpolator->inTimeRange(rowTime, rowAntenna1)) { |
1513 1513 | // setup spline interpolator for the current dataset (CAS-11261, 2018/5/22 WK) |
1514 1514 | delete interpolator; |
1515 1515 | interpolator = 0; |
1516 1516 | interpolator = new SDPosInterpolator(vb, pointingDirCol_p); |
1517 - | // Missing isSplineInterpolationReady = true; ? |
1518 1517 | } |
1519 1518 | } |
1520 1519 | } |
1521 1520 | |
1522 - | // 4. If it does not already exists, create the machine to convert pointings directions |
1521 + | // 4. If it does not already exist, create the machine to convert pointings directions |
1523 1522 | // and update the frame holding the measurements for this row |
1524 1523 | const MEpoch rowEpoch(Quantity(rowTime, "s")); |
1525 1524 | if (not pointingToImage) { |
1526 1525 | // Set the frame |
1527 - | const MPosition rowAntenna1Position = |
1526 + | const auto & rowAntenna1Position = |
1528 1527 | vb.msColumns().antenna().positionMeas()(rowAntenna1); |
1529 1528 | |
1530 1529 | mFrame_p = MeasFrame(rowEpoch, rowAntenna1Position); |
1531 1530 | |
1532 1531 | // Remember antenna id for next call, |
1533 1532 | // which may be done using a different VisBuffer ... |
1534 1533 | lastAntID_p = rowAntenna1; |
1535 1534 | |
1536 1535 | // Not clear why we compute directions at this stage |
1537 1536 | if (havePointings) { |
1561 1560 | // antenna ID is unset |
1562 1561 | logIO_p << LogIO::DEBUGGING |
1563 1562 | << "updating antenna position for conversion: new MS ID " << msId_p |
1564 1563 | << ", antenna ID " << rowAntenna1 << LogIO::POST; |
1565 1564 | } else { |
1566 1565 | logIO_p << LogIO::DEBUGGING |
1567 1566 | << "updating antenna position for conversion: MS ID " << msId_p |
1568 1567 | << ", last antenna ID " << lastAntID_p |
1569 1568 | << ", new antenna ID " << rowAntenna1 << LogIO::POST; |
1570 1569 | } |
1571 - | const MPosition rowAntenna1Position = |
1570 + | const auto & rowAntenna1Position = |
1572 1571 | vb.msColumns().antenna().positionMeas()(rowAntenna1); |
1573 1572 | |
1574 1573 | mFrame_p.resetPosition(rowAntenna1Position); |
1575 1574 | |
1576 1575 | // Remember antenna id for next call, |
1577 1576 | // which may be done using a different VisBuffer ... |
1578 1577 | lastAntID_p = rowAntenna1; |
1579 1578 | } |
1580 1579 | } |
1581 1580 | |
1594 1593 | //printf("%lf %lf \n", newdirv(0), newdirv(1)); |
1595 1594 | } else { |
1596 1595 | worldPosMeas = (*pointingToImage)(directionMeas(act_mspc, pointingIndex)); |
1597 1596 | } |
1598 1597 | } else { |
1599 1598 | // Without pointings, this converts the direction of the phase center |
1600 1599 | worldPosMeas = (*pointingToImage)(vb.direction1()(row)); |
1601 1600 | } |
1602 1601 | |
1603 1602 | // 6. Convert world position coordinates to image pixel coordinates |
1604 - | Bool result = directionCoord.toPixel(xyPos, worldPosMeas); |
1605 - | if (!result) { |
1603 + | Bool havePixel = directionCoord.toPixel(xyPos, worldPosMeas); |
1604 + | if (not havePixel) { |
1606 1605 | logIO_p << "Failed to find a pixel for pointing direction of " |
1607 1606 | << MVTime(worldPosMeas.getValue().getLong("rad")).string(MVTime::TIME) |
1608 1607 | << ", " << MVAngle(worldPosMeas.getValue().getLat("rad")).string(MVAngle::ANGLE) |
1609 1608 | << LogIO::WARN << LogIO::POST; |
1610 1609 | return false; |
1611 1610 | } |
1612 1611 | |
1613 1612 | // 7. Handle moving sources |
1614 1613 | if ((pointingDirCol_p == "SOURCE_OFFSET") || (pointingDirCol_p == "POINTING_OFFSET")) { |
1615 1614 | // It makes no sense to track in offset coordinates... |
1627 1626 | MDirection actSourceDir = (*pointingToImage)(tmphadec); |
1628 1627 | Vector<Double> actPix; |
1629 1628 | directionCoord.toPixel(actPix, actSourceDir); |
1630 1629 | |
1631 1630 | //cout << row << " scan " << vb.scan()(row) << "xyPos " << xyPos |
1632 1631 | // << " xyposmovorig " << xyPosMovingOrig_p << " actPix " << actPix << endl; |
1633 1632 | |
1634 1633 | xyPos = xyPos + xyPosMovingOrig_p - actPix; |
1635 1634 | } |
1636 1635 | |
1637 - | return result; |
1636 + | return havePixel; |
1638 1637 | } |
1639 1638 | |
1640 1639 | MDirection SDGrid::directionMeas(const MSPointingColumns& mspc, const Int& index){ |
1641 1640 | if (pointingDirCol_p == "TARGET") { |
1642 1641 | return mspc.targetMeas(index); |
1643 1642 | } else if (pointingDirCol_p == "POINTING_OFFSET") { |
1644 1643 | if (!mspc.pointingOffsetMeasCol().isNull()) { |
1645 1644 | return mspc.pointingOffsetMeas(index); |
1646 1645 | } |
1647 1646 | cerr << "No PONTING_OFFSET column in POINTING table" << endl; |