Changeset 2900 for trunk/src/STMath.cpp


Ignore:
Timestamp:
03/12/14 12:23:31 (10 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-5875

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: test_sdcoadd

Put in Release Notes: No

Module(s): sd

Description: Describe your changes here...

Added freq_tol parameter to asapmath.merge.
The freq_tol allows to specify frequency tolerance as
numeric value (1.0e6) or string ('1MHz'). The value will
be used to merge FREQUENCIES rows, FREQ_ID, and IFNO.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r2899 r2900  
    25412541
    25422542CountedPtr< Scantable >
    2543 STMath::merge( const std::vector< CountedPtr < Scantable > >& in )
    2544 //STMath::merge( const std::vector< CountedPtr < Scantable > >& in,
    2545 //             const std::string &freqTol )
    2546 {
    2547   /**
    2548   LogIO os;
    2549   Double freqTolInHz = 0.0;
     2543STMath::merge( const std::vector< CountedPtr < Scantable > >& in,
     2544               const std::string &freqTol )
     2545{
     2546  Double freqTolInHz = 1.0; // default is 1.0Hz according to concat task
    25502547  if (freqTol.size() > 0) {
    25512548    Quantum<Double> freqTolInQuantity;
     
    25582555    freqTolInHz = freqTolInQuantity.getValue("Hz");
    25592556  }
    2560   **/
    25612557 
    25622558  if ( in.size() < 2 ) {
     
    25792575  uInt newscanno = max(scannos)+1;
    25802576  ++it;
     2577
     2578  // new IFNO
     2579  uInt ifnoCounter = max(ifnocol.getColumn()) + 1;
     2580 
    25812581  while ( it != in.end() ){
    2582     /**
    25832582    // Check FREQUENCIES/BASEFRAME
    25842583    if ( out->frequencies().getFrame(true) != (*it)->frequencies().getFrame(true) ) {
    25852584      throw(AipsError("BASEFRAME is not identical"));
    25862585    }
    2587     **/
    25882586   
    25892587    if ( ! (*it)->conformant(*out) ) {
     
    26212619        (*it)->frequencies().getEntry(rp, rv, inc, rec.asuInt("FREQ_ID"));
    26222620        uInt id;
    2623         id = out->frequencies().addEntry(rp, rv, inc);
    2624         //if ( !out->frequencies().match(rp, rv, inc, freqTolInHz, id) ) {
    2625         //  id = out->frequencies().addEntry(rp, rv, inc);
    2626         //}
     2621       
     2622        // default value is new unique IFNO
     2623        uInt newifno = ifnoCounter;
     2624        uInt nchan = rec.asArrayFloat("SPECTRA").shape()[0];
     2625        //id = out->frequencies().addEntry(rp, rv, inc);
     2626        if ( !out->frequencies().match(rp, rv, inc, freqTolInHz, id) ) {
     2627          // add new entry to FREQUENCIES table
     2628          id = out->frequencies().addEntry(rp, rv, inc);
     2629
     2630          // increment counter for IFNO
     2631          ifnoCounter++;
     2632        }
     2633        else {
     2634          // should renumber IFNO to be same as existing rows that have same FREQ_ID
     2635          LogIO os(LogOrigin("STMath", "merge", WHERE));
     2636          Table outFreqIdSelected = tout(tout.col("FREQ_ID") == id);
     2637          TableIterator _iter(outFreqIdSelected, "IFNO");
     2638          map<uInt, uInt> nchanMap;
     2639          while (!_iter.pastEnd()) {
     2640            const Table _table = _iter.table();
     2641            ROTableRow _row(_table);
     2642            const TableRecord &_rec = _row.get(0);
     2643            uInt nchan = _rec.asArrayFloat("SPECTRA").shape()[0];
     2644            if (nchanMap.find(nchan) != nchanMap.end()) {
     2645              throw(AipsError("There are non-unique IFNOs assigned to spectra that have same FREQ_ID and same nchan. Something wrong."));
     2646            }
     2647            nchanMap[nchan] = _rec.asuInt("IFNO");
     2648            _iter.next();
     2649          }
     2650
     2651          os << LogIO::DEBUGGING << "nchanMap for " << id << ":" << LogIO::POST;
     2652          for (map<uInt, uInt>::iterator i = nchanMap.begin(); i != nchanMap.end(); ++i) {
     2653            os << LogIO::DEBUGGING << "nchanMap[" << i->first << "] = " << i->second << LogIO::POST;
     2654          }
     2655
     2656          if (nchanMap.find(nchan) == nchanMap.end()) {
     2657            // increment counter for IFNO
     2658            ifnoCounter++;
     2659          }
     2660          else {
     2661            // renumber IFNO to be same as existing value that corresponds to nchan
     2662            newifno = nchanMap[nchan];
     2663          }
     2664          os << LogIO::DEBUGGING << "newifno = " << newifno << LogIO::POST;
     2665        }
    26272666        thecolvals = id;
    26282667        freqidcol.putColumnRange(slice, thecolvals);
     2668
     2669        thecolvals = newifno;
     2670        ifnocol.putColumnRange(slice, thecolvals);
    26292671       
    26302672        // Set the proper MOLECULE_ID
Note: See TracChangeset for help on using the changeset viewer.