[904] | 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 |
|
---|
| 24 | namespace asap {
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | Convert betweeen the possible polarisations (linear, circular, stokes, stokes2)
|
---|
| 28 |
|
---|
| 29 | @author Malte Marquarding
|
---|
| 30 | @date $Date:$
|
---|
| 31 |
|
---|
| 32 | */
|
---|
| 33 | class STPol {
|
---|
| 34 | public:
|
---|
| 35 |
|
---|
| 36 | typedef void (STPol::*polOperation)( casa::Float phase );
|
---|
[1586] | 37 | STPol(): totalangle_(0.0),feedhand_(1.0) {}
|
---|
[904] | 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);
|
---|
[957] | 54 | else if ( mode == "circular" )
|
---|
| 55 | return getCircular(index);
|
---|
[904] | 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 |
|
---|
[2163] | 68 | virtual void rotatePhase( casa::Float ) {}
|
---|
| 69 | virtual void rotateLinPolPhase( casa::Float) {}
|
---|
[904] | 70 |
|
---|
[2163] | 71 | virtual void invertPhase( casa::Float ) {}
|
---|
[904] | 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 |
|
---|
[1586] | 85 | void setPhaseCorrections(casa::Float totalang=0.0, casa::Float feedhand=1.0)
|
---|
| 86 | { totalangle_=totalang;feedhand_=feedhand;}
|
---|
[957] | 87 |
|
---|
[1586] | 88 | casa::Float getTotalPhase() const { return totalangle_; }
|
---|
[957] | 89 | casa::Float getFeedHand() const { return feedhand_; }
|
---|
| 90 |
|
---|
[904] | 91 | static std::pair<int, std::string> polFromString(const std::string& key);
|
---|
| 92 | static std::string getPolLabel(int index, const std::string& type = "linear");
|
---|
| 93 |
|
---|
| 94 | private:
|
---|
| 95 | static void initPolMap();
|
---|
| 96 | static void initLabelMap();
|
---|
| 97 | static std::map<std::string, std::pair<int, std::string> > polmap_;
|
---|
| 98 | static std::map<std::string, std::map<int, std::string> > labelmap_;
|
---|
| 99 |
|
---|
[1586] | 100 | casa::Float totalangle_,feedhand_;
|
---|
[904] | 101 | std::string mode_;
|
---|
| 102 | casa::Matrix<casa::Float> basespectra_;
|
---|
| 103 |
|
---|
| 104 | };
|
---|
| 105 |
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | #endif
|
---|