source: branches/Release12/src/python_SDMath.cc@ 1340

Last change on this file since 1340 was 798, checked in by phi196, 19 years ago

Added swap_pol & invert_phase

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1//#---------------------------------------------------------------------------
2//# python_SDMath.cc: python exposure of c++ SDMath class
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#include <boost/python.hpp>
32#include <vector>
33
34#include <casa/aips.h>
35#include <casa/Containers/Block.h>
36#include <casa/Utilities/CountedPtr.cc>
37
38#include "SDMathWrapper.h"
39#include "SDMath.h"
40
41using namespace casa;
42using namespace boost::python;
43
44namespace asap {
45 namespace SDMathWrapper {
46 SDMemTableWrapper SDMathWrapper::average(boost::python::tuple tp,
47 const std::vector<bool>& mask,
48 bool scanAv,
49 const std::string& weightStr) {
50 int n;
51 n = extract<int>(tp.attr("__len__")());
52 std::vector<CountedPtr<asap::SDMemTable> > b(n);
53 //Block<CountedPtr<asap::SDMemTable> > b(n);
54 for (int i=0;i< n;++i) {
55 SDMemTableWrapper sdmw =
56 extract<SDMemTableWrapper>( tp.attr("__getitem__")(i) );
57 b[i] = sdmw.getCP();
58 }
59 Vector<Bool> msk(mask);
60
61 return SDMemTableWrapper(sdmath.average(b, msk, Bool(scanAv), weightStr));
62 };
63 } // namespace SDMathWrapper
64
65 namespace python {
66 void python_SDMath() {
67 def("b_operate", &SDMathWrapper::binaryOperate);
68
69 def("quotient", &SDMathWrapper::quotient);
70
71 def("scale", &SDMathWrapper::scale);
72 def("scale_insitu", &SDMathWrapper::scaleInSitu);
73
74 def("add", &SDMathWrapper::add);
75 def("add_insitu", &SDMathWrapper::addInSitu);
76
77 def("smooth", &SDMathWrapper::smooth);
78 def("smooth_insitu", &SDMathWrapper::smoothInSitu);
79
80 def("convertflux", &SDMathWrapper::convertFlux);
81 def("convertflux_insitu", &SDMathWrapper::convertFluxInSitu);
82
83 def("gainel", &SDMathWrapper::gainElevation);
84 def("gainel_insitu", &SDMathWrapper::gainElevationInSitu);
85
86 def("freq_align", &SDMathWrapper::frequencyAlignment);
87 def("freq_align_insitu", &SDMathWrapper::frequencyAlignmentInSitu);
88
89 def("opacity", &SDMathWrapper::opacity);
90 def("opacity_insitu", &SDMathWrapper::opacityInSitu);
91
92 def("average", &SDMathWrapper::average);
93
94 def("averagepol", &SDMathWrapper::averagePol);
95 def("averagepol_insitu", &SDMathWrapper::averagePolInSitu);
96
97 def("bin", &SDMathWrapper::bin);
98 def("bin_insitu", &SDMathWrapper::binInSitu);
99
100 def("resample", &SDMathWrapper::resample);
101 def("resample_insitu", &SDMathWrapper::resampleInSitu);
102
103 def("stats", &SDMathWrapper::statistic);
104
105 def("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu);
106 def("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu);
107
108 def("_invert_phase", &SDMathWrapper::invertPhaseInSitu);
109 def("_swap_pol", &SDMathWrapper::swapPolInSitu);
110
111
112 def("_frequency_switch", &SDMathWrapper::frequencySwitch);
113 def("_frequency_switch_insitu", &SDMathWrapper::frequencySwitchInSitu);
114 };
115
116 } // python
117} // asap
118
Note: See TracBrowser for help on using the repository browser.