Changeset 2899


Ignore:
Timestamp:
03/11/14 14:17:00 (11 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): Module Names change impacts.

Description: Describe your changes here...

sdcoadd (sd.merge):
Fixed a bug that input scantable may be unexpectedly modified.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r2879 r2899  
    2525#include <casa/Exceptions/Error.h>
    2626#include <casa/Logging/LogIO.h>
     27#include <casa/Quanta/Quantum.h>
    2728
    2829#include <coordinates/Coordinates/CoordinateSystem.h>
     
    25402541
    25412542CountedPtr< Scantable >
    2542   STMath::merge( const std::vector< CountedPtr < Scantable > >& in )
    2543 {
     2543STMath::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;
     2550  if (freqTol.size() > 0) {
     2551    Quantum<Double> freqTolInQuantity;
     2552    if (!Quantum<Double>::read(freqTolInQuantity, freqTol)) {
     2553      throw(AipsError("Failed to convert freqTol string to quantity"));
     2554    }
     2555    if (!freqTolInQuantity.isConform("Hz")) {
     2556      throw(AipsError("Invalid freqTol string"));
     2557    }
     2558    freqTolInHz = freqTolInQuantity.getValue("Hz");
     2559  }
     2560  **/
     2561 
    25442562  if ( in.size() < 2 ) {
    25452563    throw(AipsError("Need at least two scantables to perform a merge."));
     
    25532571  ScalarColumn<uInt> freqidcol(tout,"FREQ_ID"), molidcol(tout, "MOLECULE_ID");
    25542572  ScalarColumn<uInt> scannocol(tout,"SCANNO"), focusidcol(tout,"FOCUS_ID");
     2573  ScalarColumn<uInt> ifnocol(tout, "IFNO");
    25552574  // Renumber SCANNO to be 0-based
    25562575  Vector<uInt> scannos = scannocol.getColumn();
     
    25612580  ++it;
    25622581  while ( it != in.end() ){
     2582    /**
     2583    // Check FREQUENCIES/BASEFRAME
     2584    if ( out->frequencies().getFrame(true) != (*it)->frequencies().getFrame(true) ) {
     2585      throw(AipsError("BASEFRAME is not identical"));
     2586    }
     2587    **/
     2588   
    25632589    if ( ! (*it)->conformant(*out) ) {
    25642590      // non conformant.
     
    25762602    TableIterator scanit(tab, "SCANNO");
    25772603    while (!scanit.pastEnd()) {
    2578       ScalarColumn<uInt> thescannocol(scanit.table(),"SCANNO");
    2579       Vector<uInt> thescannos(thescannocol.nrow(),newscanno);
    2580       thescannocol.putColumn(thescannos);
    25812604      TableIterator subit(scanit.table(), cols);
    25822605      while ( !subit.pastEnd() ) {
     
    25852608        ROTableRow row(thetab);
    25862609        Vector<uInt> thecolvals(thetab.nrow());
    2587         ScalarColumn<uInt> thefreqidcol(thetab,"FREQ_ID");
    2588         ScalarColumn<uInt> themolidcol(thetab, "MOLECULE_ID");
    2589         ScalarColumn<uInt> thefocusidcol(thetab,"FOCUS_ID");
    25902610        // The selected subset of table should have
    25912611        // the equal FREQ_ID, MOLECULE_ID, and FOCUS_ID values.
    25922612        const TableRecord& rec = row.get(0);
     2613        tout.addRow(thetab.nrow());
     2614        TableCopy::copyRows(tout, thetab, nrow, 0, thetab.nrow());
     2615
     2616        Slicer slice(IPosition(1, nrow), IPosition(1, thetab.nrow()),
     2617                     Slicer::endIsLength);
     2618
    25932619        // Set the proper FREQ_ID
    25942620        Double rv,rp,inc;
     
    25962622        uInt id;
    25972623        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        //}
    25982627        thecolvals = id;
    2599         thefreqidcol.putColumn(thecolvals);
     2628        freqidcol.putColumnRange(slice, thecolvals);
     2629       
    26002630        // Set the proper MOLECULE_ID
    26012631        Vector<String> name,fname;Vector<Double> rf;
     
    26032633        id = out->molecules().addEntry(rf, name, fname);
    26042634        thecolvals = id;
    2605         themolidcol.putColumn(thecolvals);
     2635        molidcol.putColumnRange(slice, thecolvals);
     2636       
    26062637        // Set the proper FOCUS_ID
    26072638        Float fpa,frot,fax,ftan,fhand,fmount,fuser, fxy, fxyp;
     
    26112642                                   fxy, fxyp);
    26122643        thecolvals = id;
    2613         thefocusidcol.putColumn(thecolvals);
    2614 
    2615         tout.addRow(thetab.nrow());
    2616         TableCopy::copyRows(tout, thetab, nrow, 0, thetab.nrow());
     2644        focusidcol.putColumnRange(slice, thecolvals);
     2645
     2646        // Set the proper SCANNO
     2647        thecolvals = newscanno;
     2648        scannocol.putColumnRange(slice, thecolvals);
    26172649
    26182650        ++subit;
Note: See TracChangeset for help on using the changeset viewer.