Commits
174 174 | itsFlagAcc(), |
175 175 | itsModDataAcc(), |
176 176 | itsCorrDataAcc(), |
177 177 | itsChanFlagAcc(), |
178 178 | itsDataShapes(0), |
179 179 | itsFreqTolerance(freqTolerance), |
180 180 | itsApplyTsys(applyTsys), |
181 181 | itsEVLAisOn(false), |
182 182 | itsInitEpoch(false), |
183 183 | itsRevBeenWarned(false), |
184 - | itsNoPolInfoWarned(false) |
184 + | itsNoPolInfoWarned(false), |
185 + | itsZeroEpochWarned(false) |
185 186 | { |
186 187 | String antscheme=antnamescheme; |
187 188 | antscheme.downcase(); |
188 189 | itsNewAntName=false; |
189 190 | if(antscheme.contains("new")) |
190 191 | itsNewAntName=true; |
191 192 | itsKeepAutoCorr=autocorr; |
192 193 | checkStop = false; |
193 194 | fillStarted = false; |
194 195 | AlwaysAssert(itsMS.tableInfo().subType() == "VLA", AipsError); |
446 447 | itsNewScan=true; |
447 448 | return true; |
448 449 | } |
449 450 | |
450 451 | fillStarted = true; |
451 452 | const VLARCA& rca = itsRecord.RCA(); |
452 453 | const VLASDA& sda = itsRecord.SDA(); |
453 454 | //For new ms and first go...make sure to init this to B1950 if data is so |
454 455 | // as default blank ms is in J2000 direction |
455 456 | if(!itsInitEpoch){ |
456 - | itsMSDirType=sda.epoch(); |
457 + | itsMSDirType=validEpoch(sda.epoch()); |
457 458 | itsFrame.set(MDirection(MVDirection(), itsMSDirType)); |
458 459 | setDirectionRef(itsMSDirType); |
459 460 | setUVWRef(Muvw::fromDirType(itsMSDirType)); |
460 461 | // For the direction and uvw converter the output type is fixed. |
461 462 | itsDirCtr.setOut(MeasRef<MDirection>(itsMSDirType, itsFrame)); |
462 463 | itsUvwCtr.setOut(MeasRef<Muvw>(Muvw::fromDirType(itsMSDirType), itsFrame)); |
463 464 | itsMS.initRefs(); |
464 465 | |
465 466 | itsInitEpoch=true; |
466 467 | itsMS.flush(); |
495 496 | //NEED to use the exact date the EVLA antenna got in |
496 497 | // If after 2005 EVLA can be in |
497 498 | if(obsTime.getDay() > 53371.0) |
498 499 | itsEVLAisOn=true; |
499 500 | else |
500 501 | itsEVLAisOn=false; |
501 502 | } |
502 503 | |
503 504 | { // Workout the field ID. |
504 505 | const MVDirection fieldDirVal(sda.sourceDir()); |
505 - | const MDirection::Types fieldDirRef(sda.epoch()); |
506 + | const MDirection::Types fieldDirRef(validEpoch(sda.epoch())); |
506 507 | // Need to convert the direction to the same type as the MS. Otherwise the |
507 508 | // match will fail. |
508 509 | |
509 510 | MDirection fieldDir(fieldDirVal, fieldDirRef); |
510 511 | if (fieldDirRef != itsMSDirType) { // need to do a conversion |
511 512 | if (fieldDirRef == itsDirType) { // no need to setup the converter |
512 513 | fieldDir = itsDirCtr(fieldDirVal); |
513 514 | } else { |
514 515 | itsDirCtr.setModel(fieldDir); |
515 516 | itsDirType = fieldDirRef; |
564 565 | } |
565 566 | |
566 567 | const uInt nAnt = rca.nAntennas(); |
567 568 | // Cache the uvw coordinates of each antenna. For holography mode, |
568 569 | // these are the az, el offsets. |
569 570 | Block<Double> antUvw(3*nAnt); |
570 571 | { |
571 572 | uInt elem = 0; |
572 573 | Vector<Double> convertedUvw(3); |
573 574 | Double u, v, w; |
574 - | const Bool doConversion = (itsMSDirType == sda.epoch()) ? false : true; |
575 + | const Bool doConversion = (itsMSDirType == validEpoch(sda.epoch())) ? false : true; |
575 576 | for (uInt a = 0; a < nAnt; a++) { |
576 577 | const VLAADA& ada = itsRecord.ADA(a); |
577 578 | u = ada.u(); |
578 579 | v = ada.v(); |
579 580 | w = ada.w(); |
580 581 | if (doConversion) { |
581 582 | convertedUvw = itsUvwCtr(MVuvw(u, v, w)).getValue().getValue(); |
582 583 | u = convertedUvw(0); |
583 584 | v = convertedUvw(1); |
584 585 | w = convertedUvw(2); |
700 701 | if(isHolo) { |
701 702 | |
702 703 | // We store AzEl in the pointing table. We only need to do this |
703 704 | // when the table is empty |
704 705 | MSPointingColumns& pointingCol = pointing(); |
705 706 | if(pointingCol.nrow()==0) { |
706 707 | pointingCol.directionMeasCol().setDescRefCode(MDirection::AZEL); |
707 708 | } |
708 709 | |
709 710 | const MVDirection fieldDirVal(itsRecord.SDA().sourceDir()); |
710 - | const MDirection::Types fieldDirRef(itsRecord.SDA().epoch()); |
711 + | const MDirection::Types fieldDirRef(validEpoch(itsRecord.SDA().epoch())); |
711 712 | MDirection fieldDir(fieldDirVal, fieldDirRef); |
712 713 | |
713 714 | // For the actual direction, we put (Az,El) = (0,0). For the |
714 715 | // target, we put the actual Ra, Dec. The uv data (in ns!) is |
715 716 | // really the pointing offset in radians. |
716 717 | for (uInt a = 0; a < nAnt; a++) { |
717 718 | if(itsAntId[a]>-1) { |
718 719 | const VLAADA& ada = itsRecord.ADA(a); |
719 720 | MDirection thisDir(MVDirection(0.0, 0.0), MDirection::AZEL); |
720 721 | thisDir.shift(-ada.u()/ns2m, ada.v()/ns2m, true); |
865 866 | |
866 867 | |
867 868 | itsLog << LogIO::DEBUGGING; |
868 869 | itsLog << "CDA's containing this spectral ID: ["; |
869 870 | for (uInt c = 0; c < CDAId[localSpId].nelements(); c++) { |
870 871 | itsLog << static_cast<Int>(CDAId[localSpId][c]) |
871 872 | << ((c+1 < CDAId[localSpId].nelements()) ? ", " : "]\n"); |
872 873 | } |
873 874 | itsLog << "The previous CDA containing this spectral ID: " |
874 875 | << static_cast<Int>(CDAId[localSpId][nCDA-1]) << endl; |
875 - | itsLog << "The polarisation map of this CDA: [" ; |
876 + | itsLog << "The polarization map of this CDA: [" ; |
876 877 | { |
877 878 | const uInt w = CDAId[localSpId][nCDA-1]; |
878 879 | for (uInt c = 0; c < polId[w].nelements(); c++) { |
879 880 | itsLog << polId[w][c] |
880 881 | << ((c+1 < polId[w].nelements()) ? ", " : "]\n"); |
881 882 | } |
882 883 | } |
883 - | itsLog << "The last element of the polarisation map: " |
884 + | itsLog << "The last element of the polarization map: " |
884 885 | << prevPolId.nelements()-1 << endl; |
885 - | itsLog << "The next polarisation starts at index: " |
886 + | itsLog << "The next polarization starts at index: " |
886 887 | << polIdx << endl; |
887 888 | itsLog << LogIO::POST << LogIO::NORMAL; |
888 889 | |
889 890 | } |
890 891 | const uInt nPols = sda.npol(thisCDA); |
891 892 | polId[c].resize(nPols); |
892 893 | for (uInt p = 0; p < nPols; p++) { |
893 894 | polId[c][p] = p + polIdx; |
894 895 | } |
895 896 | } |
899 900 | if (nSpId == 0) { |
900 901 | // This can occur if there is a single antenna subarray doing VLBI. This |
901 902 | // antenna may not be connected to the VLA correlator and hence the |
902 903 | // auto-correlation cannot be calculated. In this case all the CDA's are |
903 904 | // invalid and there is no data to add to the main table of the MS. |
904 905 | DebugAssert(nAnt == 1, AipsError); |
905 906 | return true; |
906 907 | } |
907 908 | |
908 909 | // Check if the transfer switch is only set on some antennas. If so warn |
909 - | // the user that the polarisation may be misslabeled |
910 + | // the user that the polarization may be misslabeled |
910 911 | { |
911 912 | const Stokes::StokesTypes ant0Pol = itsRecord.ADA(0).ifPol(VLAEnum::IFA); |
912 913 | for (uInt a = 1; a < nAnt; a++) { |
913 914 | if (itsRecord.ADA(a).ifPol(VLAEnum::IFA) != ant0Pol) { |
914 915 | // only warn if there's been no warning on this antenna yet - only ants with warnings are ever here |
915 916 | if (itsTransferWarned.count(itsRecord.ADA(a).antName(itsNewAntName)) == 0) { |
916 917 | itsLog << LogIO::WARN |
917 918 | << "The IF transfer switch for antenna " |
918 919 | << itsRecord.ADA(a).antName(itsNewAntName) |
919 920 | << " is different from the setting for antenna " |
920 921 | << itsRecord.ADA(0).antName(itsNewAntName) << "." << endl |
921 922 | << "Correlations involving this antenna may have " |
922 - | << "incorrect polarisation labelling." |
923 + | << "incorrect polarization labelling." |
923 924 | << LogIO::POST; |
924 925 | itsTransferWarned[itsRecord.ADA(a).antName(itsNewAntName)] = true; |
925 926 | } |
926 927 | } |
927 928 | } |
928 929 | } |
929 930 | |
930 931 | // Now sort out the polarisation subtable |
931 932 | if (nSpId != itsPolId.nelements()) { |
932 933 | itsPolId.resize(nSpId, true); |
1031 1032 | << "')" << endl; |
1032 1033 | for (uInt s = 0; s < CDAId.nelements(); s++) { |
1033 1034 | itsLog << " Id: " << itsSpId[CDAId[s][0]] << " is in CDA's ["; |
1034 1035 | for (uInt i = 0; i < CDAId[s].nelements(); i++) { |
1035 1036 | itsLog << static_cast<Int>(CDAId[s][i])+1 |
1036 1037 | << ((i+1 < CDAId[s].nelements()) ? ", " : "]\n"); |
1037 1038 | } |
1038 1039 | for (uInt cda = 0; cda < CDAId[s].nelements(); cda++) { |
1039 1040 | itsLog << " CDA: " << static_cast<Int>(CDAId[s][cda]) + 1 |
1040 1041 | << " contains " << polId[CDAId[s][cda]].nelements() |
1041 - | << " polarisations ["; |
1042 + | << " polarizations ["; |
1042 1043 | for (uInt i = 0; i < polId[CDAId[s][cda]].nelements(); i++) { |
1043 1044 | itsLog << polId[CDAId[s][cda]][i] |
1044 1045 | << ((i+1 < polId[CDAId[s][cda]].nelements()) ? ", " : "] ("); |
1045 1046 | } |
1046 1047 | Vector<Stokes::StokesTypes> pol(itsRecord.polarisations(CDAId[s][cda])); |
1047 1048 | for (uInt i = 0; i < pol.nelements(); i++) { |
1048 1049 | itsLog << Stokes::name(pol(i)) |
1049 1050 | << ((i+1 < pol.nelements()) ? ", " : ")\n"); |
1050 1051 | } |
1051 1052 | } |
2195 2196 | break; |
2196 2197 | case Stokes::LR: |
2197 2198 | polProd(0, p) = 1; |
2198 2199 | polProd(1, p) = 0; |
2199 2200 | break; |
2200 2201 | case Stokes::LL: |
2201 2202 | polProd(0, p) = 1; |
2202 2203 | polProd(1, p) = 1; |
2203 2204 | break; |
2204 2205 | default: |
2205 - | throw(AipsError("VLAFiller::addPolarization - Bad polarisation value")); |
2206 + | throw(AipsError("VLAFiller::addPolarization - Bad polarization value")); |
2206 2207 | } |
2207 2208 | } |
2208 2209 | pol.corrType().put(newRow, polInt); |
2209 2210 | pol.corrProduct().put(newRow, polProd); |
2210 2211 | pol.flagRow().put(newRow, false); |
2211 2212 | return newRow; |
2212 2213 | } |
2213 2214 | |
2214 2215 | uInt VLAFiller::addDataDescription(uInt spwId, uInt polId) { |
2215 2216 | MSDataDescColumns& dd = dataDescription(); |
2440 2441 | ostringstream newname; |
2441 2442 | newname << thisname << "_" << suffix; |
2442 2443 | name(nameMatches(imatch))=String(newname); |
2443 2444 | fldcol.name().put(nameMatches(imatch),name(nameMatches(imatch))); |
2444 2445 | } |
2445 2446 | } |
2446 2447 | } |
2447 2448 | |
2448 2449 | } |
2449 2450 | |
2451 + | casacore::MDirection::Types VLAFiller::validEpoch(casacore::MDirection::Types mdType) |
2452 + | { |
2453 + | if (mdType == MDirection::N_Types) { |
2454 + | // epoch in data is 0, warn and assume B1950_VLA |
2455 + | mdType = MDirection::B1950_VLA; |
2456 + | if (!itsZeroEpochWarned) { |
2457 + | itsLog << LogIO::WARN |
2458 + | << "epoch is 0, assuming B1950_VLA" |
2459 + | << LogIO::POST; |
2460 + | itsZeroEpochWarned = true; |
2461 + | } |
2462 + | } |
2463 + | return mdType; |
2464 + | } |
2465 + | |
2450 2466 | |
2451 2467 | // Local Variables: |
2452 2468 | // compile-command: "gmake VLAFiller; cd ../../apps/vlafiller; gmake OPTLIB=1" |
2453 2469 | // End: |