[805] | 1 | // |
---|
| 2 | // C++ Interface: STMath |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | #ifndef ASAPSTMATH_H |
---|
| 13 | #define ASAPSTMATH_H |
---|
[2] | 14 | |
---|
[38] | 15 | #include <string> |
---|
[805] | 16 | #include <map> |
---|
| 17 | |
---|
[130] | 18 | #include <casa/aips.h> |
---|
[81] | 19 | #include <casa/Utilities/CountedPtr.h> |
---|
[805] | 20 | #include <casa/BasicSL/String.h> |
---|
| 21 | #include <casa/Arrays/Vector.h> |
---|
| 22 | #include <scimath/Mathematics/InterpolateArray1D.h> |
---|
[294] | 23 | |
---|
[805] | 24 | #include "Scantable.h" |
---|
[834] | 25 | #include "STDefs.h" |
---|
[896] | 26 | #include "STPol.h" |
---|
[894] | 27 | #include "Logger.h" |
---|
[2] | 28 | |
---|
[83] | 29 | namespace asap { |
---|
[2] | 30 | |
---|
[805] | 31 | /** |
---|
[1106] | 32 | * Mathmatical operations on Scantable objects |
---|
| 33 | * @author Malte Marquarding |
---|
[805] | 34 | */ |
---|
[890] | 35 | class STMath : private Logger { |
---|
[716] | 36 | public: |
---|
[1106] | 37 | // typedef for long method name |
---|
[805] | 38 | typedef casa::InterpolateArray1D<casa::Double, |
---|
| 39 | casa::Float>::InterpolationMethod imethod; |
---|
[299] | 40 | |
---|
[1106] | 41 | // typedef for std::map |
---|
[805] | 42 | typedef std::map<std::string, imethod> imap; |
---|
[177] | 43 | |
---|
[1106] | 44 | /** |
---|
| 45 | * whether to operate on the given Scantable or return a new one |
---|
| 46 | * @param insitu the toggle for this behaviour |
---|
| 47 | */ |
---|
[805] | 48 | STMath(bool insitu=true); |
---|
[221] | 49 | |
---|
[995] | 50 | virtual ~STMath(); |
---|
[227] | 51 | |
---|
[805] | 52 | /** |
---|
[1106] | 53 | * get the currnt @attr inistu state |
---|
[805] | 54 | */ |
---|
| 55 | bool insitu() const { return insitu_;}; |
---|
[1106] | 56 | |
---|
| 57 | /** |
---|
| 58 | * set the currnt @attr inistu state |
---|
| 59 | * @param b the new state |
---|
| 60 | */ |
---|
[805] | 61 | void setInsitu(bool b) { insitu_ = b; }; |
---|
[262] | 62 | |
---|
[1106] | 63 | |
---|
| 64 | /** |
---|
| 65 | * average a vector of Scantables |
---|
| 66 | * @param in the vector of Scantables to average |
---|
| 67 | * @param an optional mask to apply on specific weights |
---|
| 68 | * @param weight weighting scheme |
---|
| 69 | * @param avmode the mode ov averaging. Per "SCAN" or "ALL". |
---|
| 70 | * @return a casa::CountedPtr<Scantable> which either holds a new Scantable |
---|
| 71 | * or returns the imput pointer. |
---|
| 72 | */ |
---|
[805] | 73 | casa::CountedPtr<Scantable> |
---|
| 74 | average( const std::vector<casa::CountedPtr<Scantable> >& in, |
---|
[858] | 75 | const std::vector<bool>& mask = std::vector<bool>(), |
---|
| 76 | const std::string& weight = "NONE", |
---|
[977] | 77 | const std::string& avmode = "SCAN"); |
---|
[1066] | 78 | |
---|
[1106] | 79 | /** |
---|
| 80 | * median average a vector of Scantables. See also STMath::average |
---|
| 81 | * @param in the Scantable to average |
---|
| 82 | * @param mode the averaging mode. Currently only "MEDIAN" |
---|
| 83 | * @param avmode the mode ov averaging. Per "SCAN" or "ALL". |
---|
| 84 | * @return a casa::CountedPtr<Scantable> which either holds a new Scantable |
---|
| 85 | * or returns the imput pointer. |
---|
| 86 | */ |
---|
[1069] | 87 | casa::CountedPtr<Scantable> |
---|
| 88 | averageChannel( const casa::CountedPtr<Scantable> & in, |
---|
[1078] | 89 | const std::string& mode = "MEDIAN", |
---|
| 90 | const std::string& avmode = "SCAN"); |
---|
[1069] | 91 | |
---|
[940] | 92 | casa::CountedPtr< Scantable > |
---|
| 93 | averagePolarisations( const casa::CountedPtr< Scantable > & in, |
---|
| 94 | const std::vector<bool>& mask, |
---|
| 95 | const std::string& weight ); |
---|
[234] | 96 | |
---|
[805] | 97 | casa::CountedPtr<Scantable> |
---|
| 98 | unaryOperate( const casa::CountedPtr<Scantable>& in, float val, |
---|
| 99 | const std::string& mode, bool tsys=false ); |
---|
[169] | 100 | |
---|
[1066] | 101 | casa::CountedPtr<Scantable> autoQuotient(const casa::CountedPtr<Scantable>& in, |
---|
| 102 | const std::string& mode = "NEAREST", |
---|
| 103 | bool preserve = true); |
---|
| 104 | |
---|
| 105 | casa::CountedPtr<Scantable> quotient( const casa::CountedPtr<Scantable>& on, |
---|
| 106 | const casa::CountedPtr<Scantable>& off, |
---|
[805] | 107 | bool preserve = true ); |
---|
[169] | 108 | |
---|
[805] | 109 | casa::CountedPtr<Scantable> |
---|
| 110 | freqSwitch( const casa::CountedPtr<Scantable>& in ); |
---|
[716] | 111 | |
---|
[805] | 112 | std::vector<float> statistic(const casa::CountedPtr<Scantable>& in, |
---|
| 113 | const std::vector<bool>& mask, |
---|
| 114 | const std::string& which); |
---|
[457] | 115 | |
---|
[805] | 116 | casa::CountedPtr<Scantable> bin( const casa::CountedPtr<Scantable>& in, |
---|
| 117 | int width=5); |
---|
| 118 | casa::CountedPtr<Scantable> |
---|
| 119 | resample(const casa::CountedPtr<Scantable>& in, |
---|
| 120 | const std::string& method, float width); |
---|
[457] | 121 | |
---|
[805] | 122 | casa::CountedPtr<Scantable> |
---|
| 123 | smooth(const casa::CountedPtr<Scantable>& in, const std::string& kernel, |
---|
[995] | 124 | float width); |
---|
[169] | 125 | |
---|
[805] | 126 | casa::CountedPtr<Scantable> |
---|
| 127 | gainElevation(const casa::CountedPtr<Scantable>& in, |
---|
[867] | 128 | const std::vector<float>& coeff, |
---|
[805] | 129 | const std::string& fileName, |
---|
[995] | 130 | const std::string& method); |
---|
[805] | 131 | casa::CountedPtr<Scantable> |
---|
| 132 | convertFlux(const casa::CountedPtr<Scantable>& in, float d, |
---|
| 133 | float etaap, float jyperk); |
---|
[152] | 134 | |
---|
[805] | 135 | casa::CountedPtr<Scantable> opacity(const casa::CountedPtr<Scantable>& in, |
---|
| 136 | float tau); |
---|
[144] | 137 | |
---|
[841] | 138 | casa::CountedPtr<Scantable> |
---|
| 139 | merge(const std::vector<casa::CountedPtr<Scantable> >& in); |
---|
| 140 | |
---|
[896] | 141 | casa::CountedPtr<Scantable> |
---|
| 142 | invertPhase( const casa::CountedPtr<Scantable>& in); |
---|
[912] | 143 | |
---|
[896] | 144 | casa::CountedPtr<Scantable> |
---|
| 145 | rotateXYPhase( const casa::CountedPtr<Scantable>& in, float phase); |
---|
[912] | 146 | |
---|
[896] | 147 | casa::CountedPtr<Scantable> |
---|
| 148 | rotateLinPolPhase( const casa::CountedPtr<Scantable>& in, float phase); |
---|
| 149 | |
---|
| 150 | casa::CountedPtr<Scantable> |
---|
| 151 | swapPolarisations(const casa::CountedPtr<Scantable>& in); |
---|
| 152 | |
---|
[917] | 153 | casa::CountedPtr<Scantable> |
---|
| 154 | frequencyAlign( const casa::CountedPtr<Scantable>& in, |
---|
[927] | 155 | const std::string& refTime = "", |
---|
| 156 | const std::string& method = "cubic" ); |
---|
[917] | 157 | |
---|
[992] | 158 | casa::CountedPtr<Scantable> |
---|
| 159 | convertPolarisation( const casa::CountedPtr<Scantable>& in, |
---|
| 160 | const std::string& newtype); |
---|
| 161 | |
---|
[805] | 162 | private: |
---|
[896] | 163 | casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in, |
---|
| 164 | STPol::polOperation fptr, |
---|
| 165 | casa::Float phase); |
---|
| 166 | |
---|
[805] | 167 | static imethod stringToIMethod(const std::string& in); |
---|
| 168 | static WeightType stringToWeight(const std::string& in); |
---|
[146] | 169 | |
---|
[805] | 170 | void scaleByVector(casa::Table& in, |
---|
| 171 | const casa::Vector<casa::Float>& factor, |
---|
| 172 | bool dotsys); |
---|
[152] | 173 | |
---|
[805] | 174 | void scaleFromAsciiTable(casa::Table& in, const std::string& filename, |
---|
| 175 | const std::string& method, |
---|
| 176 | const casa::Vector<casa::Float>& xout, |
---|
| 177 | bool dotsys); |
---|
[162] | 178 | |
---|
[805] | 179 | void scaleFromTable(casa::Table& in, const casa::Table& table, |
---|
| 180 | const std::string& method, |
---|
| 181 | const casa::Vector<casa::Float>& xout, bool dotsys); |
---|
[227] | 182 | |
---|
[805] | 183 | void convertBrightnessUnits(casa::CountedPtr<Scantable>& in, |
---|
| 184 | bool tokelvin, float cfac); |
---|
[227] | 185 | |
---|
[805] | 186 | casa::CountedPtr< Scantable > |
---|
| 187 | getScantable(const casa::CountedPtr< Scantable >& in, bool droprows); |
---|
[230] | 188 | |
---|
[805] | 189 | casa::MaskedArray<casa::Float> |
---|
| 190 | maskedArray( const casa::Vector<casa::Float>& s, |
---|
| 191 | const casa::Vector<casa::uChar>& f ); |
---|
| 192 | casa::Vector<casa::uChar> |
---|
| 193 | flagsFromMA(const casa::MaskedArray<casa::Float>& ma); |
---|
[230] | 194 | |
---|
[805] | 195 | bool insitu_; |
---|
| 196 | }; |
---|
[234] | 197 | |
---|
[805] | 198 | } |
---|
[165] | 199 | #endif |
---|