Changeset 2900
- Timestamp:
- 03/12/14 12:23:31 (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r2845 r2900 823 823 824 824 @asaplog_post_dec 825 def merge(*args ):825 def merge(*args, **kwargs): 826 826 """ 827 827 Merge a list of scanatables, or comma-sperated scantables into one … … 829 829 Parameters: 830 830 A list [scan1, scan2] or scan1, scan2. 831 freq_tol: frequency tolerance for merging IFs. numeric values 832 in units of Hz (1.0e6 -> 1MHz) and string ('1MHz') 833 is allowed. 831 834 Example: 832 835 myscans = [scan1, scan2] … … 834 837 # or equivalent 835 838 sameallscans = merge(scan1, scan2) 839 # with freqtol 840 allscans = merge(scan1, scan2, freq_tol=1.0e6) 841 # or equivalently 842 allscans = merge(scan1, scan2, freq_tol='1MHz') 836 843 """ 837 844 varlist = vars() … … 842 849 else: 843 850 lst = tuple(args) 851 if kwargs.has_key('freq_tol'): 852 freq_tol = str(kwargs['freq_tol']) 853 else: 854 freq_tol = '' 844 855 varlist["args"] = "%d scantables" % len(lst) 845 856 # need special formatting her for history... … … 850 861 msg = "Please give a list of scantables" 851 862 raise TypeError(msg) 852 s = scantable(stm._merge(lst ))863 s = scantable(stm._merge(lst, freq_tol)) 853 864 s._add_history("merge", varlist) 854 865 return s -
trunk/src/STFrequencies.cpp
r2816 r2900 16 16 #include <casa/Arrays/IPosition.h> 17 17 #include <casa/Logging/LogIO.h> 18 #include <casa/BasicMath/Math.h> 18 19 19 20 #include <tables/Tables/TableDesc.h> … … 450 451 } 451 452 453 bool STFrequencies::match( Double refpix, Double refval, 454 Double inc, Double freqTolInHz, 455 uInt &id) 456 { 457 ROScalarColumn<uInt> idCol(table_, "ID"); 458 ROScalarColumn<Double> refPixCol(table_, "REFPIX"); 459 ROScalarColumn<Double> refValCol(table_, "REFVAL"); 460 ROScalarColumn<Double> incCol(table_, "INCREMENT"); 461 for (uInt irow = 0; irow < table_.nrow(); ++irow) { 462 Double refInc = incCol(irow); 463 Double refFreq = refValCol(irow) - refPixCol(irow) * refInc; 464 Double freq0 = refval - refpix * inc; 465 if (nearAbs(inc, refInc, freqTolInHz) && 466 nearAbs(refFreq, freq0, freqTolInHz)) { 467 id = irow; 468 return true; 469 } 470 } 471 return false; 472 } 473 452 474 } // namespace -
trunk/src/STFrequencies.h
r1819 r2900 172 172 const casa::String& name() const { return name_; } 173 173 174 /** 175 * Examine given set of refpix, refval, and increment matches 176 * any of the rows within a tolerance of freqTolInHz. If match, 177 * return true and id is filled properly. Otherwise, return false 178 * and id may have invalid value. 179 * 180 * @param[in] refpix 181 * @param[in] refval 182 * @param[in] inc 183 * @param[in] freqTolInHz 184 * @param[out] id 185 * @return boolean indicating match with any rows or not 186 */ 187 bool match( casa::Double refpix, casa::Double refval, casa::Double inc, 188 casa::Double freqTolInHz, casa::uInt &id); 189 174 190 private: 175 191 -
trunk/src/STMath.cpp
r2899 r2900 2541 2541 2542 2542 CountedPtr< 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; 2543 STMath::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 2550 2547 if (freqTol.size() > 0) { 2551 2548 Quantum<Double> freqTolInQuantity; … … 2558 2555 freqTolInHz = freqTolInQuantity.getValue("Hz"); 2559 2556 } 2560 **/2561 2557 2562 2558 if ( in.size() < 2 ) { … … 2579 2575 uInt newscanno = max(scannos)+1; 2580 2576 ++it; 2577 2578 // new IFNO 2579 uInt ifnoCounter = max(ifnocol.getColumn()) + 1; 2580 2581 2581 while ( it != in.end() ){ 2582 /**2583 2582 // Check FREQUENCIES/BASEFRAME 2584 2583 if ( out->frequencies().getFrame(true) != (*it)->frequencies().getFrame(true) ) { 2585 2584 throw(AipsError("BASEFRAME is not identical")); 2586 2585 } 2587 **/2588 2586 2589 2587 if ( ! (*it)->conformant(*out) ) { … … 2621 2619 (*it)->frequencies().getEntry(rp, rv, inc, rec.asuInt("FREQ_ID")); 2622 2620 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 } 2627 2666 thecolvals = id; 2628 2667 freqidcol.putColumnRange(slice, thecolvals); 2668 2669 thecolvals = newifno; 2670 ifnocol.putColumnRange(slice, thecolvals); 2629 2671 2630 2672 // Set the proper MOLECULE_ID -
trunk/src/STMath.h
r2658 r2900 310 310 311 311 casa::CountedPtr<Scantable> 312 merge(const std::vector<casa::CountedPtr<Scantable> >& in); 312 merge(const std::vector<casa::CountedPtr<Scantable> >& in, 313 const std::string &freqTol = ""); 313 314 314 315 casa::CountedPtr<Scantable> -
trunk/src/STMathWrapper.h
r2428 r2900 175 175 176 176 ScantableWrapper 177 merge(const std::vector<ScantableWrapper >& in )178 177 merge(const std::vector<ScantableWrapper >& in, 178 const std::string &freqTol) 179 179 { 180 180 std::vector<casa::CountedPtr<Scantable> > sts; 181 181 for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP()); 182 return ScantableWrapper(STMath::merge(sts )); }182 return ScantableWrapper(STMath::merge(sts, freqTol)); } 183 183 184 184 ScantableWrapper rotateXYPhase( const ScantableWrapper& in, float angle)
Note:
See TracChangeset
for help on using the changeset viewer.