Changeset 1779 for branches/mergetest/external/atnf/PKSIO/PKSMS2writer.cc
- Timestamp:
- 07/29/10 19:13:46 (14 years ago)
- Location:
- branches/mergetest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mergetest
- Property svn:mergeinfo changed
-
branches/mergetest/external/atnf/PKSIO/PKSMS2writer.cc
r1720 r1779 42 42 #include <casa/BasicSL/Constants.h> 43 43 #include <casa/Quanta/QC.h> 44 #include <casa/Logging/LogIO.h> 44 45 #include <measures/Measures/Stokes.h> 45 46 #include <tables/Tables/ArrColDesc.h> … … 52 53 #include <tables/Tables/TiledShapeStMan.h> 53 54 55 // Class name 56 const string className = "PKSMS2writer" ; 57 54 58 //------------------------------------------------- PKSMS2writer::PKSMS2writer 55 59 … … 59 63 { 60 64 cPKSMS = 0x0; 61 62 // By default, messages are written to stderr.63 initMsg();64 65 } 65 66 … … 92 93 const Bool haveBase) 93 94 { 95 const string methodName = "create()" ; 96 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 97 94 98 if (cPKSMS) { 95 logMsg("ERROR: Output MS already open, close it first.");99 os << LogIO::SEVERE << "Output MS already open, close it first." << LogIO::POST ; 96 100 return 1; 97 101 } 98 99 // Clear the message stack.100 clearMsg();101 102 102 103 // Open a MS table. … … 108 109 109 110 Int maxNPol = max(cNPol); 110 111 111 cGBT = cAPEX = cSMT = cALMA = cATF = False; 112 113 String telName = antName; 114 // check if it is GBT data 115 if (antName.contains("GBT")) { 116 cGBT = True; 117 } 118 else if (antName.contains("APEX")) { 119 cAPEX = True; 120 } 121 else if (antName.contains("HHT") || antName.contains("SMT")) { 122 cSMT = True; 123 } 124 else if (antName.contains("ALMA")) { 125 cALMA = True; 126 } 127 else if (antName.contains("ATF")) { 128 cATF = True; 129 telName="ATF"; 130 } 131 112 132 // Add the non-standard CALFCTR column. 113 133 pksDesc.addColumn(ArrayColumnDesc<Float>("CALFCTR", "Calibration factors", … … 116 136 // Add the optional FLOAT_DATA column. 117 137 MS::addColumnToDesc(pksDesc, MS::FLOAT_DATA, 2); 138 //pksDesc.rwColumnDesc(MS::columnName(MS::FLOAT_DATA)).rwKeywordSet(). 139 // define("UNIT", String("Jy")); 118 140 pksDesc.rwColumnDesc(MS::columnName(MS::FLOAT_DATA)).rwKeywordSet(). 119 141 define("UNIT", bunit); … … 136 158 137 159 MS::addColumnToDesc(pksDesc, MS::DATA, 2); 160 //pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet(). 161 // define("UNIT", "Jy"); 138 162 pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet(). 139 163 define("UNIT", bunit); … … 152 176 newtab.bindAll(incrStMan, True); 153 177 154 // Use TiledShapeStMan for the FLOAT_DATA hypercube with tile size 1 6 kiB.155 TiledShapeStMan tiledStMan("TiledData", IPosition(3,1,128, 32));178 // Use TiledShapeStMan for the FLOAT_DATA hypercube with tile size 1 MB. 179 TiledShapeStMan tiledStMan("TiledData", IPosition(3,1,128,2048)); 156 180 newtab.bindColumn(MS::columnName(MS::FLOAT_DATA), tiledStMan); 157 181 … … 367 391 } else if (dopplerFrame == "SOURCE") { 368 392 MFrequency::getType(cDopplerFrame, "REST"); 393 } else if (dopplerFrame == "LSRK") { 394 MFrequency::getType(cDopplerFrame, "LSRK"); 369 395 } 370 396 … … 374 400 addDopplerEntry(); 375 401 addFeedEntry(); 376 addObservationEntry(observer, project); 402 //addObservationEntry(observer, project); 403 addObservationEntry(observer, project, telName); 377 404 addProcessorEntry(); 378 405 … … 384 411 // Write the next data record. 385 412 413 /** 414 Int PKSMS2writer::write( 415 const Int scanNo, 416 const Int cycleNo, 417 const Double mjd, 418 const Double interval, 419 const String fieldName, 420 const String srcName, 421 const Vector<Double> srcDir, 422 const Vector<Double> srcPM, 423 const Double srcVel, 424 const String obsMode, 425 const Int IFno, 426 const Double refFreq, 427 const Double bandwidth, 428 const Double freqInc, 429 //const Double restFreq, 430 const Vector<Double> restFreq, 431 const Vector<Float> tcal, 432 const String tcalTime, 433 const Float azimuth, 434 const Float elevation, 435 const Float parAngle, 436 const Float focusAxi, 437 const Float focusTan, 438 const Float focusRot, 439 const Float temperature, 440 const Float pressure, 441 const Float humidity, 442 const Float windSpeed, 443 const Float windAz, 444 const Int refBeam, 445 const Int beamNo, 446 const Vector<Double> direction, 447 const Vector<Double> scanRate, 448 const Vector<Float> tsys, 449 const Vector<Float> sigma, 450 const Vector<Float> calFctr, 451 const Matrix<Float> baseLin, 452 const Matrix<Float> baseSub, 453 const Matrix<Float> &spectra, 454 const Matrix<uChar> &flagged, 455 const uInt flagrow, 456 const Complex xCalFctr, 457 const Vector<Complex> &xPol) 458 **/ 386 459 Int PKSMS2writer::write( 387 460 const PKSrecord &pksrec) … … 415 488 pksrec.restFreq, pksrec.srcVel); 416 489 417 // Find or add the obs Type to the STATE subtable.490 // Find or add the obsMode to the STATE subtable. 418 491 Int stateId = addStateEntry(pksrec.obsType); 419 492 420 493 // FIELD subtable. 421 Vector<Double> scanRate(2);422 scanRate(0) = pksrec.scanRate(0);423 scanRate(1) = pksrec.scanRate(1);494 //Vector<Double> scanRate(2); 495 //scanRate(0) = pksrec.scanRate(0); 496 //scanRate(1) = pksrec.scanRate(1); 424 497 Int fieldId = addFieldEntry(pksrec.fieldName, time, pksrec.direction, 425 scanRate, srcId);498 pksrec.scanRate, srcId); 426 499 427 500 // POINTING subtable. 428 501 addPointingEntry(time, pksrec.interval, pksrec.fieldName, pksrec.direction, 429 scanRate);502 pksrec.scanRate); 430 503 431 504 // SYSCAL subtable. 432 505 addSysCalEntry(pksrec.beamNo, iIF, time, pksrec.interval, pksrec.tcal, 433 pksrec.tsys );506 pksrec.tsys, nPol); 434 507 435 508 // Handle weather information. … … 508 581 cMSCols->sigma().put(irow, pksrec.sigma); 509 582 510 Vector<Float> weight(1, 1.0f); 583 //Vector<Float> weight(1, 1.0f); 584 Vector<Float> weight(nPol, 1.0f); 511 585 cMSCols->weight().put(irow, weight); 586 //imaging weight 587 //Vector<Float> imagingWeight(nChan); 588 //cMSCols->imagingWeight().put(irow, imagingWeight); 512 589 513 590 // Flag information. 514 591 Cube<Bool> flags(nPol, nChan, 1, False); 515 cMSCols->flag().put(irow, flags.xyPlane(0));592 //cMSCols->flag().put(irow, flags.xyPlane(0)); 516 593 cMSCols->flagCategory().put(irow, flags); 517 cMSCols->flagRow().put(irow, False); 594 // Row-based flagging info. (True:>0, False:0) 595 cMSCols->flagRow().put(irow, (pksrec.flagrow > 0)); 596 518 597 519 598 return 0; … … 571 650 cSysCal = MSSysCal(); 572 651 cWeather = MSWeather(); 573 574 652 // Release the main table. 575 delete cPKSMS; 576 cPKSMS =0x0;653 delete cPKSMS; 654 cPKSMS=0x0; 577 655 } 578 656 … … 589 667 Int n = cAntenna.nrow() - 1; 590 668 669 // do specific things for GBT 591 670 // Data. 671 // plus some more telescopes 592 672 cAntennaCols->name().put(n, antName); 593 cAntennaCols->station().put(n, "ATNF_PARKES"); 673 //cAntennaCols->station().put(n, "ATNF_PARKES"); 674 if (cGBT) { 675 cAntennaCols->station().put(n, "GREENBANK"); 676 cAntennaCols->dishDiameter().put(n, 110.0); 677 } 678 else if (cAPEX) { 679 cAntennaCols->station().put(n, "CHAJNANTOR"); 680 cAntennaCols->dishDiameter().put(n, 12.0); 681 } 682 else if (cALMA) { 683 // this needs to be changed in future... 684 cAntennaCols->station().put(n, "CHAJNANTOR"); 685 cAntennaCols->dishDiameter().put(n, 12.0); 686 } 687 else if (cATF) { 688 //pad name for the antenna is static... 689 String stname="unknown"; 690 if (antName.contains("DV")) { 691 stname="PAD001"; 692 } 693 if (antName.contains("DA")) { 694 stname="PAD002"; 695 } 696 cAntennaCols->station().put(n, stname); 697 cAntennaCols->dishDiameter().put(n, 12.0); 698 } 699 else if (cSMT) { 700 cAntennaCols->station().put(n, "MT_GRAHAM"); 701 cAntennaCols->dishDiameter().put(n, 10.0); 702 } 703 else { 704 cAntennaCols->station().put(n, "ATNF_PARKES"); 705 cAntennaCols->dishDiameter().put(n, 64.0); 706 } 594 707 cAntennaCols->type().put(n, "GROUND-BASED"); 595 708 cAntennaCols->mount().put(n, "ALT-AZ"); … … 597 710 Vector<Double> antOffset(3, 0.0); 598 711 cAntennaCols->offset().put(n, antOffset); 599 cAntennaCols->dishDiameter().put(n, 64.0); 600 712 //cAntennaCols->dishDiameter().put(n, 64.0); 713 //if (cGBT) { 714 // cAntennaCols->dishDiameter().put(n, 110.0); 715 //} 716 //else { 717 // cAntennaCols->dishDiameter().put(n, 64.0); 718 //} 601 719 // Flags. 602 720 cAntennaCols->flagRow().put(n, False); … … 711 829 const Int srcId) 712 830 { 831 832 ROScalarColumn<String> fldn(cField, "NAME"); 833 ROScalarColumn<Int> sourceid(cField, "SOURCE_ID"); 834 Int n; 835 Int nFld = cField.nrow(); 836 for (n = 0; n < nFld; n++) { 837 if (fldn(n) == fieldName && sourceid(n) == srcId) { 838 break; 839 } 840 } 841 713 842 // Extend the FIELD subtable. 714 cField.addRow(); 715 Int n = cField.nrow() - 1; 716 717 // Data. 718 cFieldCols->name().put(n, fieldName); 719 cFieldCols->code().put(n, "DRIFT"); 720 cFieldCols->time().put(n, time); 721 722 Matrix<Double> track(2, 2); 723 track.column(0) = direction; 724 track.column(1) = scanRate; 725 cFieldCols->numPoly().put(n, 1); 726 cFieldCols->delayDir().put(n, track); 727 cFieldCols->phaseDir().put(n, track); 728 cFieldCols->referenceDir().put(n, track); 729 cFieldCols->sourceId().put(n, srcId); 730 731 // Flags. 732 cFieldCols->flagRow().put(n, False); 843 if (n == nFld) { 844 cField.addRow(); 845 //Int n = cField.nrow() - 1; 846 847 // Data. 848 cFieldCols->name().put(n, fieldName); 849 if (cGBT) { 850 cFieldCols->code().put(n, " "); 851 } 852 else { 853 cFieldCols->code().put(n, "DRIFT"); 854 } 855 cFieldCols->time().put(n, time); 856 857 //Matrix<Double> track(2, 2); 858 Matrix<Double> track(2, 1); 859 track.column(0) = direction; 860 //track.column(1) = scanRate; 861 cFieldCols->numPoly().put(n, 1); 862 cFieldCols->delayDir().put(n, track); 863 cFieldCols->phaseDir().put(n, track); 864 cFieldCols->referenceDir().put(n, track); 865 cFieldCols->sourceId().put(n, srcId); 866 867 // Flags. 868 cFieldCols->flagRow().put(n, False); 869 } 733 870 734 871 return n; … … 741 878 Int PKSMS2writer::addObservationEntry( 742 879 const String observer, 743 const String project) 880 const String project, 881 const String antName) 744 882 { 745 883 // Extend the OBSERVATION subtable. … … 748 886 749 887 // Data. 750 cObservationCols->telescopeName().put(n, "Parkes"); 888 //cObservationCols->telescopeName().put(n, "Parkes"); 889 cObservationCols->telescopeName().put(n, antName); 751 890 Vector<Double> timerange(2, 0.0); 752 891 cObservationCols->timeRange().put(n, timerange); … … 754 893 Vector<String> log(1, "none"); 755 894 cObservationCols->log().put(n, log); 756 cObservationCols->scheduleType().put(n, "ATNF"); 895 //cObservationCols->scheduleType().put(n, "ATNF"); 896 cObservationCols->scheduleType().put(n, ""); 757 897 Vector<String> schedule(1, "Not available"); 758 898 cObservationCols->schedule().put(n, schedule); … … 767 907 768 908 //--------------------------------------------- PKSMS2writer::addPointingEntry 909 910 // Modified to fill pointing data if the direction is the pointing direction. 911 // So the following comment is no longer true. 769 912 770 913 // Add an entry to the POINTING subtable. This compulsory subtable simply … … 778 921 const Vector<Double> scanRate) 779 922 { 780 // Extend the POINTING subtable. 781 cPointing.addRow(); 782 Int n = cPointing.nrow() - 1; 783 784 // Keys. 785 cPointingCols->antennaId().put(n, 0); 786 cPointingCols->time().put(n, time); 787 cPointingCols->interval().put(n, interval); 788 789 // Data. 790 cPointingCols->name().put(n, fieldName); 791 cPointingCols->numPoly().put(n, 1); 792 cPointingCols->timeOrigin().put(n, time); 793 794 Matrix<Double> track(2, 2); 795 track.column(0) = direction; 796 track.column(1) = scanRate; 797 cPointingCols->direction().put(n, track); 798 cPointingCols->target().put(n, track); 799 cPointingCols->tracking().put(n, True); 800 923 924 ROScalarColumn<Double> tms(cPointing, "TIME"); 925 Int n; 926 Int ntm = cPointing.nrow(); 927 for (n = 0; n < ntm; n++) { 928 if (tms(n) == time) { 929 break; 930 } 931 } 932 933 if (n == ntm) { 934 // Extend the POINTING subtable. 935 cPointing.addRow(); 936 //Int n = cPointing.nrow() - 1; 937 938 // Keys. 939 cPointingCols->antennaId().put(n, 0); 940 cPointingCols->time().put(n, time); 941 cPointingCols->interval().put(n, interval); 942 943 // Data. 944 cPointingCols->name().put(n, fieldName); 945 cPointingCols->numPoly().put(n, 1); 946 cPointingCols->timeOrigin().put(n, time); 947 948 //Matrix<Double> track(2, 2); 949 Matrix<Double> track(2, 1); 950 track.column(0) = direction; 951 //track.column(1) = scanRate; 952 cPointingCols->direction().put(n, track); 953 cPointingCols->target().put(n, track); 954 cPointingCols->tracking().put(n, True); 955 } 801 956 return n; 802 957 } … … 821 976 // Data. 822 977 Vector<Int> corrType(2); 978 if (nPol == 1) { 979 corrType.resize(1); 980 corrType(0) = Stokes::XX; 981 } 982 else { 983 //Vector<Int> corrType(2); 823 984 corrType(0) = Stokes::XX; 824 985 corrType(1) = Stokes::YY; 986 } 825 987 cPolarizationCols->corrType().put(n, corrType); 826 988 827 989 Matrix<Int> corrProduct(2,2,1); 990 if (nPol == 1) { 991 corrProduct.resize(2,1,1); 992 corrProduct(1,0) = 0; 993 } 828 994 if (nPol == 2) { 829 995 corrProduct(1,0) = 0; … … 869 1035 const Vector<Double> direction, 870 1036 const Vector<Double> properMotion, 871 const Double restFreq, 1037 //const Double restFreq, 1038 const Vector<Double> restFreq, 872 1039 const Double radialVelocity) 873 1040 { … … 903 1070 // cSourceCols->position().put(n, position); 904 1071 cSourceCols->properMotion().put(n, properMotion); 905 Vector<Double> restFrequency(1, restFreq); 906 cSourceCols->restFrequency().put(n, restFrequency); 1072 // Vector<Double> restFrequency(1, restFreq); 1073 // cSourceCols->restFrequency().put(n, restFrequency); 1074 cSourceCols->restFrequency().put(n, restFreq); 907 1075 Vector<Double> sysvel(1, radialVelocity); 908 1076 cSourceCols->sysvel().put(n, sysvel); … … 933 1101 934 1102 // Data. 935 cSpWindowCols->name().put(n, "L-band"); 1103 //cSpWindowCols->name().put(n, "L-band"); 1104 cSpWindowCols->name().put(n, " "); 936 1105 cSpWindowCols->refFrequency().put(n, refFreq); 937 1106 … … 1015 1184 const Double interval, 1016 1185 const Vector<Float> tcal, 1017 const Vector<Float> tsys) 1018 { 1186 const Vector<Float> tsys, 1187 const Int nPol) 1188 { 1189 LogIO os(LogOrigin("PKSMS2writer", "addSysCalEntry()", WHERE)); 1190 1019 1191 // Extend the SYSCAL subtable. 1020 1192 cSysCal.addRow(); 1021 1193 Int n = cSysCal.nrow() - 1; 1022 1194 1195 //check fo consistency with n pol 1196 //here assume size of Tcal vector = npol 1197 Vector<Float> inTcal(nPol,0); 1198 Int ndim = tcal.shape()(0); 1199 Vector<Float> tmpTcal = tcal; 1200 if (nPol != ndim) { 1201 os << LogIO::WARN 1202 << "Found "<< ndim <<" Tcal value(s) for the data with "<<nPol<<" polarization(s)" 1203 << "(expecting one Tcal per pol)."<<endl 1204 << "First "<< nPol << " Tcal value(s) will be filled." << LogIO::POST; 1205 tmpTcal.resize(nPol, True); 1206 inTcal = tmpTcal; 1207 } 1023 1208 // Keys. 1024 1209 cSysCalCols->antennaId().put(n, 0); … … 1029 1214 1030 1215 // Data. 1031 cSysCalCols->tcal().put(n, tcal); 1216 //cSysCalCols->tcal().put(n, tcal); 1217 cSysCalCols->tcal().put(n, inTcal); 1032 1218 cSysCalCols->tsys().put(n, tsys); 1033 1219
Note: See TracChangeset
for help on using the changeset viewer.