[872] | 1 | //
|
---|
| 2 | // C++ Interface: STMathWrapper
|
---|
| 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 ASAPSTMATHWRAPPER_H
|
---|
| 13 | #define ASAPSTMATHWRAPPER_H
|
---|
[49] | 14 |
|
---|
| 15 | #include <vector>
|
---|
| 16 | #include <string>
|
---|
| 17 |
|
---|
[872] | 18 | #include <casa/Utilities/CountedPtr.h>
|
---|
[49] | 19 |
|
---|
[872] | 20 | #include "STMath.h"
|
---|
| 21 | #include "Scantable.h"
|
---|
| 22 | #include "ScantableWrapper.h"
|
---|
[49] | 23 |
|
---|
[83] | 24 | namespace asap {
|
---|
[49] | 25 |
|
---|
[872] | 26 | /**
|
---|
| 27 | Wrapper class to handle ScantableWrapper
|
---|
[49] | 28 |
|
---|
[872] | 29 | @author Malte Marquarding
|
---|
| 30 | */
|
---|
| 31 | class STMathWrapper : public STMath {
|
---|
| 32 | public:
|
---|
| 33 | STMathWrapper() {;}
|
---|
[1353] | 34 | explicit STMathWrapper(bool insitu) : STMath(insitu) {;}
|
---|
[716] | 35 |
|
---|
[872] | 36 | virtual ~STMathWrapper() {;}
|
---|
[49] | 37 |
|
---|
[872] | 38 | ScantableWrapper
|
---|
| 39 | average( const std::vector<ScantableWrapper>& in,
|
---|
| 40 | const std::vector<bool>& mask,
|
---|
| 41 | const std::string& weight,
|
---|
[977] | 42 | const std::string& avmode )
|
---|
[872] | 43 | {
|
---|
| 44 | std::vector<casa::CountedPtr<Scantable> > sts;
|
---|
[996] | 45 | for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP());
|
---|
[978] | 46 | return ScantableWrapper(STMath::average(sts, mask, weight, avmode));
|
---|
[872] | 47 | }
|
---|
[1069] | 48 |
|
---|
[940] | 49 | ScantableWrapper
|
---|
[1069] | 50 | averageChannel( const ScantableWrapper& in,
|
---|
[1078] | 51 | const std::string& mode = "MEDIAN",
|
---|
| 52 | const std::string& avmode = "NONE")
|
---|
[1069] | 53 | {
|
---|
[1078] | 54 | return ScantableWrapper(STMath::averageChannel(in.getCP(), mode, avmode));
|
---|
[1069] | 55 | }
|
---|
| 56 |
|
---|
| 57 | ScantableWrapper
|
---|
[940] | 58 | averagePolarisations( const ScantableWrapper& in,
|
---|
| 59 | const std::vector<bool>& mask,
|
---|
| 60 | const std::string& weight)
|
---|
| 61 | { return ScantableWrapper(STMath::averagePolarisations(in.getCP(),mask, weight));}
|
---|
[107] | 62 |
|
---|
[872] | 63 | ScantableWrapper
|
---|
[1145] | 64 | averageBeams( const ScantableWrapper& in,
|
---|
| 65 | const std::vector<bool>& mask,
|
---|
| 66 | const std::string& weight)
|
---|
| 67 |
|
---|
| 68 | { return ScantableWrapper(STMath::averageBeams(in.getCP(),mask, weight));}
|
---|
| 69 |
|
---|
| 70 | ScantableWrapper
|
---|
[872] | 71 | unaryOperate( const ScantableWrapper& in, float val,
|
---|
[2952] | 72 | const std::string& mode, bool tsys=false,
|
---|
| 73 | bool skip_flaggedrow=false )
|
---|
| 74 | { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys, skip_flaggedrow)); }
|
---|
[49] | 75 |
|
---|
[1819] | 76 | ScantableWrapper arrayOperate( const ScantableWrapper& in,
|
---|
| 77 | const std::vector<float> val,
|
---|
| 78 | const std::string& mode,
|
---|
[2952] | 79 | bool tsys=false,
|
---|
| 80 | bool skip_flaggedrow=false )
|
---|
| 81 | { return ScantableWrapper(STMath::arrayOperateChannel(in.getCP(), val, mode, tsys, skip_flaggedrow)); }
|
---|
[1819] | 82 |
|
---|
| 83 | ScantableWrapper array2dOperate( const ScantableWrapper& in,
|
---|
| 84 | const std::vector< std::vector<float> > val,
|
---|
| 85 | const std::string& mode, bool tsys=false )
|
---|
| 86 | { return ScantableWrapper(STMath::array2dOperate(in.getCP(), val, mode, tsys)); }
|
---|
| 87 |
|
---|
[1308] | 88 | ScantableWrapper binaryOperate( const ScantableWrapper& left,
|
---|
| 89 | const ScantableWrapper& right,
|
---|
| 90 | const std::string& mode)
|
---|
| 91 | { return ScantableWrapper( STMath::binaryOperate( left.getCP(), right.getCP(),
|
---|
| 92 | mode ) ); }
|
---|
| 93 |
|
---|
| 94 |
|
---|
[1066] | 95 | ScantableWrapper autoQuotient( const ScantableWrapper& in,
|
---|
| 96 | const std::string& mode = "NEAREST",
|
---|
| 97 | bool preserve = true )
|
---|
| 98 | { return ScantableWrapper(STMath::autoQuotient(in.getCP(), mode, preserve)); }
|
---|
| 99 |
|
---|
| 100 | ScantableWrapper quotient( const ScantableWrapper& on,
|
---|
| 101 | const ScantableWrapper& off,
|
---|
[872] | 102 | bool preserve = true )
|
---|
[1066] | 103 | { return ScantableWrapper( STMath::quotient( on.getCP(), off.getCP(),
|
---|
| 104 | preserve ) ); }
|
---|
[151] | 105 |
|
---|
[1391] | 106 | ScantableWrapper dototalpower( const ScantableWrapper& calon,
|
---|
| 107 | const ScantableWrapper& caloff, casa::Float tcal= 0 )
|
---|
| 108 | { return ScantableWrapper( STMath::dototalpower( calon.getCP(), caloff.getCP(), tcal ) ); }
|
---|
| 109 |
|
---|
| 110 | ScantableWrapper dosigref( const ScantableWrapper& sig,
|
---|
| 111 | const ScantableWrapper& ref,
|
---|
| 112 | int smoothref = 0, casa::Float tsysv=0.0, casa::Float tau=0.0)
|
---|
| 113 | { return ScantableWrapper( STMath::dosigref( sig.getCP(), ref.getCP(), smoothref, tsysv, tau ) ); }
|
---|
| 114 |
|
---|
| 115 | ScantableWrapper donod( const ScantableWrapper& s,
|
---|
| 116 | const std::vector<int>& scans,
|
---|
| 117 | int smoothref = 0,
|
---|
| 118 | casa::Float tsysv=0.0, casa::Float tau=0.0, casa::Float tcal=0.0 )
|
---|
| 119 | { return ScantableWrapper( STMath::donod( s.getCP(), scans, smoothref, tsysv, tau, tcal ) ); }
|
---|
| 120 |
|
---|
| 121 | ScantableWrapper dofs( const ScantableWrapper& s,
|
---|
| 122 | const std::vector<int>& scans,
|
---|
| 123 | int smoothref = 0,
|
---|
| 124 | casa::Float tsysv=0.0, casa::Float tau=0.0, casa::Float tcal=0.0 )
|
---|
| 125 | { return ScantableWrapper( STMath::dofs( s.getCP(), scans, smoothref, tsysv, tau, tcal ) ); }
|
---|
| 126 |
|
---|
[872] | 127 | ScantableWrapper
|
---|
| 128 | freqSwitch( const ScantableWrapper& in )
|
---|
| 129 | { return ScantableWrapper(STMath::freqSwitch(in.getCP())); }
|
---|
[300] | 130 |
|
---|
[872] | 131 | std::vector<float> statistic(const ScantableWrapper& in,
|
---|
| 132 | const std::vector<bool>& mask,
|
---|
| 133 | const std::string& which)
|
---|
| 134 | { return STMath::statistic(in.getCP(), mask, which); }
|
---|
[222] | 135 |
|
---|
[1907] | 136 | std::vector<float> statisticRow(const ScantableWrapper& in,
|
---|
| 137 | const std::vector<bool>& mask,
|
---|
| 138 | const std::string& which,
|
---|
| 139 | int row)
|
---|
| 140 | { return STMath::statisticRow(in.getCP(), mask, which, row); }
|
---|
| 141 |
|
---|
[1819] | 142 | std::vector<int> minMaxChan(const ScantableWrapper& in,
|
---|
| 143 | const std::vector<bool>& mask,
|
---|
| 144 | const std::string& which)
|
---|
| 145 | { return STMath::minMaxChan(in.getCP(), mask, which); }
|
---|
| 146 |
|
---|
[872] | 147 | ScantableWrapper bin( const ScantableWrapper& in, int width=5)
|
---|
| 148 | { return ScantableWrapper(STMath::bin(in.getCP(), width)); }
|
---|
[228] | 149 |
|
---|
[872] | 150 | ScantableWrapper
|
---|
| 151 | resample(const ScantableWrapper& in,
|
---|
| 152 | const std::string& method, float width)
|
---|
| 153 | { return ScantableWrapper(STMath::resample(in.getCP(), method, width)); }
|
---|
[262] | 154 |
|
---|
[872] | 155 | ScantableWrapper
|
---|
[1570] | 156 | smooth(const ScantableWrapper& in, const std::string& kernel, float width,
|
---|
| 157 | int order=2)
|
---|
| 158 | { return ScantableWrapper(STMath::smooth(in.getCP(), kernel, width, order)); }
|
---|
[457] | 159 |
|
---|
[872] | 160 | ScantableWrapper
|
---|
| 161 | gainElevation(const ScantableWrapper& in,
|
---|
| 162 | const std::vector<float>& coeff,
|
---|
| 163 | const std::string& filename,
|
---|
[996] | 164 | const std::string& method)
|
---|
[503] | 165 |
|
---|
[872] | 166 | { return
|
---|
| 167 | ScantableWrapper(STMath::gainElevation(in.getCP(), coeff, filename, method)); }
|
---|
[235] | 168 |
|
---|
[872] | 169 | ScantableWrapper
|
---|
| 170 | convertFlux(const ScantableWrapper& in, float d,
|
---|
| 171 | float etaap, float jyperk)
|
---|
| 172 | { return ScantableWrapper(STMath::convertFlux(in.getCP(), d, etaap, jyperk)); }
|
---|
[49] | 173 |
|
---|
[872] | 174 | ScantableWrapper opacity(const ScantableWrapper& in,
|
---|
[1689] | 175 | const std::vector<float>& tau)
|
---|
[872] | 176 | { return ScantableWrapper(STMath::opacity(in.getCP(), tau)); }
|
---|
[49] | 177 |
|
---|
[872] | 178 | ScantableWrapper
|
---|
[2900] | 179 | merge(const std::vector<ScantableWrapper >& in,
|
---|
| 180 | const std::string &freqTol)
|
---|
[872] | 181 | {
|
---|
| 182 | std::vector<casa::CountedPtr<Scantable> > sts;
|
---|
[996] | 183 | for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP());
|
---|
[2900] | 184 | return ScantableWrapper(STMath::merge(sts, freqTol)); }
|
---|
[716] | 185 |
|
---|
[912] | 186 | ScantableWrapper rotateXYPhase( const ScantableWrapper& in, float angle)
|
---|
| 187 | { return ScantableWrapper(STMath::rotateXYPhase(in.getCP(), angle)); }
|
---|
| 188 |
|
---|
| 189 | ScantableWrapper rotateLinPolPhase( const ScantableWrapper& in, float angle)
|
---|
| 190 | { return ScantableWrapper(STMath::rotateLinPolPhase(in.getCP(), angle)); }
|
---|
| 191 |
|
---|
| 192 | ScantableWrapper invertPhase( const ScantableWrapper& in )
|
---|
| 193 | { return ScantableWrapper(STMath::invertPhase(in.getCP())); }
|
---|
| 194 |
|
---|
| 195 | ScantableWrapper swapPolarisations( const ScantableWrapper& in )
|
---|
| 196 | { return ScantableWrapper(STMath::swapPolarisations(in.getCP())); }
|
---|
| 197 |
|
---|
[927] | 198 | ScantableWrapper frequencyAlign( const ScantableWrapper& in,
|
---|
| 199 | const std::string& refTime,
|
---|
| 200 | const std::string& method )
|
---|
[2428] | 201 | { return ScantableWrapper(STMath::frequencyAlign(in.getCP(),
|
---|
| 202 | refTime, method)); }
|
---|
[927] | 203 |
|
---|
[992] | 204 | ScantableWrapper convertPolarisation( const ScantableWrapper& in,
|
---|
| 205 | const std::string& newtype )
|
---|
| 206 | { return ScantableWrapper(STMath::convertPolarisation(in.getCP(),newtype)); }
|
---|
[1145] | 207 |
|
---|
[1140] | 208 | ScantableWrapper mxExtract( const ScantableWrapper& in,
|
---|
| 209 | const std::string& scantype="on" )
|
---|
| 210 | { return ScantableWrapper(STMath::mxExtract(in.getCP(),scantype)); }
|
---|
[992] | 211 |
|
---|
[1192] | 212 | ScantableWrapper lagFlag( const ScantableWrapper& in,
|
---|
[1570] | 213 | double start, double end,
|
---|
| 214 | const std::string& mode="frequency" )
|
---|
| 215 | { return ScantableWrapper(STMath::lagFlag(in.getCP(), start, end,
|
---|
| 216 | mode)); }
|
---|
[1192] | 217 |
|
---|
[2177] | 218 | std::vector<float> fft( const ScantableWrapper& in,
|
---|
| 219 | const std::vector<int>& whichrow,
|
---|
| 220 | const bool getRealImag=false )
|
---|
| 221 | { return STMath::fft(in.getCP(), whichrow, getRealImag); }
|
---|
| 222 |
|
---|
[1819] | 223 | // test for average spectra with different channel/resolution
|
---|
| 224 | ScantableWrapper
|
---|
| 225 | new_average( const std::vector<ScantableWrapper>& in,
|
---|
| 226 | const bool& compel,
|
---|
| 227 | const std::vector<bool>& mask,
|
---|
| 228 | const std::string& weight,
|
---|
| 229 | const std::string& avmode )
|
---|
| 230 | {
|
---|
| 231 | std::vector<casa::CountedPtr<Scantable> > sts;
|
---|
| 232 | for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP());
|
---|
| 233 | return ScantableWrapper(STMath::new_average(sts, compel, mask, weight, avmode));
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | // cwcal
|
---|
| 237 | ScantableWrapper cwcal( const ScantableWrapper &in,
|
---|
| 238 | const std::string calmode,
|
---|
| 239 | const std::string antname )
|
---|
| 240 | {
|
---|
| 241 | casa::CountedPtr<Scantable> tab = in.getCP() ;
|
---|
| 242 | casa::String mode( calmode ) ;
|
---|
| 243 | casa::String name( antname ) ;
|
---|
| 244 | return ScantableWrapper( STMath::cwcal( tab, mode, name ) ) ;
|
---|
| 245 | }
|
---|
| 246 | // almacal
|
---|
| 247 | ScantableWrapper almacal( const ScantableWrapper &in,
|
---|
| 248 | const std::string calmode )
|
---|
| 249 | {
|
---|
| 250 | casa::CountedPtr<Scantable> tab = in.getCP() ;
|
---|
| 251 | casa::String mode( calmode ) ;
|
---|
| 252 | return ScantableWrapper( STMath::almacal( tab, mode ) ) ;
|
---|
| 253 | }
|
---|
[49] | 254 | };
|
---|
| 255 |
|
---|
[872] | 256 | }
|
---|
| 257 |
|
---|
[49] | 258 | #endif
|
---|