Changeset 2198 for trunk/external-alma


Ignore:
Timestamp:
06/23/11 17:29:35 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2819

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Bug fix on REFVAL in FREQUENCIES table.

  • REFVAL is calculated only once for each array
  • REFVAL is defined as REST value


Location:
trunk/external-alma/atnf/PKSIO
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/NRODataset.cc

    r2156 r2198  
    8383  }
    8484  same_ = -1 ;
     85
     86  // Record for frequency setting
     87  frec_ = Record() ;
    8588}
    8689
     
    664667  NRODataRecord *record = getRecord( i ) ;
    665668  string arryt = string( record->ARRYT ) ;
    666   //string sbeamno = arryt.substr( 1, arryt.size()-1 ) ;
    667   //uInt ib = atoi( sbeamno.c_str() ) - 1 ;
    668669  uInt ib = getArrayId( arryt ) ;
    669670
    670   int ia = -1 ;
     671  if ( frec_.isDefined( arryt ) ) {
     672    // frequency for the array is already calculated
     673    Vector<Double> f =  frec_.asArrayDouble( arryt ) ;
     674    Double *f_p = f.data() ;
     675    for ( int i = 0 ; i < 3 ; i++ )
     676      v[i] = (double)(f_p[i]) ;
     677    return v ;
     678  }
     679
     680  //int ia = -1 ;
    671681  bool isAOS = false ;
    672682  //cout << "NRODataset::getFrequencies()  record->ARRYT=" << record->ARRYT << endl ;
    673683  //cout << "NRODataset::getFrequencies()  ib = " << ib << endl ;
    674684
    675   if ( strncmp( record->ARRYT, "X", 1 ) == 0 ) {
    676     // FX
    677     if ( strncmp( (record->ARRYT)+1, "1", 1 ) == 0
    678          || strncmp( (record->ARRYT)+1, "3", 1 ) ) {
    679       // FX1, 3
    680       ia = 2 ;
    681     }
    682     else {
    683       // FX2, 4
    684       ia = 1 ;
    685     }
    686   }
    687   else if ( strncmp( record->ARRYT, "A", 1 ) == 0 )
    688     ia = 2 ;  // AC
    689   else if ( strncmp( record->ARRYT, "W", 1 ) == 0 ) {
    690     // AOS-W   
    691     ia = 2 ; 
     685//   if ( strncmp( record->ARRYT, "X", 1 ) == 0 ) {
     686//     // FX
     687//     if ( strncmp( (record->ARRYT)+1, "1", 1 ) == 0
     688//          || strncmp( (record->ARRYT)+1, "3", 1 ) ) {
     689//       // FX1, 3
     690//       ia = 2 ;
     691//     }
     692//     else {
     693//       // FX2, 4
     694//       ia = 1 ;
     695//     }
     696//   }
     697//   else if ( strncmp( record->ARRYT, "A", 1 ) == 0 )
     698//     ia = 2 ;  // AC
     699//   else if ( strncmp( record->ARRYT, "W", 1 ) == 0 ) {
     700//     // AOS-W   
     701//     ia = 2 ; 
     702//     isAOS = true ;
     703//   }
     704//   else if ( strncmp( record->ARRYT, "U", 1 ) == 0 ) {
     705//     // AOS-U
     706//     ia = 2 ; 
     707//     isAOS = true ;
     708//   }
     709//   else if ( strncmp( record->ARRYT, "H", 1 ) == 0 ) {
     710//     // AOS-H
     711//     isAOS = true ;
     712//     //cout << record->ARRYT << " " <<  strlen(record->ARRYT) << endl ;
     713//     //cout << (record->ARRYT)+1 << endl ;
     714//     if ( strncmp( (record->ARRYT)+2, " ", 1 ) == 0 ) {
     715//       // H1-9
     716//       if ( strncmp( (record->ARRYT)+1, "9", 1 ) == 0 ) {
     717//         // H9
     718//         ia = 2 ;
     719//       }
     720//       else {
     721//         // H1-8
     722//         ia = 1 ;
     723//       }
     724//     }
     725//     else {
     726//       // H10-16
     727//       ia = 2 ;
     728//     }
     729//   }
     730  if ( arryt[0] == 'A' || arryt[0] == 'W' || arryt[0] == 'U' || arryt[0] == 'H' )
    692731    isAOS = true ;
    693   }
    694   else if ( strncmp( record->ARRYT, "U", 1 ) == 0 ) {
    695     // AOS-U
    696     ia = 2 ; 
    697     isAOS = true ;
    698   }
    699   else if ( strncmp( record->ARRYT, "H", 1 ) == 0 ) {
    700     // AOS-H
    701     isAOS = true ;
    702     //cout << record->ARRYT << " " <<  strlen(record->ARRYT) << endl ;
    703     //cout << (record->ARRYT)+1 << endl ;
    704     if ( strncmp( (record->ARRYT)+2, " ", 1 ) == 0 ) {
    705       // H1-9
    706       if ( strncmp( (record->ARRYT)+1, "9", 1 ) == 0 ) {
    707         // H9
    708         ia = 2 ;
    709       }
    710       else {
    711         // H1-8
    712         ia = 1 ;
    713       }
    714     }
    715     else {
    716       // H10-16
    717       ia = 2 ;
    718     }
    719   }
    720 
    721   int iu ;
     732
     733  Bool isUSB ;
    722734  if ( record->FQIF1 > 0 )
    723     iu = 1 ;  // USB
     735    isUSB = True ;  // USB
    724736  else
    725     iu = 2 ;  // LSB
     737    isUSB = False ;  // LSB
    726738
    727739  int ivdef = -1 ;
    728   //if ( strncmp( (dataset_->getVDEF()).c_str(), "RAD", 3 ) == 0 )
    729740  if ( (getVDEF()).compare( 0, 3, "RAD" ) == 0 )
    730741    ivdef = 0 ;
    731   //else if ( strncmp( dataset_->getVDEF(), "OPT", 3 ) == 0 )
    732742  else if ( (getVDEF()).compare( 0, 3, "OPT" ) == 0 )
    733743    ivdef = 1 ;
     
    741751
    742752  int ncal = getNFCAL()[ib] ;
    743   vector<double> freqs( ncal ) ;
    744753  double cw = 0.0 ;
    745754  vector<double> fqcal = getFQCAL()[ib] ;
    746755  vector<double> chcal = getCHCAL()[ib] ;
    747 
     756  double f0cal = getF0CAL()[ib] ;
     757  Vector<Double> freqs( ncal, fq0-f0cal ) ;
     758
     759  double factor = vel / cvel ;
     760  if ( ivdef == 0 )
     761    factor = 1.0 / ( 1.0 - factor ) ;
    748762  for ( int ii = 0 ; ii < ncal ; ii++ ) {
    749     freqs[ii] = fqcal[ii] ;
    750     freqs[ii] -= getF0CAL()[ib] ;
    751     if ( ia == 1 ) {
    752       if ( iu == 1 ) {
    753         freqs[ii] = fq0 + freqs[ii] ;
    754       }
    755       else if ( iu == 2 ) {
    756         freqs[ii] = fq0 - freqs[ii] ;
    757       }
    758     }
    759     else if ( ia == 2 ) {
    760       if ( iu == 1 ) {
    761         freqs[ii] = fq0 - freqs[ii] ;
    762       }
    763       else if ( iu == 2 ) {
    764         freqs[ii] = fq0 + freqs[ii] ;
    765       }
    766     }     
    767 //       if ( ivdef == 0 ) {
    768 //         double factor = 1.0 / ( 1.0 - vel / cvel ) ;
    769 //         freqs[ii] = freqs[ii] * factor - record->FQTRK * ( factor - 1.0 ) ;
    770 //       }
    771 //       else if ( ivdef == 1 ) {
    772 //         double factor = vel / cvel ;
    773 //         freqs[ii] = freqs[ii] * ( 1.0 + factor ) - record->FQTRK * factor ;
    774 //       }
     763    freqs[ii] += fqcal[ii] ;
     764    if ( ivdef == 0 ) {
     765      freqs[ii] = freqs[ii] * factor + record->FQTRK * ( 1.0 - factor ) ;
     766    }
     767    else if ( ivdef == 1 ) {
     768      freqs[ii] = freqs[ii] * ( 1.0 + factor ) - record->FQTRK * factor ;
     769    }
     770
     771    //ofstream ofs("freqs.txt",ios::out|ios::app) ;
     772    //ofs << setprecision(16) ;
     773    //ofs << i << " " << record->ARRYT << " " << chcal[ii] << " " << freqs[ii] << " " << record->ISCAN << " " << fqcal[ii] << " " << f0cal << " " << record->FQTRK << " " << vel << endl ;
     774    //ofs.close() ;
     775
    775776  }
    776777
     
    798799  else {
    799800    cw = getBERES()[ib] ;
     801
     802    if ( !isUSB )
     803      cw *= -1.0 ;
    800804   
    801     if ( iu == 2 )
    802       cw *= -1.0 ;
    803 
    804805    if ( cw == 0.0 ) {
    805806      cw = ( freqs[1] - freqs[0] )
    806807        / ( chcal[1] - chcal[0] ) ;
    807 //           if ( cw < 0.0 )
    808 //             cw = - cw ;
    809     }
     808    }
     809
    810810    v[0] = chcal[0] - 1 ; // 0-base
    811811    v[1] = freqs[0] ;
     
    813813  }
    814814
    815   // conversion from TOPO to LSRK
    816   v[1] = toLSR( v[1], getStartIntTime( i ), record_->SCX, record_->SCY ) ;
    817 
    818   if ( refFreq_[ib] != 0.0 ) {
    819     v[1] = refFreq_[ib] ;
    820   }
    821   else {
     815  if ( refFreq_[ib] == 0.0 )
    822816    refFreq_[ib] = v[1] ;
    823   }
     817
     818  // register frequency setting to Record
     819  Vector<Double> f( v ) ;
     820  frec_.define( arryt, f ) ;
    824821
    825822  return v ;
  • trunk/external-alma/atnf/PKSIO/NRODataset.h

    r2156 r2198  
    4141//#include <casa/aips.h>
    4242#include <casa/Logging/LogIO.h>
     43#include <casa/Containers/Record.h>
    4344#include <atnf/PKSIO/NRODataRecord.h>
    4445#include <casa/namespace.h>
     
    513514  // reference frequency for each array
    514515  vector<double> refFreq_ ;
     516
     517  // record to store REFPIX, REFVAL, INCREMENT pair for each array
     518  Record frec_ ;
    515519} ;
    516520
  • trunk/external-alma/atnf/PKSIO/NROReader.cc

    r2158 r2198  
    456456  }
    457457  //freqref = vref ;
    458   freqref = "LSRK" ;
    459   //freqref = "REST" ;
     458  //freqref = "LSRK" ;
     459  freqref = "REST" ;
    460460  //cout << "freqref = " << freqref << endl ;
    461461  NRODataRecord *record = dataset_->getRecord( 0 ) ;
Note: See TracChangeset for help on using the changeset viewer.