Changeset 2591
- Timestamp:
- 07/09/12 16:11:50 (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r2574 r2591 19 19 from asap.utils import _n_bools, mask_not, mask_and, mask_or, page 20 20 from asap.asapfitter import fitter 21 22 ###############################################################23 ### WK temporarily added these lines for testing 2011/11/28 ###24 ###############################################################25 #from asap._asap import TestClass26 27 #class testclass(TestClass):28 # def __init__(self, nelem):29 # TestClass.__init__(self, nelem)30 31 ###############################################################32 33 21 34 22 def preserve_selection(func): -
trunk/src/Scantable.cpp
r2575 r2591 11 11 // 12 12 #include <map> 13 #include <sys/time.h> 13 14 14 15 #include <atnf/PKSIO/SrcType.h> … … 2444 2445 void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 2445 2446 { 2447 /*************/ 2448 //clock_t totTimeStart, totTimeEnd, blTimeStart, blTimeEnd, ioTimeStart, ioTimeEnd; 2449 double totTimeStart, totTimeEnd, blTimeStart, blTimeEnd, ioTimeStart, ioTimeEnd, msTimeStart, msTimeEnd, seTimeStart, seTimeEnd, otTimeStart, otTimeEnd, prTimeStart, prTimeEnd; 2450 double elapseMs = 0.0; 2451 double elapseSe = 0.0; 2452 double elapseOt = 0.0; 2453 double elapsePr = 0.0; 2454 double elapseBl = 0.0; 2455 double elapseIo = 0.0; 2456 //totTimeStart = clock(); 2457 totTimeStart = mathutil::gettimeofday_sec(); 2458 /*************/ 2459 2446 2460 try { 2447 2461 ofstream ofs; … … 2474 2488 //-------------------------------- 2475 2489 for (int whichrow = 0; whichrow < nRow; ++whichrow) { 2490 /******************/ 2491 //ioTimeStart = clock(); 2492 ioTimeStart = mathutil::gettimeofday_sec(); 2493 /**/ 2494 std::vector<float> sp = getSpectrum(whichrow); 2495 /**/ 2496 //ioTimeEnd = clock(); 2497 ioTimeEnd = mathutil::gettimeofday_sec(); 2498 elapseIo += (double)(ioTimeEnd - ioTimeStart); 2499 2500 //blTimeStart = clock(); 2501 msTimeStart = mathutil::gettimeofday_sec(); 2502 /******************/ 2503 2476 2504 chanMask = getCompositeChanMask(whichrow, mask); 2505 2506 /**/ 2507 msTimeEnd = mathutil::gettimeofday_sec(); 2508 elapseMs += (double)(msTimeEnd - msTimeStart); 2509 blTimeStart = mathutil::gettimeofday_sec(); 2510 /**/ 2511 2477 2512 //fitBaseline(chanMask, whichrow, fitter); 2478 2513 //setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); … … 2480 2515 std::vector<float> params(nPiece*4); 2481 2516 int nClipped = 0; 2482 std::vector<float> res = doCubicSplineFitting(getSpectrum(whichrow), chanMask, nPiece, pieceEdges, params, nClipped, thresClip, nIterClip, getResidual); 2517 std::vector<float> res = doCubicSplineFitting(sp, chanMask, nPiece, pieceEdges, params, nClipped, thresClip, nIterClip, getResidual); 2518 2519 /**/ 2520 blTimeEnd = mathutil::gettimeofday_sec(); 2521 elapseBl += (double)(blTimeEnd - blTimeStart); 2522 seTimeStart = mathutil::gettimeofday_sec(); 2523 /**/ 2524 2525 2483 2526 setSpectrum(res, whichrow); 2484 2527 // 2485 2528 2529 /**/ 2530 seTimeEnd = mathutil::gettimeofday_sec(); 2531 elapseSe += (double)(seTimeEnd - seTimeStart); 2532 otTimeStart = mathutil::gettimeofday_sec(); 2533 /**/ 2534 2486 2535 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "cubicSplineBaseline()", pieceEdges, params, nClipped); 2536 2537 /**/ 2538 otTimeEnd = mathutil::gettimeofday_sec(); 2539 elapseOt += (double)(otTimeEnd - otTimeStart); 2540 prTimeStart = mathutil::gettimeofday_sec(); 2541 /**/ 2542 2487 2543 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 2544 2545 /******************/ 2546 //blTimeEnd = clock(); 2547 prTimeEnd = mathutil::gettimeofday_sec(); 2548 elapsePr += (double)(prTimeEnd - prTimeStart); 2549 /******************/ 2488 2550 } 2489 2551 //-------------------------------- … … 2494 2556 throw; 2495 2557 } 2558 /***************/ 2559 //totTimeEnd = clock(); 2560 totTimeEnd = mathutil::gettimeofday_sec(); 2561 //std::cout << "io : " << elapseIo/CLOCKS_PER_SEC << " (sec.)" << endl; 2562 //std::cout << "bl : " << elapseBl/CLOCKS_PER_SEC << " (sec.)" << endl; 2563 //std::cout << "total : " << (double)(totTimeEnd - totTimeStart)/CLOCKS_PER_SEC << " (sec.)" << endl; 2564 std::cout << "io : " << elapseIo << " (sec.)" << endl; 2565 std::cout << "ms : " << elapseMs << " (sec.)" << endl; 2566 std::cout << "bl : " << elapseBl << " (sec.)" << endl; 2567 std::cout << "se : " << elapseSe << " (sec.)" << endl; 2568 std::cout << "ot : " << elapseOt << " (sec.)" << endl; 2569 std::cout << "pr : " << elapsePr << " (sec.)" << endl; 2570 std::cout << "total : " << (double)(totTimeEnd - totTimeStart) << " (sec.)" << endl; 2571 /***************/ 2496 2572 } 2497 2573 2498 2574 void Scantable::autoCubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 2499 2575 { 2576 /************* 2577 clock_t totTimeStart, totTimeEnd, blTimeStart, blTimeEnd, ioTimeStart, ioTimeEnd; 2578 double elapseBl = 0.0; 2579 double elapseIo = 0.0; 2580 totTimeStart = clock(); 2581 *************/ 2582 2500 2583 try { 2501 2584 ofstream ofs; … … 2530 2613 2531 2614 for (int whichrow = 0; whichrow < nRow; ++whichrow) { 2615 /****************** 2616 ioTimeStart = clock(); 2617 */ 2618 std::vector<float> sp = getSpectrum(whichrow); 2619 /* 2620 ioTimeEnd = clock(); 2621 elapseIo += (double)(ioTimeEnd - ioTimeStart); 2622 2623 blTimeStart = clock(); 2624 ******************/ 2532 2625 2533 2626 //------------------------------------------------------- … … 2560 2653 std::vector<float> params(nPiece*4); 2561 2654 int nClipped = 0; 2562 std::vector<float> res = doCubicSplineFitting( getSpectrum(whichrow), chanMask, nPiece, pieceEdges, params, nClipped, thresClip, nIterClip, getResidual);2655 std::vector<float> res = doCubicSplineFitting(sp, chanMask, nPiece, pieceEdges, params, nClipped, thresClip, nIterClip, getResidual); 2563 2656 setSpectrum(res, whichrow); 2564 2657 // … … 2566 2659 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoCubicSplineBaseline()", pieceEdges, params, nClipped); 2567 2660 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 2661 2662 /****************** 2663 blTimeEnd = clock(); 2664 elapseBl += (double)(blTimeEnd - blTimeStart); 2665 ******************/ 2666 2568 2667 } 2569 2668 … … 2573 2672 throw; 2574 2673 } 2674 2675 /*************** 2676 totTimeEnd = clock(); 2677 std::cout << "io : " << elapseIo/CLOCKS_PER_SEC << " (sec.)" << endl; 2678 std::cout << "bl : " << elapseBl/CLOCKS_PER_SEC << " (sec.)" << endl; 2679 std::cout << "total : " << (double)(totTimeEnd - totTimeStart)/CLOCKS_PER_SEC << " (sec.)" << endl; 2680 ***************/ 2575 2681 } 2576 2682 … … 3381 3487 std::vector<bool> Scantable::getCompositeChanMask(int whichrow, const std::vector<bool>& inMask) 3382 3488 { 3489 /**** 3490 double ms1TimeStart, ms1TimeEnd, ms2TimeStart, ms2TimeEnd; 3491 double elapse1 = 0.0; 3492 double elapse2 = 0.0; 3493 3494 ms1TimeStart = mathutil::gettimeofday_sec(); 3495 ****/ 3496 3383 3497 std::vector<bool> mask = getMask(whichrow); 3498 3499 /**** 3500 ms1TimeEnd = mathutil::gettimeofday_sec(); 3501 elapse1 = ms1TimeEnd - ms1TimeStart; 3502 std::cout << "ms1 : " << elapse1 << " (sec.)" << endl; 3503 ms2TimeStart = mathutil::gettimeofday_sec(); 3504 ****/ 3505 3384 3506 uInt maskSize = mask.size(); 3385 3507 if (inMask.size() != 0) { … … 3391 3513 } 3392 3514 } 3515 3516 /**** 3517 ms2TimeEnd = mathutil::gettimeofday_sec(); 3518 elapse2 = ms2TimeEnd - ms2TimeStart; 3519 std::cout << "ms2 : " << elapse2 << " (sec.)" << endl; 3520 ****/ 3393 3521 3394 3522 return mask; … … 3444 3572 { 3445 3573 if (outLogger || outTextFile) { 3574 /**** 3575 double ms1TimeStart, ms1TimeEnd, ms2TimeStart, ms2TimeEnd; 3576 double elapse1 = 0.0; 3577 double elapse2 = 0.0; 3578 3579 ms1TimeStart = mathutil::gettimeofday_sec(); 3580 ****/ 3581 3446 3582 float rms = getRms(chanMask, whichrow); 3583 3584 /**** 3585 ms1TimeEnd = mathutil::gettimeofday_sec(); 3586 elapse1 = ms1TimeEnd - ms1TimeStart; 3587 std::cout << "ot1 : " << elapse1 << " (sec.)" << endl; 3588 ms2TimeStart = mathutil::gettimeofday_sec(); 3589 ****/ 3590 3447 3591 String masklist = getMaskRangeList(chanMask, whichrow, coordInfo, hasSameNchan); 3448 3592 std::vector<bool> fixed; … … 3454 3598 } 3455 3599 if (outTextFile) { 3456 ofs << formatPiecewiseBaselineParams(edge, params, fixed, rms, nClipped, masklist, whichrow, true) << flush; 3457 } 3600 ofs << formatPiecewiseBaselineParams(edge, params, fixed, rms, nClipped, masklist, whichrow, true);// << flush; 3601 } 3602 3603 /**** 3604 ms2TimeEnd = mathutil::gettimeofday_sec(); 3605 elapse2 = ms2TimeEnd - ms2TimeStart; 3606 std::cout << "ot2 : " << elapse2 << " (sec.)" << endl; 3607 ****/ 3608 3458 3609 } 3459 3610 } … … 3553 3704 float Scantable::getRms(const std::vector<bool>& mask, int whichrow) 3554 3705 { 3706 /**** 3707 double ms1TimeStart, ms1TimeEnd, ms2TimeStart, ms2TimeEnd; 3708 double elapse1 = 0.0; 3709 double elapse2 = 0.0; 3710 3711 ms1TimeStart = mathutil::gettimeofday_sec(); 3712 ****/ 3713 3555 3714 Vector<Float> spec; 3715 3556 3716 specCol_.get(whichrow, spec); 3717 3718 /**** 3719 ms1TimeEnd = mathutil::gettimeofday_sec(); 3720 elapse1 = ms1TimeEnd - ms1TimeStart; 3721 std::cout << "rm1 : " << elapse1 << " (sec.)" << endl; 3722 ms2TimeStart = mathutil::gettimeofday_sec(); 3723 ****/ 3557 3724 3558 3725 float mean = 0.0; … … 3569 3736 mean /= (float)n; 3570 3737 smean /= (float)n; 3738 3739 /**** 3740 ms2TimeEnd = mathutil::gettimeofday_sec(); 3741 elapse2 = ms2TimeEnd - ms2TimeStart; 3742 std::cout << "rm2 : " << elapse2 << " (sec.)" << endl; 3743 ****/ 3571 3744 3572 3745 return sqrt(smean - mean*mean); … … 3795 3968 } 3796 3969 3970 vector<uint> Scantable::getMoleculeIdColumnData() const 3971 { 3972 Vector<uInt> molIds(mmolidCol_.getColumn()); 3973 vector<uint> res; 3974 molIds.tovector(res); 3975 return res; 3976 } 3977 3978 void Scantable::setMoleculeIdColumnData(const std::vector<uint>& molids) 3979 { 3980 Vector<uInt> molIds(molids); 3981 Vector<uInt> arr(mmolidCol_.getColumn()); 3982 if ( molIds.nelements() != arr.nelements() ) 3983 throw AipsError("The input data size must be the number of rows."); 3984 mmolidCol_.putColumn(molIds); 3985 } 3986 3797 3987 3798 3988 } -
trunk/src/Scantable.h
r2435 r2591 590 590 int whichrow, 591 591 bool verbose=false) const; 592 std::vector<uint> getMoleculeIdColumnData() const; 593 void setMoleculeIdColumnData(const std::vector<uint>& molids); 592 594 593 595 … … 766 768 void applyChanFlag( casa::uInt whichrow, const std::vector<bool>& msk, casa::uChar flagval); 767 769 768 769 770 }; 770 771 -
trunk/src/ScantableWrapper.h
r2587 r2591 310 310 { return table_->execFFT(whichrow, mask, getRealImag, getAmplitudeOnly); } 311 311 312 std::vector<uint> getMoleculeIdColumnData() const 313 { return table_->getMoleculeIdColumnData(); } 314 void setMoleculeIdColumnData(const std::vector<uint>& molids) 315 { table_->setMoleculeIdColumnData(molids); } 312 316 313 317 -
trunk/src/python_Scantable.cpp
r2526 r2591 161 161 //.def("_sspline_baseline", &ScantableWrapper::smoothingSplineBaseline) 162 162 //.def("_test_cin", &ScantableWrapper::testCin) 163 .def("_getmolidcol_list", &ScantableWrapper::getMoleculeIdColumnData) 164 .def("_setmolidcol_list", &ScantableWrapper::setMoleculeIdColumnData) 163 165 ; 164 166 };
Note:
See TracChangeset
for help on using the changeset viewer.