Changeset 418
- Timestamp:
- 02/14/05 12:35:18 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r414 r418 41 41 #include <casa/Arrays/ArrayAccessor.h> 42 42 #include <casa/Arrays/Vector.h> 43 #include <casa/BasicMath/Math.h> 43 44 #include <casa/Quanta/MVAngle.h> 44 45 … … 61 62 #include "SDContainer.h" 62 63 #include "MathUtils.h" 64 #include "SDPol.h" 63 65 64 66 … … 164 166 td.addColumn(ArrayColumnDesc<uChar>("FLAGTRA")); 165 167 td.addColumn(ArrayColumnDesc<Float>("TSYS")); 168 td.addColumn(ArrayColumnDesc<Float>("STOKES")); 166 169 td.addColumn(ScalarColumnDesc<Int>("SCANID")); 167 170 td.addColumn(ScalarColumnDesc<Double>("INTERVAL")); … … 178 181 td.addColumn(ArrayColumnDesc<String>("HISTORY")); 179 182 180 // Now create a new tablefrom the description.183 // Now create Table SetUp from the description. 181 184 182 185 SetupNewTable aNewTab("dummy", td, Table::New); 186 187 // Bind the Stokes Virtual machine to the STOKES column 188 // Because we don't know how many polarizations will 189 // be in the data at this point, we must bind the 190 // Virtual Engine regardless. The STOKES column won't 191 // be accessed if not appropriate (nPol=4) 192 193 SDStokesEngine stokesEngine(String("STOKES"), String("SPECTRA")); 194 aNewTab.bindColumn ("STOKES", stokesEngine); 195 196 // Create Table 197 183 198 table_ = Table(aNewTab, Table::Memory, 0); 184 199 } 200 185 201 186 202 void SDMemTable::attach() … … 191 207 flagsCol_.attach(table_, "FLAGTRA"); 192 208 tsCol_.attach(table_, "TSYS"); 209 stokesCol_.attach(table_, "STOKES"); 193 210 scanCol_.attach(table_, "SCANID"); 194 211 integrCol_.attach(table_, "INTERVAL"); … … 318 335 return mask; 319 336 } 337 338 339 320 340 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const 321 341 { 322 std::vector<float> spectrum;323 342 Array<Float> arr; 324 343 specCol_.get(whichRow, arr); 344 // 345 return getFloatSpectrum (arr); 346 } 347 348 std::vector<float> SDMemTable::getStokesSpectrum(Int whichRow, Bool doPol) const 349 // 350 // Gets 351 // doPol=False : I,Q,U,V 352 // doPol=True : I,P,PA,V ; P = sqrt(Q**2+U**2), PA = 0.5*atan2(Q,U) 353 // 354 { 355 if (nPol()!=4) { 356 throw (AipsError("You must have 4 polarizations to get the Stokes parameters")); 357 } 358 Array<Float> arr; 359 stokesCol_.get(whichRow, arr); 360 // 361 if (doPol && (polSel_==1 || polSel_==2)) { 362 const IPosition& shape = arr.shape(); 363 IPosition start(asap::nAxes,0); 364 IPosition end(shape-1); 365 // 366 start(asap::PolAxis) = 1; // Q 367 end (asap::PolAxis) = 1; 368 Array<Float> Q = arr(start,end); 369 // 370 start(asap::PolAxis) = 2; // U 371 end (asap::PolAxis) = 2; 372 Array<Float> U = arr(start,end); 373 // 374 Array<Float> out; 375 if (polSel_==1) { // P 376 out = SDPolUtil::polarizedIntensity(Q,U); 377 } else if (polSel_==2) { // P.A. 378 out = SDPolUtil::positionAngle(Q,U); 379 } 380 // 381 IPosition vecShape(1,shape(asap::ChanAxis)); 382 Vector<Float> outV = out.reform(vecShape); 383 std::vector<float> spectrum(out.nelements()); 384 for (uInt i=0; i<out.nelements(); i++) { 385 spectrum[i] = outV[i]; 386 } 387 return spectrum; 388 } else { 389 return getFloatSpectrum (arr); 390 } 391 } 392 393 std::vector<float> SDMemTable::getFloatSpectrum (const Array<Float>& arr) const 394 { 395 396 // Iterate and extract 397 325 398 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); 326 399 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam … … 329 402 ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1); 330 403 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 404 // 405 std::vector<float> spectrum; 331 406 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 332 407 spectrum.push_back(*i); … … 334 409 return spectrum; 335 410 } 411 412 336 413 std::vector<string> SDMemTable::getCoordInfo() const 337 414 { … … 537 614 Array<Float> arr; 538 615 specCol_.get(whichRow, arr); 616 617 // Iterate and extract 618 539 619 spectrum.resize(arr.shape()(3)); 540 620 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); … … 544 624 ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1); 545 625 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 546 626 // 547 627 ArrayAccessor<Float, Axis<asap::BeamAxis> > va(spectrum); 548 628 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { … … 551 631 } 552 632 } 633 634 553 635 /* 554 636 void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow) const { … … 591 673 specCol_.get(whichRow, arr); 592 674 flagsCol_.get(whichRow, farr); 593 Array<Bool> barr(farr.shape());convertArray(barr, farr); 675 Array<Bool> barr(farr.shape()); 676 convertArray(barr, farr); 594 677 MaskedArray<Float> marr; 595 678 if (useSelection) { … … 634 717 tsCol_.get(whichRow, arr); 635 718 Float out; 719 // 636 720 IPosition ip(arr.shape()); 637 ip(0) = beamSel_;ip(1) = IFSel_;ip(2) = polSel_;ip(3)=0; 721 ip(asap::BeamAxis) = beamSel_; 722 ip(asap::IFAxis) = IFSel_; 723 ip(asap::PolAxis) = polSel_; 724 ip(asap::ChanAxis)=0; // First channel only 725 // 638 726 out = arr(ip); 639 727 return out; … … 1476 1564 } 1477 1565 1566 1567 void SDMemTable::rotateXYPhase (Float value) 1568 // 1569 // phase in degrees 1570 // 1571 { 1572 if (nPol() != 4) { 1573 throw(AipsError("You must have 4 polarizations to run this function")); 1574 } 1575 // 1576 IPosition start(asap::nAxes,0); 1577 IPosition end(asap::nAxes); 1578 // 1579 uInt nRow = specCol_.nrow(); 1580 Array<Float> data; 1581 for (uInt i=0; i<nRow;++i) { 1582 specCol_.get(i,data); 1583 end = data.shape()-1; 1584 1585 // Get polarization slice references 1586 1587 start(asap::PolAxis) = 2; 1588 end(asap::PolAxis) = 2; 1589 Array<Float> C3 = data(start,end); 1590 // 1591 start(asap::PolAxis) = 3; 1592 end(asap::PolAxis) = 3; 1593 Array<Float> C4 = data(start,end); 1594 1595 // Rotate 1596 1597 SDPolUtil::rotateXYPhase(C3, C4, value); 1598 1599 // Put 1600 1601 specCol_.put(i,data); 1602 } 1603 } -
trunk/src/SDMemTable.h
r401 r418 94 94 virtual std::vector<float> getSpectrum(casa::Int whichRow=0) const; 95 95 virtual std::vector<bool> getMask(casa::Int whichRow=0) const; 96 virtual std::vector<float> getStokesSpectrum(casa::Int whichRow=0, 97 casa::Bool doPol=casa::False) const; 96 98 97 99 virtual casa::Float getTsys(casa::Int whichRow=0) const; … … 99 101 virtual void getSpectrum(casa::Vector<casa::Float>& spectrum, 100 102 casa::Int whichRow=0) const; 101 102 103 //virtual void getMask(Vector<Bool>& mask,Int whichRow=0) const; 104 103 105 std::vector<double> getRestFreqs() const; 104 106 … … 218 220 casa::MPosition getAntennaPosition() const; 219 221 222 // Rotate phase of XY correlation by specified value (degrees) 223 void rotateXYPhase (casa::Float angle); 224 220 225 // Helper function to check instrument (antenna) name and give enum 221 226 static Instrument convertInstrument(const casa::String& instrument, … … 226 231 casa::String formatSec(casa::Double x) const; 227 232 casa::String formatDirection(const casa::MDirection& md) const; 233 std::vector<float> getFloatSpectrum (const casa::Array<casa::Float>& arr) const; 228 234 void setup(); 229 235 void attach(); … … 245 251 casa::ArrayColumn<casa::uInt> freqidCol_, restfreqidCol_; 246 252 casa::ArrayColumn<casa::String> histCol_; 253 casa::ArrayColumn<casa::Float> stokesCol_; 247 254 }; 248 255
Note:
See TracChangeset
for help on using the changeset viewer.