Changeset 717
- Timestamp:
- 11/17/05 14:37:54 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile
r684 r717 50 50 CCOBJECTS := MathUtils.o \ 51 51 MathUtils2.o \ 52 SDLog.o \ 52 53 SDAttr.o \ 53 54 SDContainer.o \ … … 72 73 python_SDFitTable.o \ 73 74 python_SDLineFinder.o \ 75 python_SDLog.o \ 74 76 python_SD.o 75 77 … … 93 95 SDAsciiWriter.h \ 94 96 SDLineFinder.h \ 97 SDLog.h \ 95 98 python_SD.h 96 99 -
trunk/src/SDAsciiWriter.cc
r496 r717 41 41 #include <casa/iostream.h> 42 42 #include <casa/fstream.h> 43 #include <casa/sstream.h> 43 44 44 45 #include <coordinates/Coordinates/CoordinateUtil.h> … … 96 97 // Open and write header file 97 98 98 99 99 String rootName(fileName); 100 100 if (rootName.length()==0) rootName = String("ascii"); 101 101 { 102 102 String fName = String(rootName) + String("_header.txt"); 103 cout << "Writing header to " << fName << endl;103 pushLog("Writing header to "+fName); 104 104 ofstream of(fName.chars(), ios::trunc); 105 105 std::string summary = sdTable.summary(true); … … 193 193 } 194 194 } 195 // 195 196 196 of.close(); 197 cout << "Wrote " << nRows << " rows into file " << fileName << endl; 198 // 197 ostringstream oss; 198 oss << "Wrote " << nRows << " rows into file " << fileName; 199 pushLog(String(oss)); 199 200 return True; 200 201 } … … 206 207 MVAngle x1(lonLat(0)); 207 208 String s1 = x1.string(MVAngle::TIME, 12); 208 // 209 209 210 MVAngle x2(lonLat(1)); 210 211 String s2 = x2.string(MVAngle::ANGLE, 12); 211 // 212 212 213 String ss = s1 + String(" ") + s2; 213 214 return ss; -
trunk/src/SDAsciiWriter.h
r443 r717 36 36 #include <SDMemTable.h> 37 37 38 #include "SDLog.h" 39 38 40 template<class T> class casa::Vector; 39 41 … … 41 43 namespace asap { 42 44 43 class SDAsciiWriter {45 class SDAsciiWriter : public SDLog { 44 46 public: 45 47 // Constructor -
trunk/src/SDAttr.cc
r507 r717 30 30 //#--------------------------------------------------------------------------- 31 31 32 #include "SDAttr.h"33 32 #include <casa/aips.h> 34 33 #include <casa/Arrays/Vector.h> … … 43 42 #include <scimath/Mathematics/InterpolateArray1D.h> 44 43 44 #include "SDAttr.h" 45 45 46 using namespace casa; 46 47 using namespace asap; 47 48 48 SDAttr::SDAttr 49 SDAttr::SDAttr() 49 50 { 50 51 initData(); … … 53 54 SDAttr::SDAttr(const SDAttr& other) 54 55 { 55 initData(); 56 initData(); // state just private 'static' data 56 57 } 57 58 … … 59 60 { 60 61 if (this != &other) { 61 ; 62 ; // state just private 'static' data 62 63 } 63 64 return *this; … … 68 69 69 70 70 Float SDAttr::diameter 71 Float SDAttr::diameter(Instrument inst) const 71 72 { 72 73 Float D = 1.0; … … 103 104 } 104 105 } 105 //106 106 return D; 107 107 } 108 108 109 Vector<Float> SDAttr::beamEfficiency (Instrument inst, const MEpoch& dateObs, const Vector<Float>& freqs) const110 { 111 112 // Look at date where appropriate 113 109 Vector<Float> SDAttr::beamEfficiency(Instrument inst, const MEpoch& dateObs, 110 const Vector<Float>& freqs) const 111 { 112 113 // Look at date where appropriate 114 114 MVTime t(dateObs.getValue()); 115 115 uInt year = t.year(); 116 // 116 117 117 Vector<Float> facs(freqs.nelements(),1.0); 118 118 switch (inst) { 119 case ATMOPRA: 120 { 121 if (year<2003) { 122 cerr << "There is no beam efficiency data from before 2003 - using 2003 data" << endl; 123 facs = interp (freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_); 124 } else if (year==2003) { 125 cerr << "Using beam efficiency data from 2003" << endl; 126 facs = interp (freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_); 127 } else { 128 cerr << "Using beam efficiency data from 2004" << endl; 129 facs = interp (freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2004Y_); 130 } 131 } 132 break; 133 default: 134 { 135 cerr << "No beam efficiency data for this instrument - assuming unity" << endl; 136 } 137 } 138 // 139 return facs; 140 } 141 142 Vector<Float> SDAttr::apertureEfficiency (Instrument inst, const MEpoch& dateObs, const Vector<Float>& freqs) const 143 { 144 145 // Look at date where appropriate 146 147 MVTime t(dateObs.getValue()); 148 uInt year = t.year(); 149 // 150 Vector<Float> facs(freqs.nelements(),1.0); 151 switch (inst) { 152 case ATMOPRA: 153 { 154 if (year<2004) { 155 cerr << "There is no aperture efficiency data from before 2004 - using 2004 data" << endl; 156 facs = interp (freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_); 157 } else { 158 cerr << "Using aperture efficiency data from 2004" << endl; 159 facs = interp (freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_); 160 } 161 } 162 break; 163 case TIDBINBILLA: 164 { 165 facs = interp (freqs/1.0e9f, TidEtaApX_, TidEtaApY_); 166 } 167 break; 168 default: 169 { 170 cerr << "No aperture efficiency data for this instrument - assuming unity" << endl; 171 } 119 case ATMOPRA: 120 { 121 if (year<2003) { 122 pushLog("There is no beam efficiency data from before 2003" 123 " - using 2003 data"); 124 facs = interp(freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_); 125 } else if (year==2003) { 126 pushLog("Using beam efficiency data from 2003"); 127 facs = interp(freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_); 128 } else { 129 pushLog("Using beam efficiency data from 2004"); 130 facs = interp(freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2004Y_); 131 } 132 } 133 break; 134 default: 135 { 136 pushLog("No beam efficiency data for this instrument - assuming unity"); 137 } 172 138 } 173 139 return facs; 174 140 } 175 141 176 Vector<Float> SDAttr::JyPerK (Instrument inst, const MEpoch& dateObs, const Vector<Float>& freqs) const 177 { 178 179 // FInd what we need 180 181 Vector<Float> etaAp = apertureEfficiency (inst, dateObs, freqs); 182 Float D = diameter(inst); 183 184 // Compute it 185 142 Vector<Float> SDAttr::apertureEfficiency(Instrument inst, 143 const MEpoch& dateObs, 144 const Vector<Float>& freqs) const 145 { 146 147 // Look at date where appropriate 148 MVTime t(dateObs.getValue()); 149 uInt year = t.year(); 150 151 Vector<Float> facs(freqs.nelements(),1.0); 152 switch (inst) { 153 case ATMOPRA: 154 { 155 if (year<2004) { 156 pushLog("There is no aperture efficiency data from before 2004" 157 " - using 2004 data"); 158 facs = interp(freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_); 159 } else { 160 pushLog("Using aperture efficiency data from 2004"); 161 facs = interp(freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_); 162 } 163 } 164 break; 165 case TIDBINBILLA: 166 { 167 facs = interp(freqs/1.0e9f, TidEtaApX_, TidEtaApY_); 168 } 169 break; 170 default: 171 { 172 pushLog("No aperture efficiency data for this instrument" 173 " - assuming unity"); 174 } 175 } 176 return facs; 177 } 178 179 Vector<Float> SDAttr::JyPerK(Instrument inst, const MEpoch& dateObs, 180 const Vector<Float>& freqs) const 181 { 182 183 // Find what we need 184 Vector<Float> etaAp = apertureEfficiency(inst, dateObs, freqs); 185 Float D = diameter(inst); 186 // Compute it 186 187 Vector<Float> facs(freqs.nelements(),1.0); 187 188 for (uInt i=0; i<freqs.nelements(); i++) { 188 facs(i) = SDAttr::findJyPerK(etaAp(i), D);189 facs(i) = SDAttr::findJyPerK(etaAp(i), D); 189 190 } 190 //191 191 return facs; 192 192 } 193 193 194 194 195 Float SDAttr::findJyPerK (Float etaAp, Float D) 196 // 197 // Converts K -> Jy 198 // D in m 199 // 200 { 201 Double kb = QC::k.getValue(Unit(String("erg/K"))); 202 Float gA = C::pi * D * D / 4.0; 203 return (2.0 * 1.0e19 * kb / etaAp / gA); 204 } 205 206 207 Vector<Float> SDAttr::gainElevationPoly (Instrument inst) const 208 { 209 210 // Look at date where appropriate 211 212 switch (inst) { 213 case TIDBINBILLA: 214 { 215 return TidGainElPoly_.copy(); 216 } 217 break; 218 default: 219 { 220 Vector<Float> t; 221 return t.copy(); 222 } 223 } 224 } 225 226 FeedPolType SDAttr::feedPolType (Instrument inst) const 227 { 228 FeedPolType type = UNKNOWNFEED; 229 switch (inst) { 230 case ATMOPRA: 231 case ATPKSMB: 232 case ATPKSHOH: 233 { 234 type = LINEAR; 235 } 236 break; 237 case TIDBINBILLA: 238 { 239 type = CIRCULAR; 240 } 241 break; 242 default: 243 { 244 type = UNKNOWNFEED; 245 } 246 } 247 return type; 248 } 249 250 251 195 Float SDAttr::findJyPerK(Float etaAp, Float D) 196 // 197 // Converts K -> Jy 198 // D in m 199 // 200 { 201 Double kb = QC::k.getValue(Unit(String("erg/K"))); 202 Float gA = C::pi * D * D / 4.0; 203 return (2.0 * 1.0e19 * kb / etaAp / gA); 204 } 205 206 207 Vector<Float> SDAttr::gainElevationPoly(Instrument inst) const 208 { 209 210 // Look at date where appropriate 211 switch (inst) { 212 case TIDBINBILLA: 213 { 214 return TidGainElPoly_.copy(); 215 } 216 break; 217 default: 218 { 219 Vector<Float> t; 220 return t.copy(); 221 } 222 } 223 } 224 225 FeedPolType SDAttr::feedPolType(Instrument inst) const 226 { 227 FeedPolType type = UNKNOWNFEED; 228 switch (inst) { 229 case ATMOPRA: 230 case ATPKSMB: 231 case ATPKSHOH: 232 { 233 type = LINEAR; 234 } 235 break; 236 case TIDBINBILLA: 237 { 238 type = CIRCULAR; 239 } 240 break; 241 default: 242 { 243 type = UNKNOWNFEED; 244 } 245 } 246 return type; 247 } 252 248 253 249 254 250 // Private 255 256 Vector<Float> SDAttr::interp (const Vector<Float>& xOut, const Vector<Float>& xIn, 257 const Vector<Float>& yIn) const 258 { 259 Int method = 1; // Linear 260 Vector<Float> yOut; 261 Vector<Bool> mOut; 262 // 263 Vector<Bool> mIn(xIn.nelements(),True); 264 // 265 InterpolateArray1D<Float,Float>::interpolate(yOut, mOut, xOut, 266 xIn, yIn, mIn, 267 method, True, True); 268 // 269 return yOut; 270 } 271 272 void SDAttr::initData () 273 // 274 // Mopra data from Mopra web page 275 // Tid data from Tid web page 276 // X in GHz 277 // 278 { 279 280 // Beam efficiency 281 251 Vector<Float> SDAttr::interp(const Vector<Float>& xOut, 252 const Vector<Float>& xIn, 253 const Vector<Float>& yIn) const 254 { 255 Int method = 1; // Linear 256 Vector<Float> yOut; 257 Vector<Bool> mOut; 258 259 Vector<Bool> mIn(xIn.nelements(),True); 260 261 InterpolateArray1D<Float,Float>::interpolate(yOut, mOut, xOut, 262 xIn, yIn, mIn, 263 method, True, True); 264 265 return yOut; 266 } 267 268 void SDAttr::initData() 269 // 270 // Mopra data from Mopra web page 271 // Tid data from Tid web page 272 // X in GHz 273 // 274 { 275 276 // Beam efficiency 282 277 MopEtaBeamX_.resize(3); 283 278 MopEtaBeamX_(0) = 86.0; 284 279 MopEtaBeamX_(1) = 100.0; 285 280 MopEtaBeamX_(2) = 115.0; 286 // 281 287 282 MopEtaBeam2003Y_.resize(3); 288 283 MopEtaBeam2003Y_(0) = 0.39; 289 284 MopEtaBeam2003Y_(1) = 0.37; 290 MopEtaBeam2003Y_(2) = 0.37; 291 // 285 MopEtaBeam2003Y_(2) = 0.37; // replicated from (1) 286 292 287 MopEtaBeam2004Y_.resize(3); 293 288 MopEtaBeam2004Y_(0) = 0.49; … … 295 290 MopEtaBeam2004Y_(2) = 0.42; 296 291 297 // Aperture efficiency 298 292 // Aperture efficiency 299 293 MopEtaApX_.resize(2); 300 294 MopEtaApX_(0) = 86.0; 301 295 MopEtaApX_(1) = 115.0; 302 // 296 303 297 MopEtaAp2004Y_.resize(2); 304 298 MopEtaAp2004Y_(0) = 0.33; 305 299 MopEtaAp2004Y_(1) = 0.24; 306 // 300 307 301 TidEtaApX_.resize(2); 308 302 TidEtaApY_.resize(2); … … 312 306 TidEtaApY_(1) = 0.4848; 313 307 314 // Gain elevation correction polynomial coefficients (for elevation in degrees) 308 // Gain elevation correction polynomial coefficients (for elevation 309 // in degrees) 315 310 316 311 TidGainElPoly_.resize(3); … … 324 319 Bool throwIt) 325 320 { 326 String t(instrument); 327 t.upcase(); 328 329 // The strings are what SDReader returns, after cunning interrogation 330 // of station names... :-( 331 Instrument inst = asap::UNKNOWNINST; 332 if (t==String("DSS-43")) { 333 inst = TIDBINBILLA; 334 } else if (t==String("ATPKSMB")) { 335 inst = ATPKSMB; 336 } else if (t==String("ATPKSHOH")) { 337 inst = ATPKSHOH; 338 } else if (t==String("ATMOPRA")) { 339 inst = ATMOPRA; 340 } else if (t==String("CEDUNA")) { 341 inst = CEDUNA; 342 } else if (t==String("HOBART")) { 343 inst = HOBART; 344 } else { 345 if (throwIt) { 346 throw AipsError("Unrecognized instrument - use function scan.set_instrument to set"); 347 } 348 } 349 return inst; 350 } 351 352 321 String t(instrument); 322 t.upcase(); 323 324 // The strings are what SDReader returns, after cunning 325 // interrogation of station names... :-( 326 Instrument inst = asap::UNKNOWNINST; 327 if (t==String("DSS-43")) { 328 inst = TIDBINBILLA; 329 } else if (t==String("ATPKSMB")) { 330 inst = ATPKSMB; 331 } else if (t==String("ATPKSHOH")) { 332 inst = ATPKSHOH; 333 } else if (t==String("ATMOPRA")) { 334 inst = ATMOPRA; 335 } else if (t==String("CEDUNA")) { 336 inst = CEDUNA; 337 } else if (t==String("HOBART")) { 338 inst = HOBART; 339 } else { 340 if (throwIt) { 341 throw AipsError("Unrecognized instrument" 342 " - use function scan.set_instrument to set"); 343 } 344 } 345 return inst; 346 } -
trunk/src/SDAttr.h
r507 r717 32 32 #define SDATTR_H 33 33 34 #include "SDDefs.h"35 34 #include <casa/aips.h> 36 35 #include <measures/Measures/MEpoch.h> 36 #include <casa/Utilities/CountedPtr.h> 37 38 #include "SDLog.h" 39 #include "SDDefs.h" 37 40 38 41 template<class T> class casa::Vector; 39 //class casa::MEpoch;40 41 42 42 43 43 44 namespace asap { 44 45 45 class SDAttr {46 class SDAttr : public SDLog { 46 47 47 48 public: 48 49 49 // Constructor 50 SDAttr(); 50 // Constructor 51 SDAttr(); 52 53 // Destructor 54 ~SDAttr(); 55 56 // Copy Constructor (copy semantics) 57 SDAttr(const SDAttr& other); 58 59 // Assignment (copy semantics) 60 SDAttr &operator=(const SDAttr& other); 61 62 // Telescope diameter(m). Throws exception if unknown. 63 casa::Float diameter(Instrument inst) const; 64 65 // Beam efficiency. Frequency in Hz. Returns 1 if unknown. 66 casa::Vector<casa::Float> 67 beamEfficiency(Instrument instr, const casa::MEpoch& dateObs, 68 const casa::Vector<casa::Float>& freqs) const; 69 70 // Aperture efficiency. Frequency in Hz. Returns 1 if unknown. 71 casa::Vector<casa::Float> 72 apertureEfficiency(Instrument instr, 73 const casa::MEpoch& dateObs, 74 const casa::Vector<casa::Float>& freqs) const; 75 76 // Find factor to convert Jy -> K for this telescope, date of 77 // observation and frequency (Hz) 78 casa::Vector<casa::Float> JyPerK(Instrument instr, 79 const casa::MEpoch& dateObs, 80 const casa::Vector<casa::Float>& freqs) 81 const; 51 82 52 // Destructor 53 ~SDAttr(); 83 // Gain Elevation polynomial correction coefficients (elevation in 84 // degrees) Returns length 0 if not known. 85 casa::Vector<casa::Float> gainElevationPoly(Instrument instr) const; 54 86 55 // Copy Constructor (copy semantics) 56 SDAttr (const SDAttr& other); 57 58 // Assignment (copy semantics) 59 SDAttr &operator=(const SDAttr& other); 60 61 // Telescope diameter (m). Throws exception if unknown. 62 casa::Float diameter (Instrument inst) const; 63 64 // Beam efficiency. Frequency in Hz. Returns 1 if unknown. 65 casa::Vector<casa::Float> beamEfficiency (Instrument instr, const casa::MEpoch& dateObs, 66 const casa::Vector<casa::Float>& freqs) const; 67 68 // Aperture efficiency. Frequency in Hz. Returns 1 if unknown. 69 casa::Vector<casa::Float> apertureEfficiency (Instrument instr, const casa::MEpoch& dateObs, 70 const casa::Vector<casa::Float>& freqs) const; 71 72 // Find factor to convert Jy -> K for this telescope, date of observation and frequency (Hz) 73 casa::Vector<casa::Float> JyPerK (Instrument instr, const casa::MEpoch& dateObs, 74 const casa::Vector<casa::Float>& freqs) const; 75 76 // Gain Elevation polynomial correction coefficients (elevation in degrees) 77 // Returns length 0 if not known. 78 casa::Vector<casa::Float> gainElevationPoly (Instrument instr) const; 79 80 // Find feed polarization type of feeds. In future this needs to come from the data themselves 81 FeedPolType feedPolType (Instrument) const; 82 83 // Helper function to check instrument (antenna) name and give enum 87 // Find feed polarization type of feeds. In future this needs to come 88 // from the data themselves 89 FeedPolType feedPolType(Instrument) const; 90 91 // Helper function to check instrument (antenna) name and give enum 84 92 static Instrument convertInstrument(const casa::String& instrument, 85 93 casa::Bool throwIt); 94 95 // Helper function. Finds factor to convert K -> Jy. Provide 96 // aperture efficiency and dish geometric diameter (m) 97 static casa::Float findJyPerK(casa::Float etaAp, casa::Float D); 98 99 private: 100 101 // Static data 102 casa::Vector<casa::Float> MopEtaBeamX_; // Beam efficiency 103 casa::Vector<casa::Float> MopEtaBeam2003Y_; 104 casa::Vector<casa::Float> MopEtaBeam2004Y_; 86 105 87 // Helper function. Finds factor to convert K -> Jy. Provide aperture efficiency and dish geometric diameter (m) 88 static casa::Float findJyPerK (casa::Float etaAp, casa::Float D); 106 casa::Vector<casa::Float> MopEtaApX_; // Aperture efficiency 107 casa::Vector<casa::Float> MopEtaAp2004Y_; 108 109 casa::Vector<casa::Float> TidEtaApX_; // Aperture efficiency 110 casa::Vector<casa::Float> TidEtaApY_; 111 112 casa::Vector<casa::Float> TidGainElPoly_; // Gain-el correction poly coeffs 113 114 // Init private data 115 void initData(); 116 117 // Linear interpolation 118 casa::Vector<casa::Float> interp(const casa::Vector<casa::Float>& xOut, 119 const casa::Vector<casa::Float>& xIn, 120 const casa::Vector<casa::Float>& yIn) const; 89 121 90 122 91 private:92 93 // Static data94 95 casa::Vector<casa::Float> MopEtaBeamX_; // Beam efficiency96 casa::Vector<casa::Float> MopEtaBeam2003Y_;97 casa::Vector<casa::Float> MopEtaBeam2004Y_;98 //99 casa::Vector<casa::Float> MopEtaApX_; // Aperture efficiency100 casa::Vector<casa::Float> MopEtaAp2004Y_;101 //102 casa::Vector<casa::Float> TidEtaApX_; // Aperture efficiency103 casa::Vector<casa::Float> TidEtaApY_;104 //105 casa::Vector<casa::Float> TidGainElPoly_; // Gain-el correction poly coeffs106 107 // Init private data108 void initData();109 110 // Linear interpolation111 casa::Vector<casa::Float> interp (const casa::Vector<casa::Float>& xOut, const casa::Vector<casa::Float>& xIn,112 const casa::Vector<casa::Float>& yIn) const;113 123 }; 114 124 -
trunk/src/SDFITSImageWriter.cc
r448 r717 120 120 Directory dir(dirName2); 121 121 dir.create(True); 122 cout << "Created directory '" << dirName2 << "' for output files" << endl; 123 124 // Temps 122 ostringstream oss; 123 oss << "Created directory '" << dirName2 << "' for output files"; 124 125 // Temps 125 126 126 127 Vector<Int> whichStokes(1,1); … … 233 234 // Write out as FITS Image file 234 235 235 ostringstream oss ;236 oss << "row" << iRow << "_beam" << pos(0) << "_if"236 ostringstream oss2; 237 oss2 << "row" << iRow << "_beam" << pos(0) << "_if" 237 238 << pos(1) << "_" << stokesName << "_" << srcCol(iRow) << ".fits"; 238 String tS(oss );239 String tS(oss2); 239 240 String fileName = dirName2 + String("/") + tS; 240 if (verbose) cout<< "Writing row " << iRow241 << " into file '" << tS << "'" << endl;241 if (verbose) oss << endl << "Writing row " << iRow 242 << " into file '" << tS << "'"; 242 243 // 243 244 Bool ok = ImageFITSConverter::ImageToFITS(errMsg, tIm, fileName, … … 247 248 degLast, reallyVerbose); 248 249 if (!ok) { 249 cerr << "Error writing fits - " << errMsg << endl;250 oss << endl<< "Error writing fits - " << errMsg; 250 251 } 251 252 … … 258 259 // 259 260 if (!verbose) { 260 cout << "Wrote " << nRows << " into individual FITS files" << endl;261 oss << endl<< "Wrote " << nRows << " into individual FITS files"; 261 262 } 262 // 263 pushLog(String(oss)); 263 264 return True; 264 265 } 265 266 266 -
trunk/src/SDFITSImageWriter.h
r443 r717 36 36 #include <SDMemTable.h> 37 37 38 #include "SDLog.h" 38 39 39 40 namespace asap { 40 41 41 class SDFITSImageWriter {42 class SDFITSImageWriter : public SDLog { 42 43 public: 43 // Constructor44 // Constructor 44 45 SDFITSImageWriter(); 45 46 // Destructor46 47 // Destructor 47 48 ~SDFITSImageWriter(); 48 49 // Write out lots of FITS images, one per row, beam, IF and polarization49 50 // Write out lots of FITS images, one per row, beam, IF and polarization 50 51 casa::Bool write(const SDMemTable& table, const casa::String& rootName, 51 52 casa::Bool toStokes, casa::Bool verbose=casa::True); 52 53 53 54 private: 54 casa::Int convertStokes(casa::Int val, casa::Bool toStokes, casa::Bool linear) const; 55 casa::Int convertStokes(casa::Int val, casa::Bool toStokes, 56 casa::Bool linear) const; 55 57 }; 56 58 -
trunk/src/SDMemTable.cc
r588 r717 887 887 MFrequency::Types mft; 888 888 if (!MFrequency::getType(mft, rf)) { 889 cerr << "Frequency type unknown assuming TOPO" << endl; 889 ostringstream oss; 890 pushLog("WARNING: Frequency type unknown assuming TOPO"); 890 891 mft = MFrequency::TOPO; 891 892 } … … 923 924 if (!MFrequency::getType(mtype, frm)) { 924 925 // Should never happen 925 cerr << "Frequency type unknown assuming TOPO" << endl;926 pushLog("WARNING: Frequency type unknown assuming TOPO"); 926 927 mtype = MFrequency::TOPO; 927 928 } … … 1655 1656 if (!MDirection::getType(mdr, mp[eq])) { 1656 1657 mdr = MDirection::J2000; 1657 cerr << "Unknown equinox using J2000" << endl; 1658 pushLog("WARNING: Unknown equinox using J2000"); 1659 1658 1660 } 1659 1661 … … 1667 1669 table_.keywordSet().get("Epoch",ep); 1668 1670 if (!MEpoch::getType(met, ep)) { 1669 cerr << "Epoch type unknown - using UTC" << endl;1671 pushLog("WARNING: Epoch type unknown - using UTC"); 1670 1672 met = MEpoch::UTC; 1671 1673 } … … 1721 1723 SDFrequencyTable sdft = getSDFreqTable(); 1722 1724 1725 ostringstream oss; 1723 1726 if (nRestFreqs>1) { 1724 1727 // Replace restFreqs, one per IF 1725 if (nRestFreqs != nIFs) { 1726 throw (AipsError("Number of rest frequencies must be equal to the number of IFs")); 1727 } 1728 cout << "Replacing rest frequencies, one per IF, with given list : " << restFreqs << endl; 1729 sdft.deleteRestFrequencies(); 1730 for (uInt i=0; i<nRestFreqs; i++) { 1731 Quantum<Double> rf(restFreqs[i], unit); 1732 sdft.addRestFrequency(rf.getValue("Hz")); 1733 } 1728 if (nRestFreqs != nIFs) { 1729 throw (AipsError("Number of rest frequencies must be equal to the number of IFs")); 1730 } 1731 ostringstream oss; 1732 oss << "Replacing rest frequencies, one per IF, with given list : " << restFreqs; 1733 sdft.deleteRestFrequencies(); 1734 for (uInt i=0; i<nRestFreqs; i++) { 1735 Quantum<Double> rf(restFreqs[i], unit); 1736 sdft.addRestFrequency(rf.getValue("Hz")); 1737 } 1734 1738 } else { 1735 1739 … … 1738 1742 idx = sdft.addRestFrequency(rf.getValue("Hz")); 1739 1743 if (whichIF>=0) { 1740 cout<< "Selecting given rest frequency (" << restFreqs[0] << ") for IF " << whichIF << endl;1744 oss << "Selecting given rest frequency (" << restFreqs[0] << ") for IF " << whichIF << endl; 1741 1745 } else { 1742 cout<< "Selecting given rest frequency (" << restFreqs[0] << ") for all IFs" << endl;1746 oss << "Selecting given rest frequency (" << restFreqs[0] << ") for all IFs" << endl; 1743 1747 } 1744 1748 } 1745 1749 pushLog(String(oss)); 1746 1750 // Replace 1747 1751 Bool empty = source.empty(); … … 1778 1782 } 1779 1783 1780 voidSDMemTable::spectralLines() const1784 std::string SDMemTable::spectralLines() const 1781 1785 { 1782 1786 Vector<String> lines = MeasTable::Lines(); 1783 1787 MFrequency lineFreq; 1784 1788 Double freq; 1785 1786 cout.flags(std::ios_base::left); 1787 cout << "Line Frequency (Hz)" << endl; 1788 cout << "-----------------------" << endl; 1789 ostringstream oss; 1790 1791 oss.flags(std::ios_base::left); 1792 oss << "Line Frequency (Hz)" << endl; 1793 oss << "-----------------------" << endl; 1789 1794 for (uInt i=0; i<lines.nelements(); i++) { 1790 1795 MeasTable::Line(lineFreq, lines[i]); 1791 1796 freq = lineFreq.getValue().getValue(); // Hz 1792 cout<< setw(11) << lines[i] << setprecision(10) << freq << endl;1797 oss << setw(11) << lines[i] << setprecision(10) << freq << endl; 1793 1798 } 1799 return String(oss); 1794 1800 } 1795 1801 -
trunk/src/SDMemTable.h
r539 r717 46 46 #include "SDDefs.h" 47 47 #include "SDFitTable.h" 48 #include "SDLog.h" 48 49 49 50 namespace asap { … … 55 56 56 57 57 58 class SDMemTable { 58 class SDMemTable : private SDLog { 59 59 public: 60 60 // create a new (empty) SDMemTable … … 161 161 162 162 // List lines 163 voidspectralLines() const;163 std::string spectralLines() const; 164 164 165 165 // Get/Set flux unit -
trunk/src/SDMemTableWrapper.h
r539 r717 179 179 } 180 180 181 voidspectralLines() const {table_->spectralLines();}181 std::string spectralLines() const {table_->spectralLines();} 182 182 183 183 std::vector<double> getRestFreqs() { -
trunk/src/SDReader.cc
r570 r717 89 89 90 90 void SDReader::close() { 91 cerr << "disabled" << endl;91 //cerr << "disabled" << endl; 92 92 } 93 93 … … 125 125 // Get basic parameters. 126 126 if (haveXPol_) { 127 cout << "Cross polarization present" << endl;127 pushLog("Cross polarization present"); 128 128 nPol_ += 2; // Convert Complex -> 2 Floats 129 129 } … … 150 150 if ((header_->obstype).matches("*SW*")) { 151 151 // need robust way here - probably read ahead of next timestamp 152 cout <<"Header indicates frequency switched observation.\n"153 "setting # of IFs = 1 " << endl;152 pushLog("Header indicates frequency switched observation.\n" 153 "setting # of IFs = 1 "); 154 154 nIF_ = 1; 155 155 } … … 259 259 // EOF. 260 260 if (row > 0 && row < stepsize-1) 261 cerr << "incomplete scan data.\n Probably means not all Beams/IFs/Pols within a scan are present." << endl;261 pushLog("incomplete scan data.\n Probably means not all Beams/IFs/Pols within a scan are present."); 262 262 263 263 // flush frequency table -
trunk/src/SDReader.h
r420 r717 43 43 #include "SDMemTable.h" 44 44 #include "SDContainer.h" 45 #include "SDLog.h" 45 46 46 47 class PKSreader; … … 48 49 namespace asap { 49 50 50 class SDReader {51 class SDReader : public SDLog { 51 52 public: 52 53 SDReader(); … … 73 74 } 74 75 76 75 77 protected: 76 78 77 79 private: 78 80 casa::Int nBeam_,nIF_,nPol_,nChan_; -
trunk/src/SDWriter.cc
r701 r717 177 177 hdr.obstype, hdr.equinox, hdr.freqref, 178 178 nChan, nPol, False, False)) { 179 cerr << "Failed to create output file." << endl; 180 return 1; 179 throw(AipsError("Failed to create output file")); 181 180 } 182 181 … … 306 305 } 307 306 } 308 309 cout << "SDWriter: wrote " << count << " rows to " << filename << endl; 307 ostringstream oss; 308 oss << "SDWriter: wrote " << count << " rows to " << filename << endl; 309 pushLog(String(oss)); 310 310 cWriter->close(); 311 311 -
trunk/src/SDWriter.h
r442 r717 40 40 #include <SDMemTableWrapper.h> 41 41 42 #include <SDLog.h> 43 42 44 class PKSwriter; 43 45 44 46 namespace asap { 45 47 46 class SDWriter {48 class SDWriter : public SDLog { 47 49 public: 48 50 SDWriter(const string &format = "SDFITS"); -
trunk/src/python_SD.cc
r576 r717 61 61 asap::python::python_SDFitTable(); 62 62 asap::python::python_SDLineFinder(); 63 asap::python::python_SDLog(); 63 64 64 65 register_exception_translator<casa::AipsError>(&asap::python::translate_ex); -
trunk/src/python_SD.h
r465 r717 44 44 void python_SDFitTable(); 45 45 void python_SDLineFinder(); 46 void python_SDLog(); 46 47 47 48 } // python -
trunk/src/python_SDReader.cc
r405 r717 45 45 .def("_reset", &SDReaderWrapper::reset) 46 46 .def("_getdata", &SDReaderWrapper::getSDMemTable) 47 .def("_header", &SDReaderWrapper::pseudoHeader) ;47 .def("_header", &SDReaderWrapper::pseudoHeader) 48 48 ; 49 49 };
Note:
See TracChangeset
for help on using the changeset viewer.