Line data Source code
1 : #include <casacore/casa/BasicSL/String.h> 2 : #include <casacore/casa/Arrays/Array.h> 3 : #include <casacore/casa/Arrays/ArrayMath.h> 4 : #include <casacore/casa/Arrays/Array.h> 5 : #include <casacore/lattices/Lattices/ArrayLattice.h> 6 : #include <casacore/lattices/Lattices/PagedArray.h> 7 : #include <casacore/lattices/LEL/LatticeExpr.h> 8 : #include <casacore/lattices/LEL/LatticeExprNode.h> 9 : #include <casacore/casa/OS/File.h> 10 : #include <casacore/casa/Exceptions/Error.h> 11 : #include <casacore/casa/BasicSL/String.h> 12 : #include <casacore/casa/Utilities/Assert.h> 13 : #include <msvis/MSVis/VisibilityIterator2.h> 14 : #include <msvis/MSVis/VisBuffer2.h> 15 : #include <sstream> 16 : #include <casacore/casa/Logging/LogMessage.h> 17 : #include <casacore/casa/Logging/LogIO.h> 18 : #include <casacore/casa/Logging/LogSink.h> 19 : #include <casacore/ms/MeasurementSets/MeasurementSet.h> 20 : #include <casacore/ms/MeasurementSets/MSColumns.h> 21 : #include <synthesis/MeasurementComponents/WriteMSAlgorithm.h> 22 : #include <casacore/casa/OS/Time.h> 23 : 24 : using namespace casacore; 25 : namespace casa { //# NAMESPACE CASA - BEGIN 26 : extern Applicator applicator; 27 0 : WriteMSAlgorithm::WriteMSAlgorithm() : myName("Test Parallel Write") 28 : { 29 : 30 0 : }; 31 0 : WriteMSAlgorithm::~WriteMSAlgorithm(){ 32 : 33 0 : }; 34 : 35 0 : void WriteMSAlgorithm::get(){ 36 : 37 0 : applicator.get(msName); 38 0 : Vector<Int> tempIds; 39 0 : applicator.get(tempIds); 40 0 : rowids.resize(tempIds.shape()); 41 0 : convertArray(rowids, tempIds); 42 0 : applicator.get(somenumber); 43 0 : }; 44 : 45 0 : void WriteMSAlgorithm::put(){ 46 : ///Looks like there is a bug in Serial transport where the 47 : //Applicator::done() signal seems to be lost 48 : //Manually force sending it here. 49 0 : if(applicator.isSerial()){ 50 0 : doneSig_p=Applicator::DONE; 51 0 : applicator.put(doneSig_p); 52 : } 53 : //applicator.put(status+10); 54 0 : status=10012; 55 0 : cerr << "in writems put " << status << endl; 56 0 : applicator.put(status); 57 : 58 0 : }; 59 : 60 0 : String& WriteMSAlgorithm::name(){ 61 : 62 0 : return myName; 63 : }; 64 : 65 0 : void WriteMSAlgorithm::task(){ 66 : 67 0 : status = 0; 68 0 : Time starttime; 69 : 70 0 : cout <<" In task() " << endl; 71 : 72 : try{ 73 : //open whole ms 74 0 : MeasurementSet ms(msName, TableLock(TableLock::UserNoReadLocking), Table::Update); 75 : ///select on rowids 76 0 : cerr << "rowids " << rowids << endl; 77 0 : MeasurementSet mssel=ms(RowNumbers(rowids)); 78 0 : mssel.lock(); 79 0 : vi::VisibilityIterator2 vi2(mssel, vi::SortColumns(), true); 80 : 81 0 : vi2.originChunks(); 82 0 : vi2.origin(); 83 : 84 0 : vi::VisBuffer2* vb = vi2.getVisBuffer(); 85 : 86 : 87 : 88 : 89 0 : for (vi2.originChunks();vi2.moreChunks();vi2.nextChunk()) { 90 0 : for (vi2.origin();vi2.more();vi2.next()) { 91 0 : Cube<Complex> mod(vb->nCorrelations(), vb->nChannels(), vb->nRows(), Complex(somenumber)); 92 0 : vb->setVisCubeModel(mod); 93 0 : vi2.writeVisModel(vb->visCubeModel()); 94 0 : } 95 : 96 : } 97 : 98 0 : mssel.unlock(); 99 : 100 0 : status=1; 101 : 102 : 103 0 : }catch (AipsError x) { 104 0 : cout << "Exceptionally yours: " << x.getMesg() << endl; 105 0 : } 106 : 107 0 : cout << "seconds elapsed since start: " << starttime.age () << endl; 108 0 : }; 109 : 110 : 111 : 112 : 113 : 114 : } //# NAMESPACE CASA - END 115 :