- Timestamp:
- 07/15/11 16:25:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSFiller.cpp
r2231 r2232 561 561 562 562 // spectral setup 563 ROScalarQuantColumn<Double> *tmpQuantCol = new ROScalarQuantColumn<Double>( t3, "TIME" ) ; 564 me = MEpoch( (*tmpQuantCol)( 0 ), MEpoch::UTC ) ; 565 delete tmpQuantCol ; 566 MeasFrame mf( me, mp, md ) ; 567 tcolr = tpoolr->construct( spwtab, "MEAS_FREQ_REF" ) ; 568 MFrequency::Types freqRef = MFrequency::castType((uInt)(tcolr->asInt(spwId))) ; 569 tpoolr->destroy( tcolr ) ; 563 uInt freqId ; 570 564 tcolr = tpoolr->construct( spwtab, "NUM_CHAN" ) ; 571 565 Int nchan = tcolr->asInt( spwId ) ; … … 573 567 if ( nchan == 4 ) iswvr = True ; 574 568 tpoolr->destroy( tcolr ) ; 575 Bool even = False ; 576 if ( (nchan/2)*2 == nchan ) even = True ; 577 sdh.nchan = max( sdh.nchan, nchan ) ; 578 tmpQuantCol = new ROScalarQuantColumn<Double>( spwtab, "TOTAL_BANDWIDTH" ) ; 579 Double totbw = (*tmpQuantCol)( spwId ).getValue( "Hz" ) ; 580 delete tmpQuantCol ; 581 if ( nchan != 4 ) 582 sdh.bandwidth = max( sdh.bandwidth, totbw ) ; 583 if ( sdh.freqref == "" && nchan != 4) 584 //sdh.freqref = MFrequency::showType( freqRef ) ; 585 sdh.freqref = "LSRK" ; 586 if ( sdh.reffreq == -1.0 && nchan != 4 ) { 587 tmpQuantCol = new ROScalarQuantColumn<Double>( spwtab, "REF_FREQUENCY" ) ; 588 Quantum<Double> qreffreq = (*tmpQuantCol)( spwId ) ; 569 map<Int,uInt>::iterator iter = ifmap.find( spwId ) ; 570 if ( iter == ifmap.end() ) { 571 ROScalarQuantColumn<Double> *tmpQuantCol = new ROScalarQuantColumn<Double>( t3, "TIME" ) ; 572 me = MEpoch( (*tmpQuantCol)( 0 ), MEpoch::UTC ) ; 589 573 delete tmpQuantCol ; 590 // sdh.reffreq = qreffreq.getValue("Hz") ; 574 MeasFrame mf( me, mp, md ) ; 575 tcolr = tpoolr->construct( spwtab, "MEAS_FREQ_REF" ) ; 576 MFrequency::Types freqRef = MFrequency::castType((uInt)(tcolr->asInt(spwId))) ; 577 tpoolr->destroy( tcolr ) ; 578 Bool even = False ; 579 if ( (nchan/2)*2 == nchan ) even = True ; 580 sdh.nchan = max( sdh.nchan, nchan ) ; 581 tmpQuantCol = new ROScalarQuantColumn<Double>( spwtab, "TOTAL_BANDWIDTH" ) ; 582 Double totbw = (*tmpQuantCol)( spwId ).getValue( "Hz" ) ; 583 delete tmpQuantCol ; 584 if ( nchan != 4 ) 585 sdh.bandwidth = max( sdh.bandwidth, totbw ) ; 586 if ( sdh.freqref == "" && nchan != 4) 587 //sdh.freqref = MFrequency::showType( freqRef ) ; 588 sdh.freqref = "LSRK" ; 589 if ( sdh.reffreq == -1.0 && nchan != 4 ) { 590 tmpQuantCol = new ROScalarQuantColumn<Double>( spwtab, "REF_FREQUENCY" ) ; 591 Quantum<Double> qreffreq = (*tmpQuantCol)( spwId ) ; 592 delete tmpQuantCol ; 593 // sdh.reffreq = qreffreq.getValue("Hz") ; 594 if ( freqRef == MFrequency::LSRK ) { 595 sdh.reffreq = qreffreq.getValue("Hz") ; 596 } 597 else { 598 MFrequency::Convert tolsr( freqRef, MFrequency::Ref( MFrequency::LSRK, mf ) ) ; 599 sdh.reffreq = tolsr( qreffreq ).get("Hz").getValue() ; 600 } 601 } 602 Int refchan = nchan / 2 ; 603 IPosition refip( 1, refchan ) ; 604 Double refpix = 0.5*(nchan-1) ; 605 Double refval = 0.0 ; 606 sharedQDArrCol = new ROArrayQuantColumn<Double>( spwtab, "CHAN_WIDTH" ) ; 607 Double increment = (*sharedQDArrCol)( spwId )( refip ).getValue( "Hz" ) ; 608 delete sharedQDArrCol ; 609 // os_ << "nchan = " << nchan << " refchan = " << refchan << "(even=" << even << ") refpix = " << refpix << LogIO::POST ; 610 sharedQDArrCol = new ROArrayQuantColumn<Double>( spwtab, "CHAN_FREQ" ) ; 611 Vector< Quantum<Double> > chanFreqs = (*sharedQDArrCol)( spwId ) ; 612 delete sharedQDArrCol ; 613 if ( nchan > 1 && chanFreqs[0].getValue("Hz") > chanFreqs[1].getValue("Hz") ) 614 increment *= -1.0 ; 615 // if ( even ) { 616 // IPosition refip0( 1, refchan-1 ) ; 617 // Double refval0 = chanFreqs(refip0).getValue("Hz") ; 618 // Double refval1 = chanFreqs(refip).getValue("Hz") ; 619 // refval = 0.5 * ( refval0 + refval1 ) ; 620 // } 621 // else { 622 // refval = chanFreqs(refip).getValue("Hz") ; 623 // } 591 624 if ( freqRef == MFrequency::LSRK ) { 592 sdh.reffreq = qreffreq.getValue("Hz") ; 625 if ( even ) { 626 IPosition refip0( 1, refchan-1 ) ; 627 Double refval0 = chanFreqs(refip0).getValue("Hz") ; 628 Double refval1 = chanFreqs(refip).getValue("Hz") ; 629 refval = 0.5 * ( refval0 + refval1 ) ; 630 } 631 else { 632 refval = chanFreqs(refip).getValue("Hz") ; 633 } 593 634 } 594 635 else { 595 636 MFrequency::Convert tolsr( freqRef, MFrequency::Ref( MFrequency::LSRK, mf ) ) ; 596 sdh.reffreq = tolsr( qreffreq ).get("Hz").getValue() ; 637 if ( even ) { 638 IPosition refip0( 1, refchan-1 ) ; 639 Double refval0 = chanFreqs(refip0).getValue("Hz") ; 640 Double refval1 = chanFreqs(refip).getValue("Hz") ; 641 refval = 0.5 * ( refval0 + refval1 ) ; 642 refval = tolsr( refval ).get("Hz").getValue() ; 643 } 644 else { 645 refval = tolsr( chanFreqs(refip) ).get("Hz").getValue() ; 646 } 597 647 } 598 } 599 Int refchan = nchan / 2 ; 600 IPosition refip( 1, refchan ) ; 601 Double refpix = 0.5*(nchan-1) ; 602 Double refval = 0.0 ; 603 sharedQDArrCol = new ROArrayQuantColumn<Double>( spwtab, "CHAN_WIDTH" ) ; 604 Double increment = (*sharedQDArrCol)( spwId )( refip ).getValue( "Hz" ) ; 605 delete sharedQDArrCol ; 606 // os_ << "nchan = " << nchan << " refchan = " << refchan << "(even=" << even << ") refpix = " << refpix << LogIO::POST ; 607 sharedQDArrCol = new ROArrayQuantColumn<Double>( spwtab, "CHAN_FREQ" ) ; 608 Vector< Quantum<Double> > chanFreqs = (*sharedQDArrCol)( spwId ) ; 609 delete sharedQDArrCol ; 610 if ( nchan > 1 && chanFreqs[0].getValue("Hz") > chanFreqs[1].getValue("Hz") ) 611 increment *= -1.0 ; 612 // if ( even ) { 613 // IPosition refip0( 1, refchan-1 ) ; 614 // Double refval0 = chanFreqs(refip0).getValue("Hz") ; 615 // Double refval1 = chanFreqs(refip).getValue("Hz") ; 616 // refval = 0.5 * ( refval0 + refval1 ) ; 617 // } 618 // else { 619 // refval = chanFreqs(refip).getValue("Hz") ; 620 // } 621 if ( freqRef == MFrequency::LSRK ) { 622 if ( even ) { 623 IPosition refip0( 1, refchan-1 ) ; 624 Double refval0 = chanFreqs(refip0).getValue("Hz") ; 625 Double refval1 = chanFreqs(refip).getValue("Hz") ; 626 refval = 0.5 * ( refval0 + refval1 ) ; 627 } 628 else { 629 refval = chanFreqs(refip).getValue("Hz") ; 630 } 648 freqId = table_->frequencies().addEntry( refpix, refval, increment ) ; 649 //if ( ifmap.find( spwId ) == ifmap.end() ) { 650 ifmap.insert( pair<Int, uInt>(spwId,freqId) ) ; 651 //os_ << "added to ifmap: (" << spwId << "," << freqId << ")" << LogIO::POST ; 631 652 } 632 653 else { 633 MFrequency::Convert tolsr( freqRef, MFrequency::Ref( MFrequency::LSRK, mf ) ) ; 634 if ( even ) { 635 IPosition refip0( 1, refchan-1 ) ; 636 Double refval0 = chanFreqs(refip0).getValue("Hz") ; 637 Double refval1 = chanFreqs(refip).getValue("Hz") ; 638 refval = 0.5 * ( refval0 + refval1 ) ; 639 refval = tolsr( refval ).get("Hz").getValue() ; 640 } 641 else { 642 refval = tolsr( chanFreqs(refip) ).get("Hz").getValue() ; 643 } 644 } 645 uInt freqId = table_->frequencies().addEntry( refpix, refval, increment ) ; 646 if ( ifmap.find( spwId ) == ifmap.end() ) { 647 ifmap.insert( pair<Int, uInt>(spwId,freqId) ) ; 648 //os_ << "added to ifmap: (" << spwId << "," << freqId << ")" << LogIO::POST ; 654 freqId = iter->second ; 649 655 } 650 656 … … 859 865 diridx = getDirection( diridx, dir, scanrate, refString, pointtab, mTimeB[irow].get("s").getValue() ) ; 860 866 MDirection::getType( dirType, refString ) ; 861 mf.resetEpoch( mTimeB[irow] ) ; 862 mf.resetDirection( MDirection( MVDirection(dir), dirType ) ) ; 867 MeasFrame mf( mTimeB[irow], mp ) ; 868 //mf.resetEpoch( mTimeB[irow] ) ; 869 //mf.resetDirection( MDirection( MVDirection(dir), dirType ) ) ; 863 870 if ( refString == "J2000" ) { 864 871 *dirRF = dir ; … … 895 902 //Vector<Double> defaultDir = srcDir ; 896 903 MDirection::getType( dirType, "J2000" ) ; 904 MeasFrame mf( mTimeB[irow], mp ) ; 897 905 if ( ref != "J2000" ) { 898 906 ROScalarMeasColumn<MEpoch> tmCol( pointtab, "TIME" ) ;
Note:
See TracChangeset
for help on using the changeset viewer.