source: branches/Release2.1.2/src/STPol.h

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

Fix for Ticket #20 - rotateLinPolPhase wasn't workin properly. Have add deafult values to STPol constructor, also had to set the focusTable entries in STMath::applyToPol.

File size: 3.0 KB
Line 
1//
2// C++ Interface: STPol
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#ifndef ASAPSTPOL_H
13#define ASAPSTPOL_H
14
15#include <map>
16#include <utility>
17
18#include <casa/aips.h>
19#include <casa/Exceptions/Error.h>
20#include <casa/Arrays/Matrix.h>
21#include <casa/Arrays/Vector.h>
22#include "Factory.h"
23
24namespace asap {
25
26/**
27Convert betweeen the possible polarisations (linear, circular, stokes, stokes2)
28
29@author Malte Marquarding
30@date $Date:$
31
32*/
33class STPol {
34public:
35
36  typedef  void (STPol::*polOperation)( casa::Float phase );
37  STPol(): totalfeed_(0.0),parangle_(0.0),feedhand_(1.0) {}
38  virtual ~STPol() {}
39
40  typedef FactoryBase<STPol> STPolFactory;
41
42  static STPol* getPolClass( std::map<std::string,STPol::STPolFactory *> factories,
43                             const std::string& type )
44    { return factories[type]->create(); }
45
46  casa::Vector<casa::Float> getSpectrum( casa::uInt index, const std::string& mode )
47    {
48      if (mode == "linear")
49        return getLinear(index);
50      else if ( mode == "stokes" )
51        return getStokes(index);
52      else if ( mode == "linpol" )
53        return getLinPol(index);
54      else if ( mode == "circular" )
55        return getCircular(index);
56      else
57        throw(casa::AipsError("Polarisation type unknown"));
58    }
59
60  virtual casa::Vector<casa::Float> getCircular( casa::uInt index ) = 0;
61
62  virtual casa::Vector<casa::Float> getStokes( casa::uInt index ) = 0;
63
64  virtual casa::Vector<casa::Float> getLinPol( casa::uInt index ) = 0;
65
66  virtual casa::Vector<casa::Float> getLinear( casa::uInt index ) = 0;
67
68  virtual void rotatePhase( casa::Float phase ) {}
69  virtual void rotateLinPolPhase( casa::Float phase ) {}
70
71  virtual void invertPhase( casa::Float phase ) {}
72
73  casa::uInt nspec() const { return basespectra_.ncolumn(); }
74
75  const casa::Vector<casa::Float> getSpectrum(casa::uInt index) const
76    { return basespectra_.column(index); }
77
78  casa::Matrix<casa::Float>& getSpectra()
79    { return basespectra_; }
80
81  void setSpectra(const casa::Matrix<casa::Float>& spec)
82    { basespectra_.resize(); basespectra_ = spec; }
83
84
85  void setPhaseCorrections(casa::Float parangle=0.0, casa::Float totalfeed=0.0,
86                           casa::Float feedhand=1.0)
87    { totalfeed_=totalfeed;parangle_=parangle;feedhand_=feedhand;}
88
89  casa::Float getTotalPhase() const { return totalfeed_+parangle_; }
90  casa::Float getFeedHand() const { return feedhand_; }
91
92  static std::pair<int, std::string> polFromString(const std::string& key);
93  static std::string getPolLabel(int index, const std::string& type = "linear");
94
95private:
96  static void initPolMap();
97  static void initLabelMap();
98  static std::map<std::string, std::pair<int, std::string> > polmap_;
99  static std::map<std::string, std::map<int, std::string> > labelmap_;
100
101  casa::Float totalfeed_,parangle_,feedhand_;
102  std::string mode_;
103  casa::Matrix<casa::Float> basespectra_;
104
105};
106
107}
108
109#endif
Note: See TracBrowser for help on using the repository browser.