source: trunk/src/STPolStokes.cpp @ 910

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

Stokes polarimetry handling and conversion

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