Changeset 1387
- Timestamp:
- 07/27/07 02:00:22 (17 years ago)
- Location:
- branches/alma/src
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/src/STAttr.cpp
r1345 r1387 73 73 Float D = 1.0; 74 74 switch (inst) { 75 case ALMA: 76 { 77 D = 12.0; 78 } 79 break; 80 75 81 case ATMOPRA: 76 82 { … … 92 98 { 93 99 D = 30.0; 100 } 101 break; 102 case GBT: 103 { 104 D = 104.9; 94 105 } 95 106 break; … … 338 349 if (t==String("DSS-43")) { 339 350 inst = TIDBINBILLA; 351 } else if (t==String("ALMA")) { 352 inst = ALMA; 340 353 } else if (t==String("ATPKSMB")) { 341 354 inst = ATPKSMB; … … 346 359 } else if (t==String("CEDUNA")) { 347 360 inst = CEDUNA; 361 } else if (t==String("GBT")) { 362 inst = GBT; 348 363 } else if (t==String("HOBART")) { 349 364 inst = HOBART; -
branches/alma/src/STFiller.cpp
r1188 r1387 26 26 27 27 #include <atnf/PKSIO/PKSreader.h> 28 #include <casa/System/ProgressMeter.h> 29 28 30 29 31 #include "STDefs.h" … … 117 119 header_->freqref, 118 120 header_->utc, header_->reffreq, 119 header_->bandwidth); 121 header_->bandwidth, 122 header_->fluxunit); 120 123 121 124 if (status) { … … 135 138 // Determine Telescope and set brightness unit 136 139 140 137 141 Bool throwIt = False; 138 142 Instrument inst = STAttr::convertInstrument(header_->antennaname, throwIt); 139 header_->fluxunit = "Jy";143 //header_->fluxunit = "Jy"; 140 144 if (inst==ATMOPRA || inst==TIDBINBILLA) { 141 145 header_->fluxunit = "K"; … … 184 188 reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0], False); 185 189 table_->setHeader(*header_); 190 //For MS, add the location of POINTING of the input MS so one get 191 //pointing data from there, if necessary. 192 //Also find nrow in MS 193 nInDataRow = 0; 194 if (format == "MS2") { 195 Path datapath(inName); 196 String ptTabPath = datapath.absoluteName(); 197 Table inMS(ptTabPath); 198 nInDataRow = inMS.nrow(); 199 ptTabPath.append("/POINTING"); 200 table_->table().rwKeywordSet().define("POINTING", ptTabPath); 201 if ((header_->antennaname).matches("GBT")) { 202 String GOTabPath = datapath.absoluteName(); 203 GOTabPath.append("/GBT_GO"); 204 table_->table().rwKeywordSet().define("GBT_GO", GOTabPath); 205 } 206 } 207 186 208 } 187 209 … … 209 231 Complex xCalFctr; 210 232 Vector<Complex> xPol; 233 Double min = 0.0; 234 Double max = nInDataRow; 235 ProgressMeter fillpm(min, max, "Data importing progress"); 236 int n = 0; 211 237 while ( status == 0 ) { 212 238 status = reader_->read(scanNo, cycleNo, mjd, interval, fieldName, … … 220 246 spectra, flagtra, xCalFctr, xPol); 221 247 if ( status != 0 ) break; 248 n += 1; 249 222 250 Regex filterrx(".*[SL|PA]$"); 223 251 Regex obsrx("^AT.+"); … … 250 278 RecordFieldPtr<String> srcnCol(rec, "SRCNAME"); 251 279 RecordFieldPtr<Int> srctCol(rec, "SRCTYPE"); 280 RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME"); 281 *fieldnCol = fieldName; 252 282 // try to auto-identify if it is on or off. 253 283 Regex rx(".*[e|w|_R]$"); … … 340 370 row.put(table_->table().nrow()-1, rec); 341 371 } 372 fillpm._update(n); 342 373 } 343 374 if (status > 0) { … … 345 376 throw(AipsError("Reading error occured, data possibly corrupted.")); 346 377 } 378 fillpm.done(); 347 379 return status; 348 380 } -
branches/alma/src/STFitter.cpp
r1232 r1387 329 329 } 330 330 331 bool Fitter::lfit() { 332 LinearFit<Float> fitter; 333 CompoundFunction<Float> func; 334 335 uInt n = funcs_.nelements(); 336 for (uInt i=0; i<n; ++i) { 337 func.addFunction(*funcs_[i]); 338 } 339 340 fitter.setFunction(func); 341 //fitter.setMaxIter(50+n*10); 342 // Convergence criterium 343 //fitter.setCriteria(0.001); 344 345 // Fit 346 Vector<Float> sigma(x_.nelements()); 347 sigma = 1.0; 348 349 parameters_.resize(); 350 parameters_ = fitter.fit(x_, y_, sigma, &m_); 351 std::vector<float> ps; 352 parameters_.tovector(ps); 353 setParameters(ps); 354 355 error_.resize(); 356 error_ = fitter.errors(); 357 358 chisquared_ = fitter.getChi2(); 359 360 residual_.resize(); 361 residual_ = y_; 362 fitter.residual(residual_,x_); 363 // use fitter.residual(model=True) to get the model 364 thefit_.resize(x_.nelements()); 365 fitter.residual(thefit_,x_,True); 366 return true; 367 } 331 368 332 369 std::vector<float> Fitter::evaluate(int whichComp) const -
branches/alma/src/STMath.cpp
r1384 r1387 48 48 #include "STAttr.h" 49 49 #include "STMath.h" 50 #include "STSelector.h" 50 51 51 52 using namespace casa; … … 536 537 } 537 538 539 // dototalpower (migration of GBTIDL procedure dototalpower.pro) 540 // calibrate the CAL on-off pair. It calculate Tsys and average CAL on-off subintegrations 541 // do it for each cycles in a specific scan. 542 CountedPtr< Scantable > STMath::dototalpower( const CountedPtr< Scantable >& calon, 543 const CountedPtr< Scantable >& caloff, Float tcal ) 544 { 545 if ( ! calon->conformant(*caloff) ) { 546 throw(AipsError("'CAL on' and 'CAL off' scantables are not conformant.")); 547 } 548 setInsitu(false); 549 CountedPtr< Scantable > out = getScantable(caloff, false); 550 Table& tout = out->table(); 551 const Table& tcon = calon->table(); 552 Vector<Float> tcalout; 553 Vector<Float> tcalout2; //debug 554 555 if ( tout.nrow() != tcon.nrow() ) { 556 throw(AipsError("Mismatch in number of rows to form cal on - off pair.")); 557 } 558 // iteration by scanno or cycle no. 559 TableIterator sit(tout, "SCANNO"); 560 TableIterator s2it(tcon, "SCANNO"); 561 while ( !sit.pastEnd() ) { 562 Table toff = sit.table(); 563 TableRow row(toff); 564 Table t = s2it.table(); 565 ScalarColumn<Double> outintCol(toff, "INTERVAL"); 566 ArrayColumn<Float> outspecCol(toff, "SPECTRA"); 567 ArrayColumn<Float> outtsysCol(toff, "TSYS"); 568 ArrayColumn<uChar> outflagCol(toff, "FLAGTRA"); 569 ROScalarColumn<uInt> outtcalIdCol(toff, "TCAL_ID"); 570 ROScalarColumn<uInt> outpolCol(toff, "POLNO"); 571 ROScalarColumn<Double> onintCol(t, "INTERVAL"); 572 ROArrayColumn<Float> onspecCol(t, "SPECTRA"); 573 ROArrayColumn<Float> ontsysCol(t, "TSYS"); 574 ROArrayColumn<uChar> onflagCol(t, "FLAGTRA"); 575 //ROScalarColumn<uInt> ontcalIdCol(t, "TCAL_ID"); 576 577 for (uInt i=0; i < toff.nrow(); ++i) { 578 //skip these checks -> assumes the data order are the same between the cal on off pairs 579 // 580 Vector<Float> specCalon, specCaloff; 581 // to store scalar (mean) tsys 582 Vector<Float> tsysout(1); 583 uInt tcalId, polno; 584 Double offint, onint; 585 outpolCol.get(i, polno); 586 outspecCol.get(i, specCaloff); 587 onspecCol.get(i, specCalon); 588 Vector<uChar> flagCaloff, flagCalon; 589 outflagCol.get(i, flagCaloff); 590 onflagCol.get(i, flagCalon); 591 outtcalIdCol.get(i, tcalId); 592 outintCol.get(i, offint); 593 onintCol.get(i, onint); 594 // caluculate mean Tsys 595 uInt nchan = specCaloff.nelements(); 596 // percentage of edge cut off 597 uInt pc = 10; 598 uInt bchan = nchan/pc; 599 uInt echan = nchan-bchan; 600 601 Slicer chansl(IPosition(1,bchan-1), IPosition(1,echan-1), IPosition(1,1),Slicer::endIsLast); 602 Vector<Float> testsubsp = specCaloff(chansl); 603 MaskedArray<Float> spoff = maskedArray( specCaloff(chansl),flagCaloff(chansl) ); 604 MaskedArray<Float> spon = maskedArray( specCalon(chansl),flagCalon(chansl) ); 605 MaskedArray<Float> spdiff = spon-spoff; 606 uInt noff = spoff.nelementsValid(); 607 //uInt non = spon.nelementsValid(); 608 uInt ndiff = spdiff.nelementsValid(); 609 Float meantsys; 610 611 /** 612 Double subspec, subdiff; 613 uInt usednchan; 614 subspec = 0; 615 subdiff = 0; 616 usednchan = 0; 617 for(uInt k=(bchan-1); k<echan; k++) { 618 subspec += specCaloff[k]; 619 subdiff += static_cast<Double>(specCalon[k]-specCaloff[k]); 620 ++usednchan; 621 } 622 **/ 623 // get tcal if input tcal <= 0 624 String tcalt; 625 Float tcalUsed; 626 tcalUsed = tcal; 627 if ( tcal <= 0.0 ) { 628 caloff->tcal().getEntry(tcalt, tcalout, tcalId); 629 if (polno<=3) { 630 tcalUsed = tcalout[polno]; 631 } 632 else { 633 tcalUsed = tcalout[0]; 634 } 635 } 636 637 Float meanoff; 638 Float meandiff; 639 if (noff && ndiff) { 640 //Debug 641 //if(noff!=ndiff) cerr<<"noff and ndiff is not equal"<<endl; 642 meanoff = sum(spoff)/noff; 643 meandiff = sum(spdiff)/ndiff; 644 meantsys= (meanoff/meandiff )*tcalUsed + tcalUsed/2; 645 } 646 else { 647 meantsys=1; 648 } 649 650 tsysout[0] = Float(meantsys); 651 MaskedArray<Float> mcaloff = maskedArray(specCaloff, flagCaloff); 652 MaskedArray<Float> mcalon = maskedArray(specCalon, flagCalon); 653 MaskedArray<Float> sig = Float(0.5) * (mcaloff + mcalon); 654 //uInt ncaloff = mcaloff.nelementsValid(); 655 //uInt ncalon = mcalon.nelementsValid(); 656 657 outintCol.put(i, offint+onint); 658 outspecCol.put(i, sig.getArray()); 659 outflagCol.put(i, flagsFromMA(sig)); 660 outtsysCol.put(i, tsysout); 661 } 662 ++sit; 663 ++s2it; 664 } 665 return out; 666 } 667 668 //dosigref - migrated from GBT IDL's dosigref.pro, do calibration of position switch 669 // observatiions. 670 // input: sig and ref scantables, and an optional boxcar smoothing width(default width=0, 671 // no smoothing). 672 // output: resultant scantable [= (sig-ref/ref)*tsys] 673 CountedPtr< Scantable > STMath::dosigref( const CountedPtr < Scantable >& sig, 674 const CountedPtr < Scantable >& ref, 675 int smoothref, 676 casa::Float tsysv, 677 casa::Float tau ) 678 { 679 if ( ! ref->conformant(*sig) ) { 680 throw(AipsError("'sig' and 'ref' scantables are not conformant.")); 681 } 682 setInsitu(false); 683 CountedPtr< Scantable > out = getScantable(sig, false); 684 CountedPtr< Scantable > smref; 685 if ( smoothref > 1 ) { 686 float fsmoothref = static_cast<float>(smoothref); 687 std::string inkernel = "boxcar"; 688 smref = smooth(ref, inkernel, fsmoothref ); 689 ostringstream oss; 690 oss<<"Applied smoothing of "<<fsmoothref<<" on the reference."<<endl; 691 pushLog(String(oss)); 692 } 693 else { 694 smref = ref; 695 } 696 Table& tout = out->table(); 697 const Table& tref = smref->table(); 698 if ( tout.nrow() != tref.nrow() ) { 699 throw(AipsError("Mismatch in number of rows to form on-source and reference pair.")); 700 } 701 // iteration by scanno? or cycle no. 702 TableIterator sit(tout, "SCANNO"); 703 TableIterator s2it(tref, "SCANNO"); 704 while ( !sit.pastEnd() ) { 705 Table ton = sit.table(); 706 Table t = s2it.table(); 707 ScalarColumn<Double> outintCol(ton, "INTERVAL"); 708 ArrayColumn<Float> outspecCol(ton, "SPECTRA"); 709 ArrayColumn<Float> outtsysCol(ton, "TSYS"); 710 ArrayColumn<uChar> outflagCol(ton, "FLAGTRA"); 711 ArrayColumn<Float> refspecCol(t, "SPECTRA"); 712 ROScalarColumn<Double> refintCol(t, "INTERVAL"); 713 ROArrayColumn<Float> reftsysCol(t, "TSYS"); 714 ArrayColumn<uChar> refflagCol(t, "FLAGTRA"); 715 ROScalarColumn<Float> refelevCol(t, "ELEVATION"); 716 for (uInt i=0; i < ton.nrow(); ++i) { 717 718 Double onint, refint; 719 Vector<Float> specon, specref; 720 // to store scalar (mean) tsys 721 Vector<Float> tsysref; 722 outintCol.get(i, onint); 723 refintCol.get(i, refint); 724 outspecCol.get(i, specon); 725 refspecCol.get(i, specref); 726 Vector<uChar> flagref, flagon; 727 outflagCol.get(i, flagon); 728 refflagCol.get(i, flagref); 729 reftsysCol.get(i, tsysref); 730 731 Float tsysrefscalar; 732 if ( tsysv > 0.0 ) { 733 ostringstream oss; 734 Float elev; 735 refelevCol.get(i, elev); 736 oss << "user specified Tsys = " << tsysv; 737 // do recalc elevation if EL = 0 738 if ( elev == 0 ) { 739 throw(AipsError("EL=0, elevation data is missing.")); 740 } else { 741 if ( tau <= 0.0 ) { 742 throw(AipsError("Valid tau is not supplied.")); 743 } else { 744 tsysrefscalar = tsysv * exp(tau/elev); 745 } 746 } 747 oss << ", corrected (for El) tsys= "<<tsysrefscalar; 748 pushLog(String(oss)); 749 } 750 else { 751 tsysrefscalar = tsysref[0]; 752 } 753 //get quotient spectrum 754 MaskedArray<Float> mref = maskedArray(specref, flagref); 755 MaskedArray<Float> mon = maskedArray(specon, flagon); 756 MaskedArray<Float> specres = tsysrefscalar*((mon - mref)/mref); 757 Double resint = onint*refint*smoothref/(onint+refint*smoothref); 758 759 //Debug 760 //cerr<<"Tsys used="<<tsysrefscalar<<endl; 761 // fill the result, replay signal tsys by reference tsys 762 outintCol.put(i, resint); 763 outspecCol.put(i, specres.getArray()); 764 outflagCol.put(i, flagsFromMA(specres)); 765 outtsysCol.put(i, tsysref); 766 } 767 ++sit; 768 ++s2it; 769 } 770 return out; 771 } 772 773 CountedPtr< Scantable > STMath::donod(const casa::CountedPtr<Scantable>& s, 774 const std::vector<int>& scans, 775 int smoothref, 776 casa::Float tsysv, 777 casa::Float tau, 778 casa::Float tcal ) 779 780 { 781 setInsitu(false); 782 STSelector sel; 783 std::vector<int> scan1, scan2, beams; 784 std::vector< vector<int> > scanpair; 785 std::vector<string> calstate; 786 String msg; 787 788 CountedPtr< Scantable > s1b1on, s1b1off, s1b2on, s1b2off; 789 CountedPtr< Scantable > s2b1on, s2b1off, s2b2on, s2b2off; 790 791 std::vector< CountedPtr< Scantable > > sctables; 792 sctables.push_back(s1b1on); 793 sctables.push_back(s1b1off); 794 sctables.push_back(s1b2on); 795 sctables.push_back(s1b2off); 796 sctables.push_back(s2b1on); 797 sctables.push_back(s2b1off); 798 sctables.push_back(s2b2on); 799 sctables.push_back(s2b2off); 800 801 //check scanlist 802 int n=s->checkScanInfo(scans); 803 if (n==1) { 804 throw(AipsError("Incorrect scan pairs. ")); 805 } 806 807 // Assume scans contain only a pair of consecutive scan numbers. 808 // It is assumed that first beam, b1, is on target. 809 // There is no check if the first beam is on or not. 810 if ( scans.size()==1 ) { 811 scan1.push_back(scans[0]); 812 scan2.push_back(scans[0]+1); 813 } else if ( scans.size()==2 ) { 814 scan1.push_back(scans[0]); 815 scan2.push_back(scans[1]); 816 } else { 817 if ( scans.size()%2 == 0 ) { 818 for (uInt i=0; i<scans.size(); i++) { 819 if (i%2 == 0) { 820 scan1.push_back(scans[i]); 821 } 822 else { 823 scan2.push_back(scans[i]); 824 } 825 } 826 } else { 827 throw(AipsError("Odd numbers of scans, cannot form pairs.")); 828 } 829 } 830 scanpair.push_back(scan1); 831 scanpair.push_back(scan2); 832 calstate.push_back("*calon"); 833 calstate.push_back("*[^calon]"); 834 CountedPtr< Scantable > ws = getScantable(s, false); 835 uInt l=0; 836 while ( l < sctables.size() ) { 837 for (uInt i=0; i < 2; i++) { 838 for (uInt j=0; j < 2; j++) { 839 for (uInt k=0; k < 2; k++) { 840 sel.reset(); 841 sel.setScans(scanpair[i]); 842 sel.setName(calstate[k]); 843 beams.clear(); 844 beams.push_back(j); 845 sel.setBeams(beams); 846 ws->setSelection(sel); 847 sctables[l]= getScantable(ws, false); 848 l++; 849 } 850 } 851 } 852 } 853 854 // replace here by splitData or getData functionality 855 CountedPtr< Scantable > sig1; 856 CountedPtr< Scantable > ref1; 857 CountedPtr< Scantable > sig2; 858 CountedPtr< Scantable > ref2; 859 CountedPtr< Scantable > calb1; 860 CountedPtr< Scantable > calb2; 861 862 msg=String("Processing dototalpower for subset of the data"); 863 ostringstream oss1; 864 oss1 << msg << endl; 865 pushLog(String(oss1)); 866 // Debug for IRC CS data 867 //float tcal1=7.0; 868 //float tcal2=4.0; 869 sig1 = dototalpower(sctables[0], sctables[1], tcal=tcal); 870 ref1 = dototalpower(sctables[2], sctables[3], tcal=tcal); 871 ref2 = dototalpower(sctables[4], sctables[5], tcal=tcal); 872 sig2 = dototalpower(sctables[6], sctables[7], tcal=tcal); 873 874 // correction of user-specified tsys for elevation here 875 876 // dosigref calibration 877 msg=String("Processing dosigref for subset of the data"); 878 ostringstream oss2; 879 oss2 << msg << endl; 880 pushLog(String(oss2)); 881 calb1=dosigref(sig1,ref2,smoothref,tsysv,tau); 882 calb2=dosigref(sig2,ref1,smoothref,tsysv,tau); 883 884 // iteration by scanno or cycle no. 885 Table& tcalb1 = calb1->table(); 886 Table& tcalb2 = calb2->table(); 887 TableIterator sit(tcalb1, "SCANNO"); 888 TableIterator s2it(tcalb2, "SCANNO"); 889 while ( !sit.pastEnd() ) { 890 Table t1 = sit.table(); 891 Table t2= s2it.table(); 892 ArrayColumn<Float> outspecCol(t1, "SPECTRA"); 893 ArrayColumn<Float> outtsysCol(t1, "TSYS"); 894 ArrayColumn<uChar> outflagCol(t1, "FLAGTRA"); 895 ScalarColumn<Double> outintCol(t1, "INTERVAL"); 896 ArrayColumn<Float> t2specCol(t2, "SPECTRA"); 897 ROArrayColumn<Float> t2tsysCol(t2, "TSYS"); 898 ArrayColumn<uChar> t2flagCol(t2, "FLAGTRA"); 899 ROScalarColumn<Double> t2intCol(t2, "INTERVAL"); 900 for (uInt i=0; i < t1.nrow(); ++i) { 901 Vector<Float> spec1, spec2; 902 // to store scalar (mean) tsys 903 Vector<Float> tsys1, tsys2; 904 Vector<uChar> flag1, flag2; 905 Double tint1, tint2; 906 outspecCol.get(i, spec1); 907 t2specCol.get(i, spec2); 908 outflagCol.get(i, flag1); 909 t2flagCol.get(i, flag2); 910 outtsysCol.get(i, tsys1); 911 t2tsysCol.get(i, tsys2); 912 outintCol.get(i, tint1); 913 t2intCol.get(i, tint2); 914 // average 915 // assume scalar tsys for weights 916 Float wt1, wt2, tsyssq1, tsyssq2; 917 tsyssq1 = tsys1[0]*tsys1[0]; 918 tsyssq2 = tsys2[0]*tsys2[0]; 919 wt1 = Float(tint1)/tsyssq1; 920 wt2 = Float(tint2)/tsyssq2; 921 Float invsumwt=1/(wt1+wt2); 922 MaskedArray<Float> mspec1 = maskedArray(spec1, flag1); 923 MaskedArray<Float> mspec2 = maskedArray(spec2, flag2); 924 MaskedArray<Float> avspec = invsumwt * (wt1*mspec1 + wt2*mspec2); 925 //Array<Float> avtsys = Float(0.5) * (tsys1 + tsys2); 926 // cerr<< "Tsys1="<<tsys1<<" Tsys2="<<tsys2<<endl; 927 tsys1[0] = sqrt(tsyssq1 + tsyssq2); 928 Array<Float> avtsys = tsys1; 929 930 outspecCol.put(i, avspec.getArray()); 931 outflagCol.put(i, flagsFromMA(avspec)); 932 outtsysCol.put(i, avtsys); 933 } 934 ++sit; 935 ++s2it; 936 } 937 return calb1; 938 } 939 940 //GBTIDL version of frequency switched data calibration 941 CountedPtr< Scantable > STMath::dofs( const CountedPtr< Scantable >& s, 942 const std::vector<int>& scans, 943 int smoothref, 944 casa::Float tsysv, 945 casa::Float tau, 946 casa::Float tcal ) 947 { 948 949 950 STSelector sel; 951 CountedPtr< Scantable > ws = getScantable(s, false); 952 CountedPtr< Scantable > sig, sigwcal, ref, refwcal; 953 CountedPtr< Scantable > calsig, calref, out; 954 955 //split the data 956 sel.setName("*_fs"); 957 ws->setSelection(sel); 958 sig = getScantable(ws,false); 959 sel.reset(); 960 sel.setName("*_fs_calon"); 961 ws->setSelection(sel); 962 sigwcal = getScantable(ws,false); 963 sel.reset(); 964 sel.setName("*_fsr"); 965 ws->setSelection(sel); 966 ref = getScantable(ws,false); 967 sel.reset(); 968 sel.setName("*_fsr_calon"); 969 ws->setSelection(sel); 970 refwcal = getScantable(ws,false); 971 972 calsig = dototalpower(sigwcal, sig, tcal=tcal); 973 calref = dototalpower(refwcal, ref, tcal=tcal); 974 975 out=dosigref(calsig,calref,smoothref,tsysv,tau); 976 977 return out; 978 } 979 538 980 539 981 CountedPtr< Scantable > STMath::freqSwitch( const CountedPtr< Scantable >& in ) … … 1250 1692 vec = 0; 1251 1693 pols->table_.rwKeywordSet().define("nPol", Int(1)); 1252 pols->table_.rwKeywordSet().define("POLTYPE", String("stokes")); 1694 //pols->table_.rwKeywordSet().define("POLTYPE", String("stokes")); 1695 pols->table_.rwKeywordSet().define("POLTYPE", in->getPolType()); 1253 1696 std::vector<CountedPtr<Scantable> > vpols; 1254 1697 vpols.push_back(pols); -
branches/alma/src/STSelector.cpp
r1004 r1387 83 83 void asap::STSelector::setName( const std::string& sname ) 84 84 { 85 std::string sql = "SELECT from$1 WHERE SRCNAME == pattern('"+sname+"')";85 std::string sql = "SELECT FROM $1 WHERE SRCNAME == pattern('"+sname+"')"; 86 86 setTaQL(sql); 87 87 } -
branches/alma/src/STTcal.cpp
r856 r1387 68 68 } 69 69 70 /*** rewrite this for handling of GBT data 70 71 uInt STTcal::addEntry( const String& time, const Vector<Float>& cal) 71 72 { … … 90 91 return resultid; 91 92 } 93 ***/ 94 95 uInt STTcal::addEntry( const String& time, const Vector<Float>& cal) 96 { 97 // test if this already exists 98 // TT - different Tcal values for each polarization, feed, and 99 // data description. So there may be multiple entries for the same 100 // time stamp. 101 uInt resultid; 102 uInt rno = table_.nrow(); 103 //table_.addRow(); 104 // get last assigned tcal_id and increment 105 if ( rno == 0 ) { 106 resultid = 0; 107 } 108 else { 109 idCol_.get(rno-1, resultid); 110 resultid++; 111 } 112 table_.addRow(); 113 tcalCol_.put(rno, cal); 114 timeCol_.put(rno, time); 115 idCol_.put(rno, resultid); 116 return resultid; 117 } 118 92 119 93 120 void STTcal::getEntry( String& time, Vector<Float>& tcal, uInt id ) -
branches/alma/src/STWriter.cpp
r1305 r1387 116 116 117 117 // Extract the header from the table. 118 // this is a little different from what I have done 119 // before. Need to check with the Offline User Test data 118 120 STHeader hdr = in->getHeader(); 119 121 //const Int nPol = hdr.npol; … … 123 125 Vector<uInt> nPol(nIF),nChan(nIF); 124 126 Vector<Bool> havexpol(nIF); 127 String fluxUnit = hdr.fluxunit; 128 125 129 nPol = 0;nChan = 0; havexpol = False; 126 130 for (uint i=0;i<ifs.size();++i) { … … 137 141 hdr.antennaname, hdr.antennaposition, 138 142 hdr.obstype, hdr.equinox, hdr.freqref, 139 nChan, nPol, havexpol, False );143 nChan, nPol, havexpol, False, fluxUnit); 140 144 if ( status ) { 141 145 throw(AipsError("Failed to create output file")); … … 265 269 pushLog(String(oss)); 266 270 writer_->close(); 267 271 //if MS2 delete POINTING table exists and copy the one in the keyword 272 if ( format_ == "MS2" ) { 273 replacePtTab(table, filename); 274 } 268 275 return 0; 269 276 } … … 315 322 } 316 323 317 318 } 324 // For writing MS data, if there is the reference to 325 // original pointing table it replace it by it. 326 void STWriter::replacePtTab (const Table& tab, const std::string& fname) 327 { 328 String oldPtTabName = fname; 329 oldPtTabName.append("/POINTING"); 330 if ( tab.keywordSet().isDefined("POINTING") ) { 331 String PointingTab = tab.keywordSet().asString("POINTING"); 332 if ( Table::isReadable(PointingTab) ) { 333 Table newPtTab(PointingTab, Table::Old); 334 newPtTab.copy(oldPtTabName, Table::New); 335 ostringstream oss; 336 oss << "STWriter: copied " <<PointingTab << " to " << fname; 337 pushLog(String(oss)); 338 } 339 } 340 } 341 342 } -
branches/alma/src/Scantable.cpp
r1375 r1387 1028 1028 } 1029 1029 1030 std::string asap::Scantable::getAntennaName() const 1031 { 1032 String out; 1033 table_.keywordSet().get("AntennaName", out); 1034 return out; 1035 } 1036 1037 int asap::Scantable::checkScanInfo(const std::vector<int>& scanlist) const 1038 { 1039 String tbpath; 1040 int ret = 0; 1041 if ( table_.keywordSet().isDefined("GBT_GO") ) { 1042 table_.keywordSet().get("GBT_GO", tbpath); 1043 Table t(tbpath,Table::Old); 1044 // check each scan if other scan of the pair exist 1045 int nscan = scanlist.size(); 1046 for (int i = 0; i < nscan; i++) { 1047 Table subt = t( t.col("SCAN") == scanlist[i]+1 ); 1048 if (subt.nrow()==0) { 1049 cerr <<"Scan "<<scanlist[i]<<" cannot be found in the scantable."<<endl; 1050 ret = 1; 1051 break; 1052 } 1053 ROTableRow row(subt); 1054 const TableRecord& rec = row.get(0); 1055 int scan1seqn = rec.asuInt("PROCSEQN"); 1056 int laston1 = rec.asuInt("LASTON"); 1057 if ( rec.asuInt("PROCSIZE")==2 ) { 1058 if ( i < nscan-1 ) { 1059 Table subt2 = t( t.col("SCAN") == scanlist[i+1]+1 ); 1060 if ( subt2.nrow() == 0) { 1061 cerr<<"Scan "<<scanlist[i+1]<<" cannot be found in the scantable."<<endl; 1062 ret = 1; 1063 break; 1064 } 1065 ROTableRow row2(subt2); 1066 const TableRecord& rec2 = row2.get(0); 1067 int scan2seqn = rec2.asuInt("PROCSEQN"); 1068 int laston2 = rec2.asuInt("LASTON"); 1069 if (scan1seqn == 1 && scan2seqn == 2) { 1070 if (laston1 == laston2) { 1071 cerr<<"A valid scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<endl; 1072 i +=1; 1073 } 1074 else { 1075 cerr<<"Incorrect scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<endl; 1076 } 1077 } 1078 else if (scan1seqn==2 && scan2seqn == 1) { 1079 if (laston1 == laston2) { 1080 cerr<<"["<<scanlist[i]<<","<<scanlist[i+1]<<"] is a valid scan pair but in incorrect order."<<endl; 1081 ret = 1; 1082 break; 1083 } 1084 } 1085 else { 1086 cerr<<"The other scan for "<<scanlist[i]<<" appears to be missing. Check the input scan numbers."<<endl; 1087 ret = 1; 1088 break; 1089 } 1090 } 1091 } 1092 else { 1093 cerr<<"The scan does not appear to be standard obsevation."<<endl; 1094 } 1095 //if ( i >= nscan ) break; 1096 } 1097 } 1098 else { 1099 cerr<<"No reference to GBT_GO table."<<endl; 1100 ret = 1; 1101 } 1102 return ret; 1103 } 1104 1105 std::vector<double> asap::Scantable::getDirectionVector(int whichrow) const 1106 { 1107 Vector<Double> Dir = dirCol_(whichrow).getAngle("rad").getValue(); 1108 std::vector<double> dir; 1109 Dir.tovector(dir); 1110 return dir; 1111 } 1112 1030 1113 } 1031 1114 //namespace asap -
branches/alma/src/python_Fitter.cpp
r894 r1387 55 55 .def("reset", &Fitter::reset) 56 56 .def("fit", &Fitter::fit) 57 .def("lfit", &Fitter::lfit) 57 58 .def("evaluate", &Fitter::evaluate) 58 59 ; -
branches/alma/src/python_STMath.cpp
r1308 r1387 52 52 .def("_auto_quotient", &STMathWrapper::autoQuotient) 53 53 .def("_quotient", &STMathWrapper::quotient) 54 .def("_dototalpower", &STMathWrapper::dototalpower) 55 .def("_dosigref", &STMathWrapper::dosigref) 56 .def("_donod", &STMathWrapper::donod) 57 .def("_dofs", &STMathWrapper::dofs) 54 58 .def("_stats", &STMathWrapper::statistic) 55 59 .def("_freqswitch", &STMathWrapper::freqSwitch) -
branches/alma/src/python_Scantable.cpp
r1360 r1387 102 102 .def("_getdirection", &ScantableWrapper::getDirectionString, 103 103 (boost::python::arg("whichrow")=0) ) 104 .def("get_antennaname", &ScantableWrapper::getAntennaName) 104 105 .def("_flag", &ScantableWrapper::flag) 105 106 .def("_save", &ScantableWrapper::makePersistent) … … 121 122 .def("_recalcazel", &ScantableWrapper::calculateAZEL) 122 123 .def("_setsourcetype", &ScantableWrapper::setSourceType) 124 .def("_getdirectionvec", &ScantableWrapper::getDirectionVector) 123 125 ; 124 126 };
Note:
See TracChangeset
for help on using the changeset viewer.