Changeset 349
- Timestamp:
- 02/02/05 13:11:28 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDContainer.cc
r336 r349 29 29 //# $Id: 30 30 //#--------------------------------------------------------------------------- 31 31 32 #include <casa/aips.h> 32 33 #include <casa/iostream.h> 33 34 #include <casa/iomanip.h> 34 35 #include <casa/Exceptions.h> 36 #include <casa/Utilities/Assert.h> 35 37 #include <tables/Tables/Table.h> 36 38 #include <casa/Arrays/IPosition.h> 37 39 #include <casa/Arrays/Matrix.h> 40 #include <casa/Arrays/VectorIter.h> 38 41 #include <casa/Arrays/ArrayAccessor.h> 39 42 #include <casa/BasicMath/Math.h> 40 43 #include <casa/Quanta/MVTime.h> 44 41 45 42 46 … … 124 128 125 129 Bool SDContainer::setSpectrum(const Matrix<Float>& spec, 126 uInt whichBeam, uInt whichIF) { 127 128 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(spectrum_); 129 aa0.reset(aa0.begin(whichBeam)); 130 ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0); 131 aa1.reset(aa1.begin(whichIF)); 132 133 //Vector<Float> pols(nPol); 134 ArrayAccessor<Float, Axis<asap::IFAxis> > j(spec); 135 IPosition shp0 = spectrum_.shape(); 136 IPosition shp1 = spec.shape(); 137 if ( (shp0(2) != shp1(1)) || (shp0(3) != shp1(0)) ) { 138 throw(AipsError("Arrays not conformant")); 139 return False; 140 } 141 // assert dimensions are the same.... 142 for (ArrayAccessor<Float, Axis<asap::PolAxis> > i(aa1);i != i.end(); ++i) { 143 ArrayAccessor<Float, Axis<asap::BeamAxis> > jj(j); 144 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > ii(i);ii != ii.end(); ++ii) { 145 (*ii) = (*jj); 146 jj++; 147 } 148 j++; 149 } 130 uInt whichBeam, uInt whichIF) 131 // 132 // spec is [nChan,nPol] 133 // spectrum_ is [,,,nChan] 134 // How annoying. 135 // 136 { 137 138 // Get slice and check dim 139 140 IPosition start, end; 141 setSlice (start, end, spec.shape(), spectrum_.shape(), 142 whichBeam, whichIF, False); 143 144 // Get a reference to the Pol/Chan slice we are interested in 145 146 Array<Float> subArr = spectrum_(start,end); 147 148 // Iterate through it and fill 149 150 ReadOnlyVectorIterator<Float> inIt(spec,0); 151 VectorIterator<Float> outIt(subArr,asap::ChanAxis); 152 while (!inIt.pastEnd()) { 153 outIt.vector() = inIt.vector(); 154 // 155 inIt.next(); 156 outIt.next(); 157 } 158 150 159 // unset flags for this spectrum, they might be set again by the 151 160 // setFlags method 152 161 153 IPosition shp = flags_.shape();154 IPosition start(4,whichBeam,whichIF,0,0);155 IPosition end(4,whichBeam,whichIF,shp(2)-1,shp(3)-1);156 162 Array<uChar> arr(flags_(start,end)); 157 163 arr = uChar(0); … … 160 166 } 161 167 162 Bool SDContainer::setFlags(const Matrix<uChar>& flag, 163 uInt whichBeam, uInt whichIF) { 164 165 ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(flags_); 166 aa0.reset(aa0.begin(whichBeam)); 167 ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0); 168 aa1.reset(aa1.begin(whichIF)); 169 170 ArrayAccessor<uChar, Axis<asap::IFAxis> > j(flag); 171 IPosition shp0 = flags_.shape(); 172 IPosition shp1 = flag.shape(); 173 if ( (shp0(2) != shp1(1)) || (shp0(3) != shp1(0)) ) { 174 cerr << "Arrays not conformant" << endl; 175 return False; 176 } 177 178 // assert dimensions are the same.... 179 for (ArrayAccessor<uChar, Axis<asap::PolAxis> > i(aa1);i != i.end(); ++i) { 180 ArrayAccessor<uChar, Axis<asap::BeamAxis> > jj(j); 181 for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > ii(i);ii != ii.end(); ++ii) { 182 (*ii) = (*jj); 183 jj++; 184 } 185 j++; 186 } 187 return True; 188 } 168 169 Bool SDContainer::setFlags (const Matrix<uChar>& flags, 170 uInt whichBeam, uInt whichIF) 171 // 172 // flags is [nChan,nPol] 173 // flags_ is [,,,nChan] 174 // How annoying. 175 // 176 { 177 // Get slice and check dim 178 179 IPosition start, end; 180 setSlice (start, end, flags.shape(), flags_.shape(), 181 whichBeam, whichIF, False); 182 183 // Get a reference to the Pol/Chan slice we are interested in 184 185 Array<uChar> subArr = flags_(start,end); 186 187 // Iterate through it and fill 188 189 ReadOnlyVectorIterator<uChar> inIt(flags,0); 190 VectorIterator<uChar> outIt(subArr,asap::ChanAxis); 191 while (!inIt.pastEnd()) { 192 outIt.vector() = inIt.vector(); 193 // 194 inIt.next(); 195 outIt.next(); 196 } 197 // 198 return True; 199 } 200 189 201 190 202 Bool SDContainer::setTsys(const Vector<Float>& tsys, 191 uInt whichBeam, uInt whichIF) { 192 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(tsys_); 193 aa0.reset(aa0.begin(whichBeam)); 194 ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0); 195 aa1.reset(aa1.begin(whichIF)); 196 // assert dimensions are the same.... 197 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa1);i != i.end(); ++i) { 198 ArrayAccessor<Float, Axis<asap::BeamAxis> > j(tsys); 199 for (ArrayAccessor<Float, Axis<asap::PolAxis> > ii(i);ii != ii.end(); ++ii) { 200 (*ii) = (*j); 201 j++; 202 } 203 uInt whichBeam, uInt whichIF) 204 // 205 // Tsys does not depend upon channel but is replicated 206 // for simplicity of use 207 // 208 { 209 210 // Get slice and check dim 211 212 IPosition start, end; 213 setSlice (start, end, tsys.shape(), tsys_.shape(), 214 whichBeam, whichIF, True); 215 216 // Get a reference to the Pol/Chan slice we are interested in 217 218 Array<Float> subArr = tsys_(start,end); 219 220 // Iterate through it and fill 221 222 VectorIterator<Float> outIt(subArr,asap::ChanAxis); 223 uInt i=0; 224 while (!outIt.pastEnd()) { 225 outIt.vector() = tsys(i++); 226 outIt.next(); 203 227 } 204 228 } … … 361 385 } 362 386 387 void SDContainer::setSlice (IPosition& start, IPosition& end, 388 const IPosition& shpIn, const IPosition& shpOut, 389 uInt whichBeam, uInt whichIF, Bool tSys) const 390 // 391 // tSYs 392 // shpIn [nPol] 393 // else 394 // shpIn [nCHan,nPol] 395 // 396 { 397 AlwaysAssert(asap::nAxes==4,AipsError); 398 if (tSys) { 399 AlwaysAssert(shpOut(asap::PolAxis)==shpIn(0),AipsError); // pol 400 } else { 401 AlwaysAssert(shpOut(asap::ChanAxis)==shpIn(0),AipsError); // chan 402 AlwaysAssert(shpOut(asap::PolAxis)==shpIn(1),AipsError); // pol 403 } 404 // 405 start.resize(asap::nAxes); 406 start = 0; 407 start(asap::BeamAxis) = whichBeam; 408 start(asap::IFAxis) = whichIF; 409 // 410 end.resize(asap::nAxes); 411 end = shpOut-1; 412 end(asap::BeamAxis) = whichBeam; 413 end(asap::IFAxis) = whichIF; 414 } 415 416 417 418 // SDFrequenctTable 419 420 363 421 Int SDFrequencyTable::addFrequency(Double refPix, Double refVal, Double inc) { 364 422 Int idx = -1; … … 415 473 416 474 475 476 // SDDataDesc 477 417 478 uInt SDDataDesc::addEntry (const String& source, uInt freqID, const MDirection& dir) 418 479 { … … 451 512 } 452 513 514 -
trunk/src/SDContainer.h
r326 r349 186 186 casa::Array<casa::Double> direction_; 187 187 casa::Vector<casa::String> history_; 188 188 void setSlice (casa::IPosition& start, casa::IPosition& end, 189 const casa::IPosition& shpIn, const casa::IPosition& shpOut, 190 casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol) const; 189 191 }; 190 192 … … 221 223 // 222 224 SDDataDesc(const SDDataDesc& other); 223 }; 224 225 226 }; 225 227 226 228 } // namespace
Note:
See TracChangeset
for help on using the changeset viewer.