Commits
Bob Garwood authored 765cfc58524 Merge
17 17 | //# You should have received a copy of the GNU Lesser General Public |
18 18 | //# License along with this library; if not, write to the Free Software |
19 19 | //# Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 20 | //# MA 02111-1307 USA |
21 21 | //# $Id: $ |
22 22 | |
23 23 | |
24 24 | |
25 25 | |
26 26 | |
27 + | |
27 28 | |
28 29 | |
29 30 | |
30 31 | using namespace casacore; |
31 32 | namespace casa { //# NAMESPACE CASA - BEGIN |
32 33 | |
33 34 | ///////////////////////////////////////////// |
34 35 | ////// MS Transform Framework utilities ///// |
35 36 | ///////////////////////////////////////////// |
36 37 | namespace MSTransformations |
313 314 | parseFreqTransParams(configuration); |
314 315 | parseChanAvgParams(configuration); |
315 316 | parseRefFrameTransParams(configuration); |
316 317 | parsePhaseShiftParams(configuration); |
317 318 | parseTimeAvgParams(configuration); |
318 319 | parseCalParams(configuration); |
319 320 | parseUVContSubParams(configuration); |
320 321 | setSpwAvg(configuration); |
321 322 | parsePolAvgParams(configuration); |
322 323 | parsePointingsInterpolationParams(configuration); |
323 - | |
324 + | parseAtmCorrectionParams(configuration); |
324 325 | |
325 326 | return; |
326 327 | } |
327 328 | |
328 329 | // ----------------------------------------------------------------------- |
329 330 | // Method to parse input/output MS specification |
330 331 | // ----------------------------------------------------------------------- |
331 332 | void MSTransformManager::parseMsSpecParams(Record &configuration) |
332 333 | { |
333 334 | int exists = -1; |
1270 1271 | } |
1271 1272 | |
1272 1273 | void MSTransformManager::parsePointingsInterpolationParams(casacore::Record &configuration){ |
1273 1274 | String key("pointingsinterpolation"); |
1274 1275 | Bool exists = configuration.isDefined(key); |
1275 1276 | if (exists) { |
1276 1277 | pointingsInterpolation_p = configuration.asBool(key); |
1277 1278 | } |
1278 1279 | } |
1279 1280 | |
1281 + | void MSTransformManager::parseAtmCorrectionParams(casacore::Record &configuration) { |
1282 + | String key("atmCor"); |
1283 + | if (configuration.isDefined(key)) { |
1284 + | doAtmCor_p = configuration.asBool(key); |
1285 + | atmCorConfig_p = configuration; |
1286 + | } else { |
1287 + | doAtmCor_p = False; |
1288 + | } |
1289 + | } |
1290 + | |
1280 1291 | // ----------------------------------------------------------------------- |
1281 1292 | // Method to open the input MS, select the data and create the |
1282 1293 | // structure of the output MS filling the auxiliary tables. |
1283 1294 | // ----------------------------------------------------------------------- |
1284 1295 | void MSTransformManager::open() |
1285 1296 | { |
1286 1297 | // Initialize MSTransformDataHandler to open the MeasurementSet object |
1287 1298 | if (interactive_p) |
1288 1299 | { |
1289 1300 | // In buffer mode we may have to modify the flags |
1293 1304 | { |
1294 1305 | dataHandler_p = new MSTransformDataHandler(inpMsName_p,Table::Old); |
1295 1306 | } |
1296 1307 | |
1297 1308 | |
1298 1309 | // WARNING: Input MS is re-set at the end of a successful MSTransformDataHandler::makeMSBasicStructure, |
1299 1310 | // call therefore we have to use the selected MS always |
1300 1311 | inputMs_p = dataHandler_p->getInputMS(); |
1301 1312 | // Note: We always get the input number of channels because we don't know if pre-averaging will be necessary |
1302 1313 | getInputNumberOfChannels(); |
1303 - | |
1314 + | |
1304 1315 | // Check available data cols to pass this information on to MSTransformDataHandler which creates the MS structure |
1305 1316 | checkDataColumnsAvailable(); |
1306 1317 | checkDataColumnsToFill(); |
1307 - | |
1318 + | |
1308 1319 | |
1309 1320 | // Check whether the MS has correlator pre-averaging and we are smoothing or averaging |
1310 1321 | checkCorrelatorPreaveraging(); |
1311 1322 | |
1312 1323 | // Set virtual column operation |
1313 1324 | dataHandler_p->setVirtualModelCol(makeVirtualModelColReal_p); |
1314 1325 | dataHandler_p->setVirtualCorrectedCol(makeVirtualCorrectedColReal_p); |
1315 1326 | |
1316 1327 | // Once the input MS is opened we can get the selection indexes, |
1317 1328 | // in this way we also validate the selection parameters |
4320 4331 | ddiCols.lagId().put(rowIndex,ddiCols.lagId()(0)); |
4321 4332 | } |
4322 4333 | } |
4323 4334 | |
4324 4335 | // Set SPW id separately |
4325 4336 | ddiCols.spectralWindowId().put(rowIndex,ddiStart_p+spw_i); |
4326 4337 | |
4327 4338 | rowIndex += 1; |
4328 4339 | } |
4329 4340 | |
4330 - | // Delete the old rows |
4341 + | // Delete the old rows |
4331 4342 | rownr_t nrowsToDelete = ddiCols.nrow()-nspws_p; |
4332 4343 | if (nrowsToDelete > 0) |
4333 4344 | { |
4334 4345 | rownr_t rownr = ddiCols.nrow()-1; |
4335 4346 | Vector<rownr_t> rowsToDelete(nrowsToDelete); |
4336 4347 | for(rownr_t idx=0; idx<nrowsToDelete; idx++) |
4337 4348 | { |
4338 4349 | rowsToDelete(idx) = rownr; |
4339 4350 | rownr -= 1; |
4340 4351 | } |
4904 4915 | * getInputNumberOfChannels()). |
4905 4916 | * |
4906 4917 | * @throws AipsError if combinespws is enabled and the input MS of the |
4907 4918 | * current configuration has different number of channels for |
4908 4919 | * different SPWs |
4909 4920 | */ |
4910 4921 | void MSTransformManager::checkSPWChannelsKnownLimitation() |
4911 4922 | { |
4912 4923 | if (not combinespws_p) |
4913 4924 | return; |
4914 - | |
4925 + | |
4915 4926 | auto nSpws = inputMs_p->spectralWindow().nrow(); |
4916 4927 | if (1 >= nSpws or numOfInpChanMap_p.empty() or numOfSelChanMap_p.empty()) |
4917 4928 | return; |
4918 4929 | |
4919 4930 | auto firstNum = numOfSelChanMap_p.begin()->second; |
4920 4931 | auto diff = std::find_if(numOfSelChanMap_p.begin(), numOfSelChanMap_p.end(), |
4921 4932 | [&firstNum](const std::pair<casacore::uInt,casacore::uInt> &other) { |
4922 4933 | return firstNum != other.second; }); |
4923 4934 | |
4924 - | |
4935 + | |
4925 4936 | if (numOfSelChanMap_p.end() != diff) { |
4926 4937 | auto otherNum = diff->second; |
4927 4938 | throw AipsError("Currently the option 'combinespws' is only supported when the number " |
4928 4939 | "of channels is the same for all the spw's selected. One of the SPWs " |
4929 4940 | "selected has " + std::to_string(firstNum) + " channels, but another " |
4930 4941 | "selected SPW has " + std::to_string(otherNum) + " channels."); |
4931 4942 | } |
4932 4943 | } |
4933 4944 | |
4934 4945 | /** |
5704 5715 | // Polarization Averaging VI |
5705 5716 | else if (polAverage_p) { |
5706 5717 | visibilityIterator_p = new vi::VisibilityIterator2(vi::PolAverageVi2Factory(polAverageConfig_p, selectedInputMs_p, |
5707 5718 | vi::SortColumns(sortColumns_p, false), timeBin_p, isWritable)); |
5708 5719 | } |
5709 5720 | // VI interpolating pointing directions |
5710 5721 | else if (pointingsInterpolation_p) { |
5711 5722 | visibilityIterator_p = new vi::VisibilityIterator2(vi::PointingInterpolationVi2Factory(pointingsInterpolationConfig_p, selectedInputMs_p, |
5712 5723 | vi::SortColumns(sortColumns_p, false), timeBin_p, isWritable)); |
5713 5724 | } |
5725 + | // Offline ATM correction |
5726 + | else if (doAtmCor_p) { |
5727 + | visibilityIterator_p = new vi::VisibilityIterator2( |
5728 + | vi::SDAtmosphereCorrectionVi2Factory( |
5729 + | atmCorConfig_p, selectedInputMs_p, vi::SortColumns(sortColumns_p, false), timeBin_p, isWritable |
5730 + | ) |
5731 + | ); |
5732 + | } |
5714 5733 | // Plain VI |
5715 5734 | else |
5716 5735 | { |
5717 5736 | visibilityIterator_p = new vi::VisibilityIterator2(*selectedInputMs_p,vi::SortColumns(sortColumns_p, false), |
5718 5737 | isWritable, NULL, timeBin_p); |
5719 5738 | } |
5720 5739 | |
5721 5740 | if (timeAverage_p) visibilityIterator_p->setWeightScaling(vi::WeightScaling::generateUnityWeightScaling()); |
5722 5741 | if (channelSelector_p != NULL) visibilityIterator_p->setFrequencySelection(*channelSelector_p); |
5723 5742 | |