source: trunk/src/STPolCircular.cpp@ 3103

Last change on this file since 3103 was 3080, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Bug fix on index range check. It seems that current code allows index 4. But I think valid index range should be 0 <= index <= 4.

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