1 | // |
---|
2 | // C++ Implementation: STPolStokes |
---|
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 "STPolStokes.h" |
---|
18 | |
---|
19 | using namespace casa; |
---|
20 | |
---|
21 | namespace asap { |
---|
22 | |
---|
23 | Factory<STPol,STPolStokes> STPolStokes::myFactory; |
---|
24 | |
---|
25 | STPolStokes::~STPolStokes() |
---|
26 | { |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | Vector<Float> asap::STPolStokes::getStokes( uint index ) |
---|
31 | { |
---|
32 | return getSpectrum(index); |
---|
33 | } |
---|
34 | |
---|
35 | Vector<Float> asap::STPolStokes::getLinPol( uInt index ) |
---|
36 | { |
---|
37 | // if ( index < 0 || index >4 ) throw(AipsError("LinPol index out of range")); |
---|
38 | if ( index >= 4 ) throw(AipsError("LinPol index out of range")); |
---|
39 | Vector<Float> out; |
---|
40 | if ( nspec() == 4) { |
---|
41 | switch(index) { |
---|
42 | case 1: |
---|
43 | out = Vector<Float>(sqrt(pow(getSpectrum(1),Float(2.0)) |
---|
44 | +pow(getSpectrum(2), Float(2.0)))); |
---|
45 | break; |
---|
46 | case 2: |
---|
47 | out = Vector<Float>(Float(180.0/C::pi/2.0) |
---|
48 | * atan2(getSpectrum(2),getSpectrum(1))); |
---|
49 | break; |
---|
50 | default: |
---|
51 | out = getSpectrum(index); |
---|
52 | } |
---|
53 | } |
---|
54 | return out; |
---|
55 | } |
---|
56 | |
---|
57 | Vector<Float> asap::STPolStokes::getLinear(uInt index ) |
---|
58 | { |
---|
59 | Vector<Float> out; |
---|
60 | switch(index) { |
---|
61 | case 0: |
---|
62 | out = (getSpectrum(0)+getSpectrum(1))/Float(2.0); |
---|
63 | break; |
---|
64 | case 1: |
---|
65 | out = (getSpectrum(0)-getSpectrum(1))/Float(2.0); |
---|
66 | break; |
---|
67 | case 2: |
---|
68 | out = getSpectrum(2)/Float(2.0); |
---|
69 | break; |
---|
70 | case 3: |
---|
71 | out = getSpectrum(3)/Float(2.0); |
---|
72 | break; |
---|
73 | default: |
---|
74 | out = Vector<Float>(); |
---|
75 | } |
---|
76 | return out; |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | Vector<Float> asap::STPolStokes::getCircular(uInt index ) |
---|
81 | { |
---|
82 | // convert to stokes I/ V first |
---|
83 | // |
---|
84 | // We use the convention |
---|
85 | // I = (RR+LL) // definition changed |
---|
86 | |
---|
87 | if ( index == 2 || index ==3 ) throw(AipsError("Re/Imag RL not implemented")); |
---|
88 | Vector<Float> out; |
---|
89 | switch(index) { |
---|
90 | case 0: |
---|
91 | out = (getSpectrum(0) + getSpectrum(3))/Float(2.0); |
---|
92 | break; |
---|
93 | case 1: |
---|
94 | out = (getSpectrum(0) - getSpectrum(3))/Float(2.0); |
---|
95 | break; |
---|
96 | default: |
---|
97 | out = Vector<Float>(); |
---|
98 | } |
---|
99 | return out; |
---|
100 | } |
---|
101 | |
---|
102 | } |
---|