- Timestamp:
- 02/14/05 12:33:44 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDContainer.cc
r414 r417 40 40 #include <casa/Arrays/VectorIter.h> 41 41 #include <casa/Arrays/ArrayAccessor.h> 42 #include <casa/Arrays/ArrayMath.h> 42 43 #include <casa/BasicMath/Math.h> 43 44 #include <casa/Quanta/MVTime.h> … … 131 132 132 133 Bool SDContainer::setSpectrum(const Matrix<Float>& spec, 134 const Vector<Complex>& cSpec, 135 uInt whichBeam, uInt whichIF) 136 // 137 // spec is [nChan,nPol] 138 // cspec is [nChan] 139 // spectrum_ is [,,,nChan] 140 // 141 // nPOl_ = 4 - xx, yy, real(xy), imag(xy) 142 // 143 { 144 AlwaysAssert(nPol_==4,AipsError); 145 146 // Get slice and check dim 147 148 Bool tSys = False; 149 Bool xPol = True; 150 IPosition start, end; 151 setSlice (start, end, spec.shape(), spectrum_.shape(), 152 whichBeam, whichIF, tSys, xPol); 153 154 // Get a reference to the Pol/Chan slice we are interested in 155 156 Array<Float> subArr = spectrum_(start,end); 157 158 // Iterate through pol-chan plane and fill 159 160 ReadOnlyVectorIterator<Float> inIt(spec,0); 161 VectorIterator<Float> outIt(subArr,asap::ChanAxis); 162 while (!outIt.pastEnd()) { 163 const IPosition& pos = outIt.pos(); 164 if (pos(asap::PolAxis)<2) { 165 outIt.vector() = inIt.vector(); 166 inIt.next(); 167 } else if (pos(asap::PolAxis)==2) { 168 outIt.vector() = real(cSpec); 169 } else if (pos(asap::PolAxis)==3) { 170 outIt.vector() = imag(cSpec); 171 } 172 // 173 outIt.next(); 174 } 175 176 // unset flags for this spectrum, they might be set again by the 177 // setFlags method 178 179 Array<uChar> arr(flags_(start,end)); 180 arr = uChar(0); 181 // 182 return True; 183 } 184 185 186 Bool SDContainer::setSpectrum(const Matrix<Float>& spec, 133 187 uInt whichBeam, uInt whichIF) 134 188 // … … 136 190 // spectrum_ is [,,,nChan] 137 191 // How annoying. 138 // 192 // nPol==2 139 193 { 140 194 … … 143 197 IPosition start, end; 144 198 setSlice (start, end, spec.shape(), spectrum_.shape(), 145 whichBeam, whichIF, False );199 whichBeam, whichIF, False, False); 146 200 147 201 // Get a reference to the Pol/Chan slice we are interested in … … 153 207 ReadOnlyVectorIterator<Float> inIt(spec,0); 154 208 VectorIterator<Float> outIt(subArr,asap::ChanAxis); 155 while (! inIt.pastEnd()) {209 while (!outIt.pastEnd()) { 156 210 outIt.vector() = inIt.vector(); 157 211 // … … 170 224 171 225 226 227 172 228 Bool SDContainer::setFlags (const Matrix<uChar>& flags, 173 uInt whichBeam, uInt whichIF) 229 uInt whichBeam, uInt whichIF, 230 Bool hasXPol) 174 231 // 175 232 // flags is [nChan,nPol] 176 233 // flags_ is [,,,nChan] 177 234 // How annoying. 178 // 179 { 235 // there are no separate flags for XY so make 236 // them up from X and Y 237 // 238 { 239 if (hasXPol) AlwaysAssert(nPol_==4,AipsError); 240 180 241 // Get slice and check dim 181 242 182 243 IPosition start, end; 183 244 setSlice (start, end, flags.shape(), flags_.shape(), 184 whichBeam, whichIF, False );245 whichBeam, whichIF, False, hasXPol); 185 246 186 247 // Get a reference to the Pol/Chan slice we are interested in … … 188 249 Array<uChar> subArr = flags_(start,end); 189 250 190 // Iterate through itand fill251 // Iterate through pol/chan plane and fill 191 252 192 253 ReadOnlyVectorIterator<uChar> inIt(flags,0); 193 254 VectorIterator<uChar> outIt(subArr,asap::ChanAxis); 194 while (!inIt.pastEnd()) { 195 outIt.vector() = inIt.vector(); 196 // 197 inIt.next(); 255 // 256 Vector<uChar> maskPol0; 257 Vector<uChar> maskPol1; 258 Vector<uChar> maskPol01; 259 while (!outIt.pastEnd()) { 260 const IPosition& pos = outIt.pos(); 261 if (pos(asap::PolAxis)<2) { 262 outIt.vector() = inIt.vector(); 263 // 264 if (hasXPol) { 265 if (pos(asap::PolAxis)==0) { 266 maskPol0 = inIt.vector(); 267 } else if (pos(asap::PolAxis)==1) { 268 maskPol1 = inIt.vector(); 269 // 270 maskPol01.resize(maskPol0.nelements()); 271 for (uInt i=0; i<maskPol01.nelements(); i++) maskPol01[i] = maskPol0[i]&maskPol1[i]; 272 } 273 } 274 // 275 inIt.next(); 276 } else if (pos(asap::PolAxis)==2) { 277 outIt.vector() = maskPol01; 278 } else if (pos(asap::PolAxis)==3) { 279 outIt.vector() = maskPol01; 280 } 281 // 198 282 outIt.next(); 199 283 } … … 204 288 205 289 Bool SDContainer::setTsys(const Vector<Float>& tsys, 206 uInt whichBeam, uInt whichIF) 290 uInt whichBeam, uInt whichIF, 291 Bool hasXpol) 207 292 // 208 293 // Tsys does not depend upon channel but is replicated 209 // for simplicity of use 294 // for simplicity of use. 295 // There is no Tsys measurement for the cross polarization 296 // so I have set TSys for XY to sqrt(Tx*Ty) 210 297 // 211 298 { … … 215 302 IPosition start, end; 216 303 setSlice (start, end, tsys.shape(), tsys_.shape(), 217 whichBeam, whichIF, True );304 whichBeam, whichIF, True, hasXpol); 218 305 219 306 // Get a reference to the Pol/Chan slice we are interested in … … 226 313 uInt i=0; 227 314 while (!outIt.pastEnd()) { 228 outIt.vector() = tsys(i++); 315 const IPosition& pos = outIt.pos(); 316 // 317 if (pos(asap::PolAxis)<2) { 318 outIt.vector() = tsys(i++); 319 } else { 320 outIt.vector() = sqrt(tsys[0]*tsys[1]); 321 } 322 // 229 323 outIt.next(); 230 324 } … … 401 495 void SDContainer::setSlice (IPosition& start, IPosition& end, 402 496 const IPosition& shpIn, const IPosition& shpOut, 403 uInt whichBeam, uInt whichIF, Bool tSys) const 497 uInt whichBeam, uInt whichIF, Bool tSys, 498 Bool xPol) const 404 499 // 405 500 // tSYs … … 408 503 // shpIn [nCHan,nPol] 409 504 // 505 // if xPol present, the output nPol = 4 but 506 // the input spectra are nPol=2 (tSys) or nPol=2 (spectra) 507 // 410 508 { 411 509 AlwaysAssert(asap::nAxes==4,AipsError); 510 uInt pOff = 0; 511 if (xPol) pOff += 2; 412 512 if (tSys) { 413 AlwaysAssert(shpOut(asap::PolAxis)==shpIn(0) ,AipsError); // pol513 AlwaysAssert(shpOut(asap::PolAxis)==shpIn(0)+pOff,AipsError); // pol 414 514 } else { 415 AlwaysAssert(shpOut(asap::ChanAxis)==shpIn(0),AipsError); // chan416 AlwaysAssert(shpOut(asap::PolAxis)==shpIn(1) ,AipsError);// pol515 AlwaysAssert(shpOut(asap::ChanAxis)==shpIn(0),AipsError); // chan 516 AlwaysAssert(shpOut(asap::PolAxis)==shpIn(1)+pOff,AipsError); // pol 417 517 } 418 518 // -
trunk/src/SDContainer.h
r396 r417 123 123 casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec, 124 124 casa::uInt whichBeam, casa::uInt whichIF); 125 casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec, 126 const casa::Vector<casa::Complex>& cSpec, 127 casa::uInt whichBeam, casa::uInt whichIF); 125 128 casa::Bool putSpectrum(const casa::Array<casa::Float>& spec); 126 129 127 130 casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs, 128 casa::uInt whichBeam, casa::uInt whichIF); 131 casa::uInt whichBeam, casa::uInt whichIF, 132 casa::Bool hasXPol=casa::False); 129 133 casa::Bool putFlags(const casa::Array<casa::uChar>& spec); 130 134 131 135 casa::Bool setTsys(const casa::Vector<casa::Float>& ts, 132 casa::uInt whichBeam, casa::uInt whichIF); 136 casa::uInt whichBeam, casa::uInt whichIF, 137 casa::Bool hasXpol); 133 138 casa::Bool putTsys(const casa::Array<casa::Float>& spec); 134 139 … … 197 202 void setSlice (casa::IPosition& start, casa::IPosition& end, 198 203 const casa::IPosition& shpIn, const casa::IPosition& shpOut, 199 casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol) const; 204 casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol, 205 casa::Bool xPol) const; 200 206 }; 201 207
Note:
See TracChangeset
for help on using the changeset viewer.