source: branches/mergetest/src/STPol.cpp@ 1843

Last change on this file since 1843 was 904, checked in by mar637, 19 years ago

Polarimetry handling and conversion

File size: 2.8 KB
Line 
1//
2// C++ Implementation: STPol
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2005
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12
13#include <casa/Exceptions/Error.h>
14#include "STPol.h"
15
16std::map<std::string, std::pair<int, std::string> > asap::STPol::polmap_;
17std::map<std::string, std::map<int, std::string> > asap::STPol::labelmap_;
18
19void asap::STPol::initLabelMap()
20{
21 if ( labelmap_.empty() ) {
22 std::map<int, std::string> linears;
23 linears[0] = "XX";linears[1] = "YY";
24 linears[2] = "Re(XY)";linears[3] = "Imag(XY)";
25 STPol::labelmap_["linear"] = linears;
26 std::map<int, std::string> circulars;
27 circulars[0] = "RR";circulars[1] = "LL";
28 circulars[2] = "Re(RL)";circulars[3] = "Imag(RL)";
29 STPol::labelmap_["circular"] = circulars;
30 std::map<int, std::string> stokes;
31 stokes[0]="I";stokes[1]="Q";stokes[2]="U";stokes[3]="V";
32 STPol::labelmap_["stokes"] = stokes;
33 std::map<int, std::string> linpol;
34 linpol[1] = "Plinear";linpol[2] = "Pangle";
35 STPol::labelmap_["linpol"] = linpol;
36 }
37}
38
39std::string asap::STPol::getPolLabel( int index,
40 const std::string& type)
41{
42 initLabelMap();
43 if ( labelmap_.find(type) == labelmap_.end() ) {
44 std::string msg = "Illegal polarisation type "+type;
45 throw(casa::AipsError(msg));
46 } else {
47 std::map<int, std::string> poltype = labelmap_[type];
48 if ( poltype.find(index) == poltype.end() ) {
49 std::string msg = "Illegal polarisation index";
50 throw(casa::AipsError(msg));
51 } else {
52 return poltype[index];
53 }
54 }
55}
56
57void asap::STPol::initPolMap( )
58{
59 if ( polmap_.empty() ) {
60 std::pair<int, std::string> val;
61 val.first = 0; val.second = "linear";
62 STPol::polmap_["XX"] = val;
63 val.first = 1;
64 STPol::polmap_["YY"] = val;
65 val.first = 2;
66 STPol::polmap_["Re(XY)"] = val;
67 val.first = 3;
68 STPol::polmap_["Imag(XY)"] = val;
69 val.first = 0; val.second = "stokes";
70 STPol::polmap_["I"] = val;
71 val.first = 1;
72 STPol::polmap_["Q"] = val;
73 val.first = 2;
74 STPol::polmap_["U"] = val;
75 val.first = 3;
76 STPol::polmap_["V"] = val;
77 val.first = 1; val.second = "linpol";
78 STPol::polmap_["Plinear"] = val;
79 val.first = 2;
80 STPol::polmap_["Pangle"] = val;
81 val.first = 0; val.second = "circular";
82 STPol::polmap_["RR"] = val;
83 val.first = 1;
84 STPol::polmap_["LL"] = val;
85 val.first = 2;
86 STPol::polmap_["Re(RL)"] = val;
87 val.first = 3;
88 STPol::polmap_["Imag(RL)"] = val;
89 }
90}
91
92std::pair<int, std::string> asap::STPol::polFromString( const std::string& key )
93{
94 initPolMap();
95 if ( polmap_.find(key) == polmap_.end() ) {
96 std::string msg = "Illegal polarisation type "+key;
97 throw(casa::AipsError(msg));
98 } else {
99 return polmap_[key];
100 }
101}
Note: See TracBrowser for help on using the repository browser.