Commits

Takahiro Tsutsumi authored 0055a2fd785 Merge
Merge branch 'master' into CAS-13317

Fixed the conflicts: casatests/stakeholder/test_stk_alma_pipeline_imaging.py

casa5/code/mstransform/MSTransform/MSTransformManager.cc

Modified
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 #include <mstransform/MSTransform/MSTransformManager.h>
24 24
25 25 #include <mstransform/TVI/PolAverageTVI.h>
26 26 #include <mstransform/TVI/PointingInterpolationTVI.h>
27 +#include <mstransform/TVI/SDAtmosphereCorrectionTVI.h>
27 28
28 29 #include <limits>
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
4313 4324 ddiCols.lagId().put(rowIndex,ddiCols.lagId()(0));
4314 4325 }
4315 4326 }
4316 4327
4317 4328 // Set SPW id separately
4318 4329 ddiCols.spectralWindowId().put(rowIndex,ddiStart_p+spw_i);
4319 4330
4320 4331 rowIndex += 1;
4321 4332 }
4322 4333
4323 - // Delete the old rows
4334 + // Delete the old rows
4324 4335 rownr_t nrowsToDelete = ddiCols.nrow()-nspws_p;
4325 4336 if (nrowsToDelete > 0)
4326 4337 {
4327 4338 rownr_t rownr = ddiCols.nrow()-1;
4328 4339 Vector<rownr_t> rowsToDelete(nrowsToDelete);
4329 4340 for(rownr_t idx=0; idx<nrowsToDelete; idx++)
4330 4341 {
4331 4342 rowsToDelete(idx) = rownr;
4332 4343 rownr -= 1;
4333 4344 }
4897 4908 * getInputNumberOfChannels()).
4898 4909 *
4899 4910 * @throws AipsError if combinespws is enabled and the input MS of the
4900 4911 * current configuration has different number of channels for
4901 4912 * different SPWs
4902 4913 */
4903 4914 void MSTransformManager::checkSPWChannelsKnownLimitation()
4904 4915 {
4905 4916 if (not combinespws_p)
4906 4917 return;
4907 -
4918 +
4908 4919 auto nSpws = inputMs_p->spectralWindow().nrow();
4909 4920 if (1 >= nSpws or numOfInpChanMap_p.empty() or numOfSelChanMap_p.empty())
4910 4921 return;
4911 4922
4912 4923 auto firstNum = numOfSelChanMap_p.begin()->second;
4913 4924 auto diff = std::find_if(numOfSelChanMap_p.begin(), numOfSelChanMap_p.end(),
4914 4925 [&firstNum](const std::pair<casacore::uInt,casacore::uInt> &other) {
4915 4926 return firstNum != other.second; });
4916 4927
4917 -
4928 +
4918 4929 if (numOfSelChanMap_p.end() != diff) {
4919 4930 auto otherNum = diff->second;
4920 4931 throw AipsError("Currently the option 'combinespws' is only supported when the number "
4921 4932 "of channels is the same for all the spw's selected. One of the SPWs "
4922 4933 "selected has " + std::to_string(firstNum) + " channels, but another "
4923 4934 "selected SPW has " + std::to_string(otherNum) + " channels.");
4924 4935 }
4925 4936 }
4926 4937
4927 4938 /**
5697 5708 // Polarization Averaging VI
5698 5709 else if (polAverage_p) {
5699 5710 visibilityIterator_p = new vi::VisibilityIterator2(vi::PolAverageVi2Factory(polAverageConfig_p, selectedInputMs_p,
5700 5711 vi::SortColumns(sortColumns_p, false), timeBin_p, isWritable));
5701 5712 }
5702 5713 // VI interpolating pointing directions
5703 5714 else if (pointingsInterpolation_p) {
5704 5715 visibilityIterator_p = new vi::VisibilityIterator2(vi::PointingInterpolationVi2Factory(pointingsInterpolationConfig_p, selectedInputMs_p,
5705 5716 vi::SortColumns(sortColumns_p, false), timeBin_p, isWritable));
5706 5717 }
5718 + // Offline ATM correction
5719 + else if (doAtmCor_p) {
5720 + visibilityIterator_p = new vi::VisibilityIterator2(
5721 + vi::SDAtmosphereCorrectionVi2Factory(
5722 + atmCorConfig_p, selectedInputMs_p, vi::SortColumns(sortColumns_p, false), timeBin_p, isWritable
5723 + )
5724 + );
5725 + }
5707 5726 // Plain VI
5708 5727 else
5709 5728 {
5710 5729 visibilityIterator_p = new vi::VisibilityIterator2(*selectedInputMs_p,vi::SortColumns(sortColumns_p, false),
5711 5730 isWritable, NULL, timeBin_p);
5712 5731 }
5713 5732
5714 5733 if (timeAverage_p) visibilityIterator_p->setWeightScaling(vi::WeightScaling::generateUnityWeightScaling());
5715 5734 if (channelSelector_p != NULL) visibilityIterator_p->setFrequencySelection(*channelSelector_p);
5716 5735

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

Add shortcut