Commits
817 817 | casacore::MSFieldColumns msfc(itsMS->field()); |
818 818 | casacore::MDirection d; |
819 819 | if(colname=="DELAY_DIR"){ |
820 820 | d = msfc.delayDirMeas(fieldid, time); |
821 821 | } |
822 822 | else if(colname=="PHASE_DIR"){ |
823 823 | d = msfc.phaseDirMeas(fieldid, time); |
824 824 | } |
825 825 | else if(colname=="REFERENCE_DIR"){ |
826 826 | d = msfc.referenceDirMeas(fieldid, time); |
827 - | } |
827 + | } |
828 828 | else if(colname=="EPHEMERIS_DIR"){ |
829 829 | d = msfc.ephemerisDirMeas(fieldid, time); |
830 830 | } |
831 831 | else{ |
832 832 | *itsLog << LogIO::SEVERE |
833 833 | << "Illegal FIELD direction column name: " << dircolname |
834 834 | << LogIO::POST; |
835 835 | } |
836 836 | String f(format); |
837 837 | f.downcase(); |
2310 2310 | Table::relinquishAutoLocks(True); |
2311 2311 | RETHROW(x); |
2312 2312 | } |
2313 2313 | Table::relinquishAutoLocks(True); |
2314 2314 | return retval; |
2315 2315 | } |
2316 2316 | |
2317 2317 | bool |
2318 2318 | ms::selectinit(const long datadescid, const bool resetsel) |
2319 2319 | { |
2320 - | *itsLog << LogOrigin("ms", "selectinit"); |
2321 - | Bool retval = false; |
2322 - | try { |
2323 - | Vector<Int> ddId(1, datadescid); |
2324 - | if(!detached()){ |
2325 - | Int n=ddId.nelements(); |
2326 - | if (n>0 && min(ddId)<0 && !resetsel) { |
2327 - | *itsLog << "The data description id must be a list of " |
2328 - | "positive integers" << LogIO::EXCEPTION; |
2329 - | } |
2330 - | if (resetsel) { |
2331 - | retval = reset(); |
2332 - | initSel_p = false; |
2333 - | } else { |
2334 - | String selDDID = String::toString(datadescid); |
2335 - | String ddidTaql = "DATA_DESC_ID IN [" + selDDID + "]"; |
2336 - | Record taqlSelRec(Record::Variable); |
2337 - | taqlSelRec.define("taql", ddidTaql); |
2338 - | std::unique_ptr<::casac::record> casacRec(fromRecord(taqlSelRec)); |
2339 - | try { |
2340 - | // test it first, can't revert MSSelection selection |
2341 - | retval = doMSSelection(*casacRec, true); // onlyparse=true |
2342 - | if (retval) |
2343 - | retval = doMSSelection(*casacRec); // onlyparse=false |
2344 - | initSel_p = retval; |
2345 - | } catch (const AipsError &x) { // MSSelectionNullSelection |
2346 - | String mesg = "selectinit failed for datadescid " + selDDID; |
2347 - | *itsLog << LogOrigin("ms", "selectinit"); |
2348 - | *itsLog << LogIO::WARN << mesg << LogIO::POST; |
2349 - | retval = initSel_p = false; |
2350 - | } |
2351 - | } |
2352 - | } |
2353 - | } catch (AipsError x) { |
2354 - | *itsLog << LogOrigin("ms", "selectinit"); |
2355 - | *itsLog << LogIO::SEVERE << "Exception Reported: " << x.getMesg() << LogIO::POST; |
2356 - | Table::relinquishAutoLocks(true); |
2357 - | RETHROW(x); |
2358 - | } |
2359 - | Table::relinquishAutoLocks(true); |
2360 - | return retval; |
2320 + | *itsLog << LogOrigin("ms", "selectinit"); |
2321 + | Bool retval = false; |
2322 + | try { |
2323 + | Vector<Int> ddId(1, datadescid); |
2324 + | if(!detached()){ |
2325 + | Int n=ddId.nelements(); |
2326 + | if (n>0 && min(ddId)<0 && !resetsel) { |
2327 + | *itsLog |
2328 + | << "The data description id must be a list of positive integers" |
2329 + | << LogIO::EXCEPTION; |
2330 + | } |
2331 + | if (resetsel) { |
2332 + | retval = reset(); |
2333 + | initSel_p = false; |
2334 + | } else { |
2335 + | String selDDID = String::toString(datadescid); |
2336 + | String ddidTaql = "DATA_DESC_ID IN [" + selDDID + "]"; |
2337 + | Record taqlSelRec(Record::Variable); |
2338 + | taqlSelRec.define("taql", ddidTaql); |
2339 + | std::unique_ptr<::casac::record> casacRec(fromRecord(taqlSelRec)); |
2340 + | try { |
2341 + | // test it first, can't revert MSSelection selection |
2342 + | retval = doMSSelection(*casacRec, true); // onlyparse=true |
2343 + | if (retval) |
2344 + | retval = doMSSelection(*casacRec); // onlyparse=false |
2345 + | initSel_p = retval; |
2346 + | } catch (const AipsError &x) { // MSSelectionNullSelection |
2347 + | String mesg = "selectinit failed for datadescid " + selDDID; |
2348 + | *itsLog << LogOrigin("ms", "selectinit"); |
2349 + | *itsLog << LogIO::WARN << mesg << LogIO::POST; |
2350 + | retval = initSel_p = false; |
2351 + | } |
2352 + | } |
2353 + | } |
2354 + | } catch (AipsError x) { |
2355 + | *itsLog << LogOrigin("ms", "selectinit"); |
2356 + | *itsLog << LogIO::SEVERE << "Exception Reported: " << x.getMesg() << LogIO::POST; |
2357 + | Table::relinquishAutoLocks(true); |
2358 + | RETHROW(x); |
2359 + | } |
2360 + | Table::relinquishAutoLocks(true); |
2361 + | return retval; |
2361 2362 | } |
2362 2363 | |
2363 2364 | bool |
2364 2365 | ms::selectold(const ::casac::record& items) |
2365 2366 | { |
2366 2367 | *itsLog << LogOrigin("ms", "selectold"); |
2367 2368 | *itsLog << LogIO::WARN |
2368 2369 | << "The use of ms::selectold() is deprecated; this function " |
2369 2370 | << "will be removed from CASA in a future version. " |
2370 2371 | << "Calls to ms::selectold() should be replaced by calls to " |
2382 2383 | Table::relinquishAutoLocks(True); |
2383 2384 | RETHROW(x); |
2384 2385 | } |
2385 2386 | Table::relinquishAutoLocks(True); |
2386 2387 | return retval; |
2387 2388 | } |
2388 2389 | |
2389 2390 | bool |
2390 2391 | ms::select(const ::casac::record& items) |
2391 2392 | { |
2392 - | *itsLog << LogOrigin("ms", "select"); |
2393 2393 | // Use selecttaql and doMSSelection for these selections |
2394 - | Bool retval = true; |
2395 - | try { |
2396 - | if(!detached()){ |
2394 + | *itsLog << LogOrigin("ms", "select"); |
2395 + | Bool retval = true; |
2396 + | try { |
2397 + | if(!detached()){ |
2397 2398 | if (checkinit()) { |
2398 2399 | *itsLog << LogOrigin("ms", "select"); |
2399 2400 | std::unique_ptr<Record> selRecord(toRecord(items)); |
2400 2401 | for (uInt field=0; field < selRecord->nfields(); ++field) { |
2401 2402 | String fieldStr = selRecord->name(field); |
2402 2403 | fieldStr.upcase(); |
2403 2404 | if (fieldStr=="ANTENNA1" || |
2404 2405 | fieldStr=="ANTENNA2" || |
2405 2406 | fieldStr=="ARRAY_ID" || |
2406 2407 | fieldStr=="FEED1" || |
2481 2482 | String column = MS::columnName(MS::TIME); |
2482 2483 | Vector<Double> time = selRecord->asArrayDouble(RecordFieldId(field)); |
2483 2484 | MeasurementSet selms = (*itsSelectedMS)((itsSelectedMS->col(column)).in(time)); |
2484 2485 | *itsSelectedMS = selms; |
2485 2486 | if (nrow(true)==0) { |
2486 2487 | *itsLog << LogIO::WARN << "Zero rows selected; input precision may be too small to select times exactly. Reset selection and select time range with {'time':[start,stop]} instead" << LogIO::POST; |
2487 2488 | } |
2488 2489 | } |
2489 2490 | else |
2490 2491 | *itsLog << LogIO::WARN << "Unrecognized field in input ignored: "+fieldStr << LogIO::POST; |
2491 - | |
2492 - | } |
2493 - | } |
2494 - | } |
2495 - | } catch (AipsError x) { |
2496 - | Table::relinquishAutoLocks(true); |
2497 - | RETHROW(x); |
2498 - | } |
2499 - | Table::relinquishAutoLocks(true); |
2500 - | return retval; |
2492 + | } |
2493 + | } |
2494 + | } |
2495 + | } catch (AipsError x) { |
2496 + | Table::relinquishAutoLocks(true); |
2497 + | RETHROW(x); |
2498 + | } |
2499 + | Table::relinquishAutoLocks(true); |
2500 + | return retval; |
2501 2501 | } |
2502 2502 | |
2503 2503 | bool |
2504 2504 | ms::selecttaqlold(const std::string& msselect) |
2505 2505 | { |
2506 2506 | *itsLog << LogOrigin("ms", "selecttaqlold"); |
2507 2507 | *itsLog << LogIO::WARN |
2508 2508 | << "The use of ms::selecttaqlold() is deprecated; this function " |
2509 2509 | << "will be removed from CASA in a future version. " |
2510 2510 | << "Calls to ms::selecttaqlold() should be replaced by calls to " |
2530 2530 | *itsLog << LogOrigin("ms", "selecttaql"); |
2531 2531 | Bool retval(false); |
2532 2532 | try { |
2533 2533 | if(!detached()) { |
2534 2534 | Record taqlSelRec(Record::Variable); |
2535 2535 | String taqlExpr = String::toString(taqlstr); |
2536 2536 | taqlSelRec.define("taql", taqlExpr); |
2537 2537 | std::unique_ptr<::casac::record> casacRec(fromRecord(taqlSelRec)); |
2538 2538 | retval = doMSSelection(*casacRec); |
2539 2539 | } |
2540 - | } catch (AipsError x) { |
2541 - | *itsLog << LogOrigin("ms", "selecttaql"); |
2542 - | if (x.getMesg().contains("zero rows")) { |
2543 - | *itsLog << LogIO::WARN << x.getMesg() << LogIO::POST; |
2544 - | } else { |
2545 - | *itsLog << LogIO::SEVERE << "Exception Reported: " << x.getMesg() << LogIO::POST; |
2546 - | Table::relinquishAutoLocks(true); |
2547 - | RETHROW(x); |
2548 - | } |
2549 - | } |
2550 - | Table::relinquishAutoLocks(true); |
2551 - | return retval; |
2540 + | } |
2541 + | catch (AipsError x) { |
2542 + | *itsLog << LogOrigin("ms", "selecttaql"); |
2543 + | if (x.getMesg().contains("zero rows")) { |
2544 + | *itsLog << LogIO::WARN << x.getMesg() << LogIO::POST; |
2545 + | } else { |
2546 + | *itsLog << LogIO::SEVERE << "Exception Reported: " << x.getMesg() << LogIO::POST; |
2547 + | Table::relinquishAutoLocks(true); |
2548 + | RETHROW(x); |
2549 + | } |
2550 + | } |
2551 + | |
2552 + | Table::relinquishAutoLocks(true); |
2553 + | return retval; |
2552 2554 | } |
2553 2555 | |
2554 2556 | bool |
2555 2557 | ms::selectchannelold(const long nchan, const long start, const long width, |
2556 2558 | const long inc) |
2557 2559 | { |
2558 2560 | *itsLog << LogOrigin("ms", "selectchannelold"); |
2559 2561 | *itsLog << LogIO::WARN |
2560 2562 | << "The use of ms::selectchannelold() is deprecated; this function " |
2561 2563 | << "will be removed from CASA in a future version. " |
6970 6972 | String spwExpr, timeExpr, fieldExpr, baselineExpr, scanExpr, scanIntentExpr, |
6971 6973 | polnExpr, uvDistExpr, obsExpr, arrayExpr, taQLExpr; |
6972 6974 | Int nFields = casaRec->nfields(); |
6973 6975 | |
6974 6976 | for (Int i=0; i<nFields; i++) |
6975 6977 | { |
6976 6978 | auto name = casaRec->name(i); |
6977 6979 | if (name == "spw") { |
6978 6980 | spwExpr = casaRec->asString(RecordFieldId(i)); |
6979 6981 | } |
6980 - | else if (name == "time") { |
6982 + | else if (name == "time") { |
6981 6983 | timeExpr = casaRec->asString(RecordFieldId(i)); |
6982 6984 | } |
6983 - | else if (name == "field") { |
6985 + | else if (name == "field") { |
6984 6986 | fieldExpr = casaRec->asString(RecordFieldId(i)); |
6985 6987 | } |
6986 - | else if (name == "baseline") { |
6988 + | else if (name == "baseline") { |
6987 6989 | baselineExpr = casaRec->asString(RecordFieldId(i)); |
6988 6990 | } |
6989 - | else if (name == "antenna") { |
6991 + | else if (name == "antenna") { |
6990 6992 | baselineExpr = casaRec->asString(RecordFieldId(i)); |
6991 6993 | } |
6992 - | else if (name == "scan") { |
6994 + | else if (name == "scan") { |
6993 6995 | scanExpr = casaRec->asString(RecordFieldId(i)); |
6994 6996 | } |
6995 - | else if (name == "scanintent") { |
6997 + | else if (name == "scanintent") { |
6996 6998 | scanIntentExpr = casaRec->asString(RecordFieldId(i)); |
6997 6999 | } |
6998 7000 | else if (name == "state") { |
6999 7001 | scanIntentExpr = casaRec->asString(RecordFieldId(i)); |
7000 7002 | } |
7001 7003 | else if (name == "polarization") { |
7002 7004 | polnExpr = casaRec->asString(RecordFieldId(i)); |
7003 7005 | } |
7004 7006 | else if (name == "uvdist") { |
7005 7007 | uvDistExpr = casaRec->asString(RecordFieldId(i)); |