// // C++ Implementation: STPolLinear // // Description: // // // Author: Malte Marquarding , (C) 2006 // // Copyright: See COPYING file that comes with this distribution // // #include #include #include #include #include "STPolLinear.h" using namespace casa; namespace asap { Factory STPolLinear::myFactory; STPolLinear::~STPolLinear() { } Vector asap::STPolLinear::getStokes( uint index ) { cout << "debug asap::STPolLinear::getStokes" << endl; if ( index < 0 || index >4 ) throw(AipsError("Stokes index out of range")); Vector out; cout << nspec() << endl; if ( nspec() == 4 ) { switch(index) { case 0: out = Vector(getSpectrum(0) + getSpectrum(1)) * Float(0.5); break; case 1: out = Vector(getSpectrum(0) - getSpectrum(1)) * Float(0.5); break; default: out =Vector(getSpectrum(index)); } } return out; } Vector asap::STPolLinear::getLinPol( uInt index ) { if ( index < 0 || index >4 ) throw(AipsError("LinPol index out of range")); Vector out,q; if ( nspec() == 4) { switch(index) { case 1: q = getStokes(index); out = Vector(sqrt(pow(q,Float(2.0))+pow(getSpectrum(2), Float(2.0)))); break; case 2: q = getStokes(index); out = Vector(Float(180.0/C::pi/2.0) * atan2(getSpectrum(2),q)); break; default: out = getStokes(index); } } return out; } Vector asap::STPolLinear::getLinear(uInt index ) { return getSpectrum(index); } Vector asap::STPolLinear::getCircular(uInt index ) { // convert to stokes I/ V first // // We use the convention // I = (RR+LL) // definition changed if ( index == 2 || index ==3 ) throw(AipsError("Re/Imag RL not implemented")); Vector I,V,out; I = getStokes(0); V = getStokes(3); switch(index) { case 0: out = (I + V)/Float(2.0); break; case 1: out = (I - V)/Float(2.0); break; default: out = Vector(); } return out; } void asap::STPolLinear::rotatePhase( Float phase ) { if (nspec() != 4) { throw(AipsError("You must have 4 linear polarizations to run this function")); } Float cosVal = cos(C::pi/180.0*phase); Float sinVal = sin(C::pi/180.0*phase); Matrix& specs = getSpectra(); Vector R2 = specs.column(2)*cosVal - specs.column(3)*sinVal; specs.column(3) = specs.column(2)*sinVal + specs.column(3)*cosVal; specs.column(2) = R2; } void asap::STPolLinear::invertPhase( Float phase ) { // phase isnt used, just ro keep interface the same for all pol operations Matrix& specs = getSpectra(); Vector I = specs.column(3); I *= Float(-1.0); } }