Changeset 2254
- Timestamp:
- 07/29/11 15:25:46 (13 years ago)
- Location:
- trunk/external-alma/asdm2ASAP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/asdm2ASAP/ASDMReader.cc
r2252 r2254 1441 1441 unsigned int index = dataIdList_[idx] ; 1442 1442 vector<PointingRow *> *prows = asdm_->getPointing().getByContext( atag ) ; 1443 1444 if ( prows == 0 ) 1445 return ; 1446 1443 1447 PointingRow *prow ; 1444 1448 PointingRow *qrow ; … … 1459 1463 // } 1460 1464 1461 if ( nrow == 0 )1462 return ;1463 1464 1465 srate.resize(2) ; 1465 1466 srate[0] = 0.0 ; … … 1467 1468 az = 0.0 ; 1468 1469 el = 0.0 ; 1469 double tcen = 0.0 ; 1470 //double tcen = 0.0 ; 1471 double tcen = getMidTime( tint ).getMJD() ; 1470 1472 1471 1473 // … … 1483 1485 ArrayTimeInterval pTime0 = (*prows)[0]->getTimeInterval() ; 1484 1486 ArrayTimeInterval pTime1 = (*prows)[nrow-1]->getTimeInterval() ; 1485 if ( tint.getStartInMJD()+tint.getDurationInDays() < pTime0.getStartInMJD() ) { 1487 //if ( tint.getStartInMJD()+tint.getDurationInDays() < pTime0.getStartInMJD() ) { 1488 if ( getEndTime( tint ) < getStartTime( pTime0 ) ) { 1486 1489 logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint < ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; 1487 1490 prow = (*prows)[0] ; 1488 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; 1489 vector< vector<Angle> > dirA = prow->getTarget() ; 1490 vector< vector<Angle> > offA = prow->getOffset() ; 1491 //az = dirA[0][0].get() ; 1492 //el = dirA[0][1].get() ; 1493 az = dirA[0][0].get() + offA[0][0].get() ; 1494 el = dirA[0][1].get() + offA[0][1].get() ; 1491 vector< vector<double> > dirA = pointingDir( prow ) ; 1492 az = dirA[0][0] ; 1493 el = dirA[0][1] ; 1495 1494 if ( prow->getUsePolynomials() && prow->getNumTerm() > 1 ) { 1496 //srate[0] = dirA[1][0].get() ; 1497 //srate[1] = dirA[1][1].get() ; 1498 srate[0] = dirA[1][0].get() + offA[1][0].get() ; 1499 srate[1] = dirA[1][1].get() + offA[1][1].get() ; 1495 srate[0] = dirA[1][0] ; 1496 srate[1] = dirA[1][1] ; 1500 1497 } 1501 1498 } 1502 else if ( tint.getStartInMJD() > pTime1.getStartInMJD()+pTime1.getDurationInDays() ) { 1499 //else if ( tint.getStartInMJD() > pTime1.getStartInMJD()+pTime1.getDurationInDays() ) { 1500 else if ( getStartTime( tint ) > getEndTime( pTime1 ) ) { 1503 1501 logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint > ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; 1504 1502 prow = (*prows)[nrow-1] ; 1505 1503 int numSample = prow->getNumSample() ; 1506 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; 1507 vector< vector<Angle> > dirA = prow->getTarget() ; 1508 vector< vector<Angle> > offA = prow->getOffset() ; 1504 vector< vector<double> > dirA = pointingDir( prow ) ; 1509 1505 if ( prow->getUsePolynomials() ) { 1510 //az = dirA[0][0].get() ; 1511 //el = dirA[0][1].get() ; 1512 az = dirA[0][0].get() + offA[0][0].get() ; 1513 el = dirA[0][1].get() + offA[0][1].get() ; 1506 az = dirA[0][0] ; 1507 el = dirA[0][1] ; 1514 1508 if ( prow->getNumTerm() > 1 ) { 1515 //srate[0] = dirA[1][0].get() ; 1516 //srate[1] = dirA[1][1].get() ; 1517 srate[0] = dirA[1][0].get() + offA[1][0].get() ; 1518 srate[1] = dirA[1][1].get() + offA[1][0].get() ; 1519 } 1520 } 1521 else { 1522 //az = dirA[numSample-1][0].get() ; 1523 //el = dirA[numSample-1][1].get() ; 1524 az = dirA[numSample-1][0].get() + offA[numSample-1][0].get() ; 1525 el = dirA[numSample-1][1].get() + offA[numSample-1][1].get() ; 1509 srate[0] = dirA[1][0] ; 1510 srate[1] = dirA[1][1] ; 1511 } 1512 } 1513 else { 1514 az = dirA[numSample-1][0] ; 1515 el = dirA[numSample-1][1] ; 1526 1516 } 1527 1517 } 1528 1518 else { 1529 1519 ArrayTime startTime = tint.getStart() ; 1530 ArrayTime endTime ( tint.getStartInMJD()+tint.getDurationInDays()) ;1520 ArrayTime endTime = getEndTime( tint ) ; 1531 1521 int row0 = -1 ; 1532 1522 int row1 = -1 ; … … 1553 1543 double t0 = getEndTime( prow->getTimeInterval() ).getMJD() ; 1554 1544 double t1 = qrow->getTimeInterval().getStartInMJD() ; 1555 double t = startTime.getMJD() ; 1556 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; 1557 //vector< vector<Angle> > dirB = qrow->getPointingDirection() ; 1558 vector< vector<Angle> > dirA = prow->getTarget() ; 1559 vector< vector<Angle> > offA = prow->getOffset() ; 1560 vector< vector<Angle> > dirB = qrow->getTarget() ; 1561 vector< vector<Angle> > offB = qrow->getOffset() ; 1562 //double da0 = dirA[0][0].get() ; 1563 //double db0 = dirB[0][0].get() ; 1564 //double da1 = dirA[0][1].get() ; 1565 //double db1 = dirB[0][1].get() ; 1566 double da0 = dirA[0][0].get() + offA[0][0].get() ; 1567 double db0 = dirB[0][0].get() + offB[0][0].get() ; 1568 double da1 = dirA[0][1].get() + offA[0][1].get() ; 1569 double db1 = dirB[0][1].get() + offB[0][1].get() ; 1545 vector< vector<double> > dirA = pointingDir( prow ) ; 1546 vector< vector<double> > dirB = pointingDir( qrow ) ; 1547 double da0 = dirA[0][0] ; 1548 double db0 = dirB[0][0] ; 1549 double da1 = dirA[0][1] ; 1550 double db1 = dirB[0][1] ; 1570 1551 if ( prow->getUsePolynomials() && qrow->getUsePolynomials() ) { 1571 double dt = ( t - t0 ) / ( t1 - t0 ) ;1552 double dt = ( tcen - t0 ) / ( t1 - t0 ) ; 1572 1553 az = da0 + ( db0 - da0 ) * dt ; 1573 1554 el = da1 + ( db1 - da1 ) * dt ; 1574 1555 if ( prow->getNumTerm() > 0 && qrow->getNumTerm() > 1 ) { 1575 //double ra0 = dirA[1][0].get() ; 1576 //double rb0 = dirB[1][0].get() ; 1577 //double ra1 = dirA[1][1].get() ; 1578 //double rb1 = dirB[1][1].get() ; 1579 double ra0 = dirA[1][0].get() + offA[1][0].get() ; 1580 double rb0 = dirB[1][0].get() + offB[1][0].get() ; 1581 double ra1 = dirA[1][1].get() + offA[1][1].get() ; 1582 double rb1 = dirB[1][1].get() + offB[1][1].get() ; 1556 double ra0 = dirA[1][0] ; 1557 double rb0 = dirB[1][0] ; 1558 double ra1 = dirA[1][1] ; 1559 double rb1 = dirB[1][1] ; 1583 1560 srate[0] = ra0 + ( rb0 - ra0 ) * dt ; 1584 1561 srate[1] = ra1 + ( rb1 - ra1 ) * dt ; … … 1586 1563 } 1587 1564 else if ( !(qrow->getUsePolynomials()) ) { 1588 double dt = ( t - t0 ) / ( t1 - t0 ) ;1565 double dt = ( tcen - t0 ) / ( t1 - t0 ) ; 1589 1566 az = da0 + ( db0 - da0 ) * dt ; 1590 1567 el = da1 + ( db1 - da1 ) * dt ; … … 1608 1585 if ( row0 == row1 ) { 1609 1586 prow = (*prows)[row0] ; 1610 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; 1611 vector< vector<Angle> > dirA = prow->getTarget() ; 1612 vector< vector<Angle> > offA = prow->getOffset() ; 1613 //az = dirA[0][0].get() ; 1614 //el = dirA[0][1].get() ; 1615 az = dirA[0][0].get() + offA[0][0].get() ; 1616 el = dirA[0][1].get() + offA[0][1].get() ; 1587 vector< vector<double> > dirA = pointingDir( prow ) ; 1588 az = dirA[0][0] ; 1589 el = dirA[0][1] ; 1617 1590 if ( prow->getNumTerm() > 1 ) { 1618 //srate[0] = dirA[1][0].get() ; 1619 //srate[1] = dirA[1][1].get() ; 1620 srate[0] = dirA[1][0].get() + offA[1][0].get() ; 1621 srate[1] = dirA[1][1].get() + offA[1][0].get() ; 1591 srate[0] = dirA[1][0] ; 1592 srate[1] = dirA[1][1] ; 1622 1593 } 1623 1594 } … … 1625 1596 prow = (*prows)[row0] ; 1626 1597 qrow = (*prows)[row1] ; 1627 //vector< vector<Angle> > dirA = qrow->getPointingDirection() ; 1628 //vector< vector<Angle> > dirB = qrow->getPointingDirection() ; 1629 vector< vector<Angle> > dirA = qrow->getTarget() ; 1630 vector< vector<Angle> > offA = prow->getOffset() ; 1631 vector< vector<Angle> > dirB = qrow->getTarget() ; 1632 vector< vector<Angle> > offB = qrow->getOffset() ; 1598 vector< vector<double> > dirA = pointingDir( prow ) ; 1599 vector< vector<double> > dirB = pointingDir( qrow ) ; 1633 1600 double t0 = getMidTime( prow->getTimeInterval() ).getMJD() ; 1634 1601 double t1 = getMidTime( qrow->getTimeInterval() ).getMJD() ; 1635 double t = startTime.getMJD() ; 1636 double dt = ( t - t0 ) / ( t1 - t0 ) ; 1637 //double da0 = dirA[0][0].get() ; 1638 //double db0 = dirB[0][0].get() ; 1639 //double da1 = dirA[0][1].get() ; 1640 //double db1 = dirB[0][1].get() ; 1641 double da0 = dirA[0][0].get() + offA[0][0].get() ; 1642 double db0 = dirB[0][0].get() + offB[0][0].get() ; 1643 double da1 = dirA[0][1].get() + offA[0][1].get() ; 1644 double db1 = dirB[0][1].get() + offB[0][1].get() ; 1602 double dt = ( tcen - t0 ) / ( t1 - t0 ) ; 1603 double da0 = dirA[0][0] ; 1604 double db0 = dirB[0][0] ; 1605 double da1 = dirA[0][1] ; 1606 double db1 = dirB[0][1] ; 1645 1607 az = da0 + ( db0 - da0 ) * dt ; 1646 1608 el = da1 + ( db1 - db0 ) * dt ; 1647 1609 if ( prow->getNumTerm() > 0 && qrow->getNumTerm() > 1 ) { 1648 //double ra0 = dirA[1][0].get() ; 1649 //double rb0 = dirB[1][0].get() ; 1650 //double ra1 = dirA[1][1].get() ; 1651 //double rb1 = dirB[1][1].get() ; 1652 double ra0 = dirA[1][0].get() + offA[1][0].get() ; 1653 double rb0 = dirB[1][0].get() + offB[1][0].get() ; 1654 double ra1 = dirA[1][1].get() + offA[1][1].get() ; 1655 double rb1 = dirB[1][1].get() + offB[1][1].get() ; 1610 double ra0 = dirA[1][0] ; 1611 double rb0 = dirB[1][0] ; 1612 double ra1 = dirA[1][1] ; 1613 double rb1 = dirB[1][1] ; 1656 1614 srate[0] = ra0 + ( rb0 - ra0 ) * dt ; 1657 1615 srate[1] = ra1 + ( rb1 - ra1 ) * dt ; … … 1661 1619 else if ( prow->getUsePolynomials() == qrow->getUsePolynomials() ) { 1662 1620 //logsink_->postLocally( LogMessage("numSample == numTerm",LogOrigin(className_,funcName,WHERE)) ) ; 1621 tcen = 0.0 ; 1663 1622 for ( int irow = row0 ; irow <= row1 ; irow++ ) { 1664 1623 prow = (*prows)[irow] ; 1665 1624 int numSample = prow->getNumSample() ; 1666 1625 //logsink_->postLocally( LogMessage("numSample = "+String::toString(numSample),LogOrigin(className_,funcName,WHERE)) ) ; 1667 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; 1668 vector< vector<Angle> > dirA = prow->getTarget() ; 1669 vector< vector<Angle> > offA = prow->getOffset() ; 1626 vector< vector<double> > dirA = pointingDir( prow ) ; 1670 1627 if ( prow->isSampledTimeIntervalExists() ) { 1671 1628 //logsink_->postLocally( LogMessage("sampledTimeIntervalExists",LogOrigin(className_,funcName,WHERE)) ) ; … … 1674 1631 //if ( tint.overlaps( stime[isam] ) ) { 1675 1632 if ( tint.contains( stime[isam] ) ) { 1676 //az += dirA[isam][0].get() ; 1677 //el += dirA[isam][1].get() ; 1678 az += dirA[isam][0].get() + offA[isam][0].get() ; 1679 el += dirA[isam][1].get() + offA[isam][1].get() ; 1633 az += dirA[isam][0] ; 1634 el += dirA[isam][1] ; 1635 tcen += getMidTime( stime[isam] ).getMJD() ; 1680 1636 ndir++ ; 1681 1637 } … … 1692 1648 //if ( tint.overlaps( stime ) ) { 1693 1649 if ( tint.contains( stime ) ) { 1694 //az += dirA[isam][0].get() ; 1695 //el += dirA[isam][1].get() ; 1696 az += dirA[isam][0].get() + offA[isam][0].get() ; 1697 el += dirA[isam][1].get() + offA[isam][1].get() ; 1650 az += dirA[isam][0] ; 1651 el += dirA[isam][1] ; 1698 1652 tcen += getMidTime( stime ).getMJD() ; 1699 1653 ndir++ ; … … 1923 1877 return angle ; 1924 1878 } 1879 1880 vector< vector<double> > ASDMReader::pointingDir( PointingRow *row ) 1881 { 1882 //vector< vector<Angle> > aDir = row->getPointingDirection() ; 1883 vector< vector<Angle> > aDir = row->getTarget() ; 1884 vector< vector<Angle> > aOff = row->getOffset() ; 1885 unsigned int n = aDir.size() ; 1886 unsigned int m = 0 ; 1887 vector< vector<double> > dir( n ) ; 1888 for ( unsigned int i = 0 ; i < n ; i++ ) { 1889 m = aDir[i].size() ; 1890 dir[i].resize( m ) ; 1891 for ( unsigned int j = 0 ; j < m ; j++ ) { 1892 //dir[i][j] = aDir[i][j].get() ; 1893 dir[i][j] = aDir[i][j].get() + aOff[i][j].get() ; 1894 } 1895 } 1896 return dir ; 1897 } -
trunk/external-alma/asdm2ASAP/ASDMReader.h
r2252 r2254 556 556 **/ 557 557 double limitedAngle( double angle ) ; 558 559 /** 560 * retrieve pointing direction from pointingDirection column 561 * or from target+offset 562 * 563 * @param row pointer to PointingRow object 564 * @return pointing direction vector (matrix) 565 **/ 566 std::vector< std::vector<double> > pointingDir( asdm::PointingRow *row ) ; 558 567 559 568 asdm::ASDM *asdm_ ; // pointer to ASDM object
Note:
See TracChangeset
for help on using the changeset viewer.