source: trunk/src/STPolCircular.cpp@ 1255

Last change on this file since 1255 was 1189, checked in by mar637, 18 years ago

Fix for ticket #61 - changing of default polarisation. Done ticket #62 as far as possible. Tid data gets automatically set as 'circular'\nAlso add circular pol class which was missing so far.

File size: 2.1 KB
RevLine 
[1189]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 }
38 return out;
39}
40
41Vector<Float> asap::STPolCircular::getLinPol( uInt index )
42{
43 if (nspec() != 4) {
44 throw(AipsError("You must have 4 circular polarisations to run this function"));
45 }
46 if ( index < 0 || index >4 ) throw(AipsError("LinPol index out of range"));
47 Vector<Float> out,q,u;
48 if ( nspec() == 4) {
49 switch(index) {
50 case 1:
51 q = getStokes(1);
52 u = getStokes(2);
53 out = Vector<Float>(sqrt(pow(q,Float(2.0))+pow(u, Float(2.0))));
54 break;
55 case 2:
56 q = getStokes(1);
57 u = getStokes(2);
58 out = Vector<Float>(Float(180.0/C::pi/2.0) * atan2(u,q));
59 break;
60 default:
61 out = getStokes(index);
62 }
63 }
64 return out;
65}
66
67Vector<Float> asap::STPolCircular::getCircular(uInt index )
68{
69 return getSpectrum(index);
70}
71
72Vector<Float> asap::STPolCircular::getLinear(uInt index )
73{
74 // convert to stokes I/ V first
75 //
76 // We use the convention
77 // I = (XX+YY) // definition changed
78
79 if (nspec() != 4) {
80 throw(AipsError("You must have 4 circular polarisations to run this function"));
81 }
82 if ( index == 2 || index ==3 ) throw(AipsError("Re/Imag XY not implemented"));
83 Vector<Float> I,V,out;
84 I = getStokes(0);
85 V = getStokes(3);
86 switch(index) {
87 case 0:
88 out = (I + V)/Float(2.0);
89 break;
90 case 1:
91 out = (I - V)/Float(2.0);
92 break;
93 default:
94 out = Vector<Float>();
95 }
96 return out;
97}
98
99}
Note: See TracBrowser for help on using the repository browser.