Changeset 209
- Timestamp:
- 01/18/05 17:31:59 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MathUtils.cc
r176 r209 40 40 using namespace casa; 41 41 42 43 44 float mathutil::statistics (const String& which, const MaskedArray<Float>& data) 42 float mathutil::statistics(const String& which, 43 const MaskedArray<Float>& data) 45 44 { 46 45 String str(which); … … 71 70 72 71 73 void mathutil::replaceMaskByZero 72 void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask) 74 73 { 75 74 for (uInt i=0; i<data.nelements(); i++) { -
trunk/src/MathUtils2.cc
r137 r209 37 37 38 38 using namespace casa; 39 //using namespace asap;40 39 41 40 template <class T> 42 41 void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask, 43 const Vector<T>& in, const Vector<Bool>& mask,44 Bool relaxed, Bool ignoreOther) {42 const Vector<T>& in, const Vector<Bool>& mask, 43 Bool relaxed, Bool ignoreOther) { 45 44 46 45 Vector< Vector<T> > weights(8); -
trunk/src/SDAsciiWriter.cc
r198 r209 30 30 //#--------------------------------------------------------------------------- 31 31 32 #include "SDAsciiWriter.h"33 34 32 #include <casa/aips.h> 35 33 #include <casa/Arrays/Array.h> … … 40 38 #include <casa/Quanta/MVAngle.h> 41 39 40 41 #include <casa/iostream.h> 42 #include <casa/fstream.h> 43 42 44 #include <coordinates/Coordinates/CoordinateUtil.h> 43 45 #include <coordinates/Coordinates/SpectralCoordinate.h> … … 51 53 #include <tables/Tables/ArrayColumn.h> 52 54 55 #include "Definitions.h" 53 56 #include "SDContainer.h" 54 57 #include "SDMemTable.h" 55 56 #include <casa/iostream.h> 57 #include <casa/fstream.h> 58 58 #include "SDAsciiWriter.h" 59 59 60 60 using namespace casa; … … 69 69 70 70 71 Bool SDAsciiWriter::write(const SDMemTable& sdTable, 71 Bool SDAsciiWriter::write(const SDMemTable& sdTable, const String& fileName) 72 72 { 73 73 … … 86 86 ROScalarColumn<String> src(tab, "SRCNAME"); 87 87 88 // Axes (should be in header)89 90 const uInt beamAxis = 0;91 const uInt ifAxis = 1;92 const uInt polAxis = 2;93 const uInt chanAxis = 3;94 95 88 // Temps 96 89 … … 109 102 // Write header 110 103 111 of << "row beam IF pol source longitude latitude time nchan spectrum mask" << endl; 112 104 of << "row beam IF pol source longitude latitude time nchan spectrum mask" 105 << endl; 106 113 107 // Loop over rows 114 108 … … 131 125 // Iterate through data in this row by spectra 132 126 133 ReadOnlyVectorIterator<Float> itData(values, chanAxis);134 ReadOnlyVectorIterator<Bool> itMask(mask, chanAxis);127 ReadOnlyVectorIterator<Float> itData(values, asap::ChanAxis); 128 ReadOnlyVectorIterator<Bool> itMask(mask, asap::ChanAxis); 135 129 while (!itData.pastEnd()) { 136 130 const IPosition& pos = itData.pos(); … … 144 138 145 139 dir.get(iRow, whichDir); 146 posDir(0) = pos( beamAxis);140 posDir(0) = pos(asap::BeamAxis); 147 141 posDir(1) = 0; 148 142 lonLat[0] = whichDir(posDir); 149 143 // 150 posDir(0) = pos( beamAxis);144 posDir(0) = pos(asap::BeamAxis); 151 145 posDir(1) = 1; 152 146 lonLat[1] = whichDir(posDir); 153 147 154 // Write. This formats the vectors as [,,,,] which we probably don't want. 155 156 of << iRow << " " << pos(beamAxis) << " " << pos(ifAxis) << " " << pos(polAxis) << " " << 157 src(iRow) << " " << formatDirection(lonLat) << " " << dTmp << " " << 158 itData.vector().nelements() << " " << itData.vector() << " " << itMask.vector() << endl; 148 // Write. This formats the vectors as [,,,,] which we 149 // probably don't want. 150 uInt ba = uInt(asap::BeamAxis); 151 uInt ia = uInt(asap::IFAxis); 152 uInt pa = uInt(asap::PolAxis); 153 154 of << iRow << " " << pos(ba) << " " 155 << pos(ia) << " " << pos(pa) << " " 156 << src(iRow) << " " << formatDirection(lonLat) << " " 157 << dTmp << " " 158 << itData.vector().nelements() << " " << itData.vector() 159 << " " << itMask.vector() << endl; 159 160 160 161 // Next spectrum … … 172 173 173 174 174 Int SDAsciiWriter::convertStokes 175 Int SDAsciiWriter::convertStokes(Int val) 175 176 { 176 177 Stokes::StokesTypes stokes = Stokes::RR; … … 191 192 192 193 193 String SDAsciiWriter::formatDirection 194 String SDAsciiWriter::formatDirection(const Vector<Double>& lonLat) 194 195 { 195 196 MVAngle x1(lonLat(0)); -
trunk/src/SDAsciiWriter.h
r198 r209 53 53 54 54 private: 55 casa::Int convertStokes 56 casa::String formatDirection 55 casa::Int convertStokes(casa::Int val); 56 casa::String formatDirection(const casa::Vector<casa::Double>& lonLat); 57 57 }; 58 58 -
trunk/src/SDFITSImageWriter.cc
r197 r209 56 56 #include <tables/Tables/ArrayColumn.h> 57 57 58 #include "Definitions.h" 58 59 #include "SDContainer.h" 59 60 #include "SDMemTable.h" … … 100 101 // Axes (should be in header) 101 102 102 const uInt beamAxis = 0;103 const uInt ifAxis = 1;104 const uInt stokesAxis = 2;105 const uInt chanAxis = 3;103 const uInt beamAxis = asap::BeamAxis; 104 const uInt ifAxis = asap::IFAxis; 105 const uInt stokesAxis = asap::PolAxis; 106 const uInt chanAxis = asap::ChanAxis; 106 107 const Unit RAD(String("rad")); 107 108 … … 207 208 // Write out as FITS Image file 208 209 209 210 210 ostringstream oss; 211 oss << "row" << iRow << "_beam" << pos(0) << "_if" << pos(1) << "_pol" << pos(2) << "_" << src(iRow) << ".fits"; 211 oss << "row" << iRow << "_beam" << pos(0) << "_if" 212 << pos(1) << "_pol" << pos(2) << "_" << src(iRow) << ".fits"; 212 213 String fileName; 213 214 if (rootName.length()>0) { … … 216 217 fileName = String(oss); 217 218 } 218 if (verbose) cerr << "Writing row " << iRow << " into file " << fileName << endl; 219 // 220 Bool ok = ImageFITSConverter::ImageToFITS (errMsg, tIm, fileName, maxMem, preferVelocity, 221 opticalVelocity, bitPix, minPix, maxPix, overWrite, 222 degLast, reallyVerbose); 219 if (verbose) cerr << "Writing row " << iRow 220 << " into file " << fileName << endl; 221 // 222 Bool ok = ImageFITSConverter::ImageToFITS(errMsg, tIm, fileName, 223 maxMem, preferVelocity, 224 opticalVelocity, bitPix, 225 minPix, maxPix, overWrite, 226 degLast, reallyVerbose); 223 227 if (!ok) { 224 228 cerr << "Error writing fits - " << errMsg << endl; … … 240 244 241 245 242 Int SDFITSImageWriter::convertStokes 246 Int SDFITSImageWriter::convertStokes(Int val) 243 247 { 244 248 Stokes::StokesTypes stokes = Stokes::RR; -
trunk/src/SDFITSImageWriter.h
r191 r209 52 52 53 53 private: 54 casa::Int convertStokes 54 casa::Int convertStokes(casa::Int val); 55 55 }; 56 56 -
trunk/src/SDMath.cc
r185 r209 59 59 60 60 #include "MathUtils.h" 61 #include "Definitions.h" 61 62 #include "SDContainer.h" 62 63 #include "SDMemTable.h" … … 109 110 // Setup 110 111 111 const uInt axis = 3;// Spectral axis112 const uInt axis = asap::ChanAxis; // Spectral axis 112 113 IPosition shp = in[0]->rowAsMaskedArray(0).shape(); // Must not change 113 114 Array<Float> arr(shp); … … 479 480 // Loop over rows and bin along channel axis 480 481 481 const uInt axis = 3;482 const uInt axis = asap::ChanAxis; 482 483 for (uInt i=0; i < in.nRow(); ++i) { 483 484 SDContainer sc = in.getSDContainer(i); … … 588 589 589 590 const uInt nRows = in.nRow(); 590 const uInt polAxis = 2; // Polarization axis591 const uInt chanAxis = 3; // Spectrum axis591 const uInt polAxis = asap::PolAxis; // Polarization axis 592 const uInt chanAxis = asap::ChanAxis; // Spectrum axis 592 593 593 594 // Create output Table and reshape number of polarizations … … 719 720 // Number of channels 720 721 721 const uInt chanAxis = 3;// Spectral axis722 const uInt chanAxis = asap::ChanAxis; // Spectral axis 722 723 SDHeader sh = in.getSDHeader(); 723 724 const uInt nChan = sh.nchan; -
trunk/src/SDMathWrapper.cc
r178 r209 52 52 // 53 53 SDMath sdm; 54 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor), Bool(doAll), what); 54 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor), 55 Bool(doAll), what); 55 56 *pIn = *pOut; 56 57 delete pOut; … … 63 64 const uInt what = 0; 64 65 SDMath sdm; 65 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(factor), Bool(doAll), what)); 66 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, 67 Float(factor), 68 Bool(doAll), what)); 66 69 } 67 70 … … 74 77 // 75 78 SDMath sdm; 76 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset), Bool(doAll), what); 79 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset), 80 Bool(doAll), what); 77 81 *pIn = *pOut; 78 82 delete pOut; … … 85 89 const uInt what = 1; 86 90 SDMath sdm; 87 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset), Bool(doAll), what)); 91 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset), 92 Bool(doAll), what)); 88 93 } 89 94 90 95 91 void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll) 96 void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in, 97 const std::string& kernel, float width, 98 bool doAll) 92 99 { 93 100 SDMemTable* pIn = in.getPtr(); 94 101 SDMath sdm; 95 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll)); 102 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel), 103 Float(width), Bool(doAll)); 96 104 *pIn = *pOut; 97 105 delete pOut; … … 99 107 100 108 101 SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in, const std::string& kernel, 109 SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in, 110 const std::string& kernel, 102 111 float width, bool doAll) 103 112 { 104 113 const CountedPtr<SDMemTable>& pIn = in.getCP(); 105 114 SDMath sdm; 106 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll))); 115 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel), 116 Float(width), Bool(doAll))); 107 117 } 108 118 … … 127 137 128 138 129 void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask) 139 void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, 140 const std::vector<bool>& mask) 130 141 { 131 142 SDMemTable* pIn = in.getPtr(); … … 136 147 } 137 148 138 SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask) 149 SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, 150 const std::vector<bool>& mask) 139 151 140 152 { -
trunk/src/SDMathWrapper.h
r178 r209 57 57 58 58 // Smooth 59 void smoothInSitu (SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll); 60 SDMemTableWrapper smooth (const SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll); 59 void smoothInSitu(SDMemTableWrapper& in, const std::string& kernel, 60 float width, bool doAll); 61 SDMemTableWrapper smooth(const SDMemTableWrapper& in, 62 const std::string& kernel, float width, bool doAll); 61 63 62 64 // Bin up 63 void binInSitu 65 void binInSitu(SDMemTableWrapper& in, int width); 64 66 SDMemTableWrapper bin(const SDMemTableWrapper& in, int width); 65 67 66 68 // Average in time 67 SDMemTableWrapper average 68 69 69 SDMemTableWrapper average(boost::python::tuple tpl, 70 const std::vector<bool>& mask, 71 bool scanAv, const std::string& wt); 70 72 71 73 // Average polarizations 72 void averagePolInSitu (SDMemTableWrapper& in, const std::vector<bool>& mask); 73 SDMemTableWrapper averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask); 74 void averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask); 75 SDMemTableWrapper averagePol(const SDMemTableWrapper& in, 76 const std::vector<bool>& mask); 74 77 75 78 // Statistics
Note:
See TracChangeset
for help on using the changeset viewer.