source: branches/asap-3.x/src/STPolCircular.cpp@ 3021

Last change on this file since 3021 was 1259, checked in by mar637, 18 years ago

Merge from Release2.1.0b tag

File size: 2.2 KB
Line 
1//
2// C++ Implementation: STPolCircular
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <Malte.Marquarding@csiro.au>, (C) 2006
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12
13#include <casa/Arrays/ArrayMath.h>
14#include <casa/BasicMath/Math.h>
15#include <casa/Exceptions/Error.h>
16#include <casa/BasicSL/Constants.h>
17#include "STPolCircular.h"
18
19using namespace casa;
20
21namespace asap {
22
23Factory<STPol,STPolCircular> STPolCircular::myFactory;
24
25STPolCircular::~STPolCircular()
26{
27}
28
29
30Vector<Float> asap::STPolCircular::getStokes( uint index )
31{
32 /// @todo implement full stokes support when circular cross pols are available
33 Vector<Float> out;
34 if (nspec() == 2) {
35 if ( index == 0 )
36 out = Vector<Float>(getSpectrum(0) + getSpectrum(1));
37 else if ( index == 3 )
38 out = Vector<Float>(getSpectrum(0) - getSpectrum(1));
39 }
40 return out;
41}
42
43Vector<Float> asap::STPolCircular::getLinPol( uInt index )
44{
45 if (nspec() != 4) {
46 throw(AipsError("You must have 4 circular polarisations to run this function"));
47 }
48 if ( index < 0 || index >4 ) throw(AipsError("LinPol index out of range"));
49 Vector<Float> out,q,u;
50 if ( nspec() == 4) {
51 switch(index) {
52 case 1:
53 q = getStokes(1);
54 u = getStokes(2);
55 out = Vector<Float>(sqrt(pow(q,Float(2.0))+pow(u, Float(2.0))));
56 break;
57 case 2:
58 q = getStokes(1);
59 u = getStokes(2);
60 out = Vector<Float>(Float(180.0/C::pi/2.0) * atan2(u,q));
61 break;
62 default:
63 out = getStokes(index);
64 }
65 }
66 return out;
67}
68
69Vector<Float> asap::STPolCircular::getCircular(uInt index )
70{
71 return getSpectrum(index);
72}
73
74Vector<Float> asap::STPolCircular::getLinear(uInt index )
75{
76 // convert to stokes I/ V first
77 //
78 // We use the convention
79 // I = (XX+YY) // definition changed
80
81 if (nspec() != 4) {
82 throw(AipsError("You must have 4 circular polarisations to run this function"));
83 }
84 if ( index == 2 || index ==3 ) throw(AipsError("Re/Imag XY not implemented"));
85 Vector<Float> I,V,out;
86 I = getStokes(0);
87 V = getStokes(3);
88 switch(index) {
89 case 0:
90 out = (I + V)/Float(2.0);
91 break;
92 case 1:
93 out = (I - V)/Float(2.0);
94 break;
95 default:
96 out = Vector<Float>();
97 }
98 return out;
99}
100
101}
Note: See TracBrowser for help on using the repository browser.