Changeset 872 for trunk/src/STMathWrapper.h
- Timestamp:
- 03/06/06 11:24:02 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMathWrapper.h
r871 r872 1 //#--------------------------------------------------------------------------- 2 //# SDMathWrapper.h: Wrapper classes to use CountedPtr 3 //#--------------------------------------------------------------------------- 4 //# Copyright (C) 2004 5 //# ATNF 6 //# 7 //# This program is free software; you can redistribute it and/or modify it 8 //# under the terms of the GNU General Public License as published by the Free 9 //# Software Foundation; either version 2 of the License, or (at your option) 10 //# any later version. 11 //# 12 //# This program is distributed in the hope that it will be useful, but 13 //# WITHOUT ANY WARRANTY; without even the implied warranty of 14 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 //# Public License for more details. 16 //# 17 //# You should have received a copy of the GNU General Public License along 18 //# with this program; if not, write to the Free Software Foundation, Inc., 19 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. 20 //# 21 //# Correspondence concerning this software should be addressed as follows: 22 //# Internet email: Malte.Marquarding@csiro.au 23 //# Postal address: Malte Marquarding, 24 //# Australia Telescope National Facility, 25 //# P.O. Box 76, 26 //# Epping, NSW, 2121, 27 //# AUSTRALIA 28 //# 29 //# $Id: 30 //#--------------------------------------------------------------------------- 31 #ifndef SDMATHWRAPPER_H 32 #define SDMATHWRAPPER_H 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 33 14 34 15 #include <vector> 35 16 #include <string> 36 17 37 #include < boost/python/tuple.hpp>18 #include <casa/Utilities/CountedPtr.h> 38 19 39 #include "SDMemTableWrapper.h" 40 #include "SDMath.h" 20 #include "STMath.h" 21 #include "Scantable.h" 22 #include "ScantableWrapper.h" 41 23 42 24 namespace asap { 43 25 44 namespace SDMathWrapper { 26 /** 27 Wrapper class to handle ScantableWrapper 45 28 29 @author Malte Marquarding 30 */ 31 class STMathWrapper : public STMath { 32 public: 33 STMathWrapper() {;} 34 STMathWrapper(bool insitu) : STMath(insitu) {;} 46 35 47 static SDMath sdmath; 48 // Quotient 49 SDMemTableWrapper quotient(const SDMemTableWrapper& on, 50 const SDMemTableWrapper& off, 51 casa::Bool preserveContinuum); 36 virtual ~STMathWrapper() {;} 52 37 53 // Simple binary operations 54 SDMemTableWrapper binaryOperate(const SDMemTableWrapper& left, 55 const SDMemTableWrapper& right, 56 const std::string& op, bool doTSys); 57 58 // Multiply 59 void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, 60 bool doTSys); 61 SDMemTableWrapper scale(const SDMemTableWrapper& in, float factor, 62 bool all, bool doTSys); 63 64 // Add 65 void addInSitu(SDMemTableWrapper& in, float offset, bool doAall); 66 SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all); 38 ScantableWrapper 39 average( const std::vector<ScantableWrapper>& in, 40 const std::vector<bool>& mask, 41 const std::string& weight, 42 const std::string& avmode, 43 bool alignfreq) 44 { 45 std::vector<casa::CountedPtr<Scantable> > sts; 46 for (int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP()); 47 return ScantableWrapper(STMath::average(sts, mask, weight, avmode, alignfreq)); 48 } 67 49 68 // Smooth 69 void smoothInSitu(SDMemTableWrapper& in, const std::string& kernel, 70 float width, bool doAll); 71 SDMemTableWrapper smooth(const SDMemTableWrapper& in, 72 const std::string& kernel, float width, bool doAll); 50 ScantableWrapper 51 unaryOperate( const ScantableWrapper& in, float val, 52 const std::string& mode, bool tsys=false ) 53 { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys)); } 73 54 74 // Bin up 75 void binInSitu(SDMemTableWrapper& in, int width); 76 SDMemTableWrapper bin(const SDMemTableWrapper& in, int width); 55 ScantableWrapper quotient( const ScantableWrapper& in, 56 const std::string& mode = "NEAREST", 57 bool preserve = true ) 58 { return ScantableWrapper(STMath::quotient(in.getCP(), mode, preserve)); } 77 59 78 // Resample 79 void resampleInSitu(SDMemTableWrapper& in, const std::string& method, 80 float width); 81 SDMemTableWrapper resample(const SDMemTableWrapper& in, 82 const std::string& method, 83 float width); 60 ScantableWrapper 61 freqSwitch( const ScantableWrapper& in ) 62 { return ScantableWrapper(STMath::freqSwitch(in.getCP())); } 84 63 85 // Convert brightness between Jy and K 86 void convertFluxInSitu(SDMemTableWrapper& in, float D, float eta, 87 float JyPerK, bool doAll); 88 SDMemTableWrapper convertFlux(const SDMemTableWrapper& in, float D, 89 float eta, float JyPerK, bool doAll); 64 std::vector<float> statistic(const ScantableWrapper& in, 65 const std::vector<bool>& mask, 66 const std::string& which) 67 { return STMath::statistic(in.getCP(), mask, which); } 90 68 91 // Apply gain elevation correction 92 void gainElevationInSitu (SDMemTableWrapper& in, const std::vector<float>& coeffs, 93 const std::string& fileName, 94 const std::string& method, bool doAll); 95 SDMemTableWrapper gainElevation(const SDMemTableWrapper& in, const std::vector<float>& coeffs, 96 const std::string& fileName, 97 const std::string& method, bool doAll); 69 ScantableWrapper bin( const ScantableWrapper& in, int width=5) 70 { return ScantableWrapper(STMath::bin(in.getCP(), width)); } 98 71 99 // Apply frequency alignment 100 void frequencyAlignmentInSitu (SDMemTableWrapper& in, const std::string& refTime, 101 const std::string& method, bool perFreqID); 102 SDMemTableWrapper frequencyAlignment(const SDMemTableWrapper& in, const std::string& refTime, 103 const std::string& method, bool perFreqID); 72 ScantableWrapper 73 resample(const ScantableWrapper& in, 74 const std::string& method, float width) 75 { return ScantableWrapper(STMath::resample(in.getCP(), method, width)); } 104 76 105 // XY Phase rotation 106 void rotateXYPhaseInSitu(SDMemTableWrapper& in, float angle, bool doAll); 77 ScantableWrapper 78 smooth(const ScantableWrapper& in, const std::string& kernel, float width) 79 { return ScantableWrapper(STMath::smooth(in.getCP(), kernel, width)); } 107 80 108 // LinPol Phase rotation 109 void rotateLinPolPhaseInSitu(SDMemTableWrapper& in, float angle, bool doAll); 81 ScantableWrapper 82 gainElevation(const ScantableWrapper& in, 83 const std::vector<float>& coeff, 84 const std::string& filename, 85 const std::string& method) 110 86 111 // Apply opacity correction 112 void opacityInSitu(SDMemTableWrapper& in, float tau, bool doAll); 113 SDMemTableWrapper opacity(const SDMemTableWrapper& in, float tau, 114 bool doAll); 87 { return 88 ScantableWrapper(STMath::gainElevation(in.getCP(), coeff, filename, method)); } 115 89 116 // Average in time 117 SDMemTableWrapper average(boost::python::tuple tpl,118 const std::vector<bool>& mask, 119 bool scanAv, const std::string& wt); 90 ScantableWrapper 91 convertFlux(const ScantableWrapper& in, float d, 92 float etaap, float jyperk) 93 { return ScantableWrapper(STMath::convertFlux(in.getCP(), d, etaap, jyperk)); } 120 94 121 // Average polarizations 122 void averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask, 123 const std::string& weightStr); 124 SDMemTableWrapper averagePol(const SDMemTableWrapper& in, 125 const std::vector<bool>& mask, 126 const std::string& weightStr); 95 ScantableWrapper opacity(const ScantableWrapper& in, 96 float tau) 97 { return ScantableWrapper(STMath::opacity(in.getCP(), tau)); } 127 98 128 // Frequency Switching129 void SDMathWrapper::frequencySwitchInSitu(SDMemTableWrapper& in);99 ScantableWrapper 100 merge(const std::vector<ScantableWrapper >& in) 130 101 131 SDMemTableWrapper 132 SDMathWrapper::frequencySwitch(const SDMemTableWrapper& in); 133 134 // Statistics 135 std::vector<float> statistic(const SDMemTableWrapper& in, 136 const std::vector<bool>& mask, 137 const std::string& which, int row); 102 { 103 std::vector<casa::CountedPtr<Scantable> > sts; 104 for (int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP()); 105 return ScantableWrapper(STMath::merge(sts)); } 138 106 139 107 }; 140 108 141 } // namespace 109 } 110 142 111 #endif
Note: See TracChangeset
for help on using the changeset viewer.