Commits

George Moellenbrock authored 32734a1c242 Merge
Merge branch 'master' into feature/CAS-10977

code/alma/apps/asdm2MS/bdflags2MS.cc

Modified
1791 1791 iMSRow,
1792 1792 flag,
1793 1793 flagRow,
1794 1794 ocorrelationMode);
1795 1795 }
1796 1796 break;
1797 1797
1798 1798 case ProcessorTypeMod::RADIOMETER :
1799 1799 {
1800 1800 const SDMDataObject& sdo = sdor.read(bdfPath);
1801 - const SDMDataObject::BinaryPart & flagsBP = sdo.dataStruct().flags();
1802 - const vector<AxisName> & flagsAxes = flagsBP.axes();
1803 - ostringstream oss;
1804 - hack06 hack06_instance(oss);
1805 - for_each(flagsAxes.begin(), flagsAxes.end(), hack06_instance);
1806 -
1807 - // Check the validity of the sequence of flags axes (depending on the fact that data are packed or not).
1808 - // also check tos ee if the first integration should be skipped - only done for packed data
1809 - // must be known before accumulator is instantiated.
1810 - bool skipFirstIntegration = false;
1811 - if (sdo.hasPackedData()) {
1812 - if (!regex_match(oss.str(), ALMARadiometerPackedFlagsAxesRegex))
1813 - throw ProcessFlagsException("'" + oss.str() + "' is not a valid sequence of flags axes for an ALMA radiometer.");
1814 -
1815 - // determine if the first integration should be skipped due a duplicate time from a subscan.
1816 - const SDMDataSubset& sdmDataSubset = sdo.sdmDataSubsets()[0];
1817 - int64_t deltaTime = sdmDataSubset.interval() / sdo.numTime();
1818 - int64_t startTime = (int64_t)sdmDataSubset.time() - (int64_t)sdmDataSubset.interval()/2LL + deltaTime/2LL;
1819 -
1820 - // should the first integration be skipped? Any actual skipping happens later.
1821 - skipFirstIntegration = checkDupInts && lastTimeMap[mR->getConfigDescriptionId()] == ArrayTime(startTime).getMJD();
1822 - if (debug && skipFirstIntegration) {
1823 - cout << "Duplicate time seen in Row : " << mainRowIndex[iASDMIndex]
1824 - << " cdId : " << mR->getConfigDescriptionId()
1825 - << " " << mR->getDataUID().getEntityId().toString()
1826 - << " numTime : " << sdo.numTime()
1827 - << endl;
1801 + // should this correlationMode be skipped? This is probably always AUTO_ONLY, but this is a general test just in case
1802 + if ((sdo.correlationMode()==CorrelationModeMod::AUTO_ONLY and ocorrelationMode==CorrelationModeMod::CROSS_ONLY) ||
1803 + (sdo.correlationMode()==CorrelationModeMod::CROSS_ONLY and ocorrelationMode==CorrelationModeMod::AUTO_ONLY)) {
1804 + if (debug) {
1805 + cout << "Skipped file " << bdfPath << " due to output correlation mode selection" << endl;
1828 1806 }
1829 - lastTimeMap[mR->getConfigDescriptionId()] = ArrayTime(startTime+(sdo.numTime()-1)*deltaTime).getMJD();
1830 - }
1831 - else {
1832 - if (!regex_match(oss.str(), ALMARadiometerFlagsAxesRegex))
1833 - throw ProcessFlagsException("'" + oss.str() + "' is not a valid sequence of flags axes for an ALMA radiometer.");
1834 - }
1835 - unsigned int numIntegrations = sdo.hasPackedData() ? sdo.numTime() : sdo.sdmDataSubsets().size();
1836 - if (numIntegrations != numIntegration) {
1837 - infostream << "(the number of integrations actually read in the BDF (numIntegrations = " << numIntegrations << ") is different from the value announced in the Main table (numIntegration = " << numIntegration
1838 - << "). Using " << numIntegrations << ")";
1839 - }
1840 - MSFlagAccumulator<char> accumulator(numIntegrations, antennas.size(), numDD);
1807 + } else {
1808 + const SDMDataObject::BinaryPart & flagsBP = sdo.dataStruct().flags();
1809 + const vector<AxisName> & flagsAxes = flagsBP.axes();
1810 + ostringstream oss;
1811 + hack06 hack06_instance(oss);
1812 + for_each(flagsAxes.begin(), flagsAxes.end(), hack06_instance);
1813 +
1814 + // Check the validity of the sequence of flags axes (depending on the fact that data are packed or not).
1815 + // also check tos ee if the first integration should be skipped - only done for packed data
1816 + // must be known before accumulator is instantiated.
1817 + bool skipFirstIntegration = false;
1818 + if (sdo.hasPackedData()) {
1819 + if (!regex_match(oss.str(), ALMARadiometerPackedFlagsAxesRegex))
1820 + throw ProcessFlagsException("'" + oss.str() + "' is not a valid sequence of flags axes for an ALMA radiometer.");
1821 +
1822 + // determine if the first integration should be skipped due a duplicate time from a subscan.
1823 + const SDMDataSubset& sdmDataSubset = sdo.sdmDataSubsets()[0];
1824 + int64_t deltaTime = sdmDataSubset.interval() / sdo.numTime();
1825 + int64_t startTime = (int64_t)sdmDataSubset.time() - (int64_t)sdmDataSubset.interval()/2LL + deltaTime/2LL;
1826 +
1827 + // should the first integration be skipped? Any actual skipping happens later.
1828 + skipFirstIntegration = checkDupInts && lastTimeMap[mR->getConfigDescriptionId()] == ArrayTime(startTime).getMJD();
1829 + if (debug && skipFirstIntegration) {
1830 + cout << "Duplicate time seen in Row : " << mainRowIndex[iASDMIndex]
1831 + << " cdId : " << mR->getConfigDescriptionId()
1832 + << " " << mR->getDataUID().getEntityId().toString()
1833 + << " numTime : " << sdo.numTime()
1834 + << endl;
1835 + }
1836 + lastTimeMap[mR->getConfigDescriptionId()] = ArrayTime(startTime+(sdo.numTime()-1)*deltaTime).getMJD();
1837 + }
1838 + else {
1839 + if (!regex_match(oss.str(), ALMARadiometerFlagsAxesRegex))
1840 + throw ProcessFlagsException("'" + oss.str() + "' is not a valid sequence of flags axes for an ALMA radiometer.");
1841 + }
1842 + unsigned int numIntegrations = sdo.hasPackedData() ? sdo.numTime() : sdo.sdmDataSubsets().size();
1843 + if (numIntegrations != numIntegration) {
1844 + infostream << "(the number of integrations actually read in the BDF (numIntegrations = " << numIntegrations << ") is different from the value announced in the Main table (numIntegration = " << numIntegration
1845 + << "). Using " << numIntegrations << ")";
1846 + }
1847 + MSFlagAccumulator<char> accumulator(numIntegrations, antennas.size(), numDD);
1841 1848
1842 - const FLAGSTYPE * flags_p = NULL;
1843 - unsigned int numFlags = 0;
1849 + const FLAGSTYPE * flags_p = NULL;
1850 + unsigned int numFlags = 0;
1844 1851
1845 - if (sdo.hasPackedData()) {
1846 - numFlags = sdo.tpDataSubset().flags(flags_p);
1847 - pair<unsigned int, const FLAGSTYPE *> flagsPair(numFlags, flags_p);
1848 - accumulator.resetIntegration();
1849 - traverseALMARadiometerFlagsAxes(numIntegrations, sdo.dataStruct().basebands(), antennas, flagsPair, flagEval, accumulator);
1850 - }
1851 - else {
1852 - // duplicate integrations are not checked or skipped here
1853 - const vector<SDMDataSubset>& sdmDataSubsets = sdo.sdmDataSubsets();
1854 - accumulator.resetIntegration();
1855 - for (unsigned int iIntegration = 0; iIntegration < numIntegrations; iIntegration++) {
1856 - numFlags = sdmDataSubsets[iIntegration].flags(flags_p);
1852 + if (sdo.hasPackedData()) {
1853 + numFlags = sdo.tpDataSubset().flags(flags_p);
1857 1854 pair<unsigned int, const FLAGSTYPE *> flagsPair(numFlags, flags_p);
1858 - traverseALMARadiometerFlagsAxes(1, sdo.dataStruct().basebands(), antennas, flagsPair, flagEval, accumulator);
1855 + accumulator.resetIntegration();
1856 + traverseALMARadiometerFlagsAxes(numIntegrations, sdo.dataStruct().basebands(), antennas, flagsPair, flagEval, accumulator);
1859 1857 }
1860 - // MAFlagAccumulator::flagCell() just returns a data member, it doesn't change anything
1861 - // in the object, and here, the returned value (x) is not used. So this can be
1862 - // safely commented out.
1863 - // const vector < vector < vector <FLAG_CELL> > >& x = accumulator.flagCell();
1864 - }
1865 - infostream.str("");
1858 + else {
1859 + // duplicate integrations are not checked or skipped here
1860 + const vector<SDMDataSubset>& sdmDataSubsets = sdo.sdmDataSubsets();
1861 + accumulator.resetIntegration();
1862 + for (unsigned int iIntegration = 0; iIntegration < numIntegrations; iIntegration++) {
1863 + numFlags = sdmDataSubsets[iIntegration].flags(flags_p);
1864 + pair<unsigned int, const FLAGSTYPE *> flagsPair(numFlags, flags_p);
1865 + traverseALMARadiometerFlagsAxes(1, sdo.dataStruct().basebands(), antennas, flagsPair, flagEval, accumulator);
1866 + }
1867 + // MAFlagAccumulator::flagCell() just returns a data member, it doesn't change anything
1868 + // in the object, and here, the returned value (x) is not used. So this can be
1869 + // safely commented out.
1870 + // const vector < vector < vector <FLAG_CELL> > >& x = accumulator.flagCell();
1871 + }
1872 + infostream.str("");
1866 1873
1867 - infostream << "ASDM Main row #" << mainRowIndex[iASDMIndex] << " - " << numIntegrations << "/" << numIntegrations << " integrations done so far.";
1868 - info(infostream.str());
1874 + infostream << "ASDM Main row #" << mainRowIndex[iASDMIndex] << " - " << numIntegrations << "/" << numIntegrations << " integrations done so far.";
1875 + info(infostream.str());
1869 1876
1877 + pair<uInt, uInt> putReturn = put(accumulator, iMSRow, flag, flagRow,skipFirstIntegration);
1878 + // accumulator.dump(cout, true);
1879 + iMSRow = putReturn.first;
1880 + numFlaggedRows = putReturn.second;
1881 + }
1870 1882 sdor.done();
1871 - pair<uInt, uInt> putReturn = put(accumulator, iMSRow, flag, flagRow,skipFirstIntegration);
1872 - // accumulator.dump(cout, true);
1873 - iMSRow = putReturn.first;
1874 - numFlaggedRows = putReturn.second;
1875 1883 }
1876 1884 break;
1877 1885
1878 1886 default:
1879 1887 throw ProcessFlagsException("Unrecognized processor type.");
1880 1888 }
1881 1889 infostream.str("");
1882 1890 infostream << "ASDM Main row #" << mainRowIndex[iASDMIndex]
1883 1891 << " (scan #" << mR->getScanNumber()
1884 1892 <<", subscan #" << mR->getSubscanNumber()

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut