source: branches/Release-2-fixes/src/python_SDMath.cc@ 2501

Last change on this file since 2501 was 653, checked in by mar637, 19 years ago

changed Blocks to vectors

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 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 SDMath sdm;
62 return SDMemTableWrapper(sdm.average(b, msk, Bool(scanAv), weightStr));
63 };
64 } // namespace SDMathWrapper
65
66 namespace python {
67 void python_SDMath() {
68 def("b_operate", &SDMathWrapper::binaryOperate);
69 //
70 def("quotient", &SDMathWrapper::quotient);
71//
72 def("scale", &SDMathWrapper::scale);
73 def("scale_insitu", &SDMathWrapper::scaleInSitu);
74//
75 def("add", &SDMathWrapper::add);
76 def("add_insitu", &SDMathWrapper::addInSitu);
77//
78 def("smooth", &SDMathWrapper::smooth);
79 def("smooth_insitu", &SDMathWrapper::smoothInSitu);
80//
81 def("convertflux", &SDMathWrapper::convertFlux);
82 def("convertflux_insitu", &SDMathWrapper::convertFluxInSitu);
83//
84 def("gainel", &SDMathWrapper::gainElevation);
85 def("gainel_insitu", &SDMathWrapper::gainElevationInSitu);
86//
87 def("freq_align", &SDMathWrapper::frequencyAlignment);
88 def("freq_align_insitu", &SDMathWrapper::frequencyAlignmentInSitu);
89//
90 def("opacity", &SDMathWrapper::opacity);
91 def("opacity_insitu", &SDMathWrapper::opacityInSitu);
92//
93 def("average", &SDMathWrapper::average);
94//
95 def("averagepol", &SDMathWrapper::averagePol);
96 def("averagepol_insitu", &SDMathWrapper::averagePolInSitu);
97//
98 def("bin", &SDMathWrapper::bin);
99 def("bin_insitu", &SDMathWrapper::binInSitu);
100//
101 def("resample", &SDMathWrapper::resample);
102 def("resample_insitu", &SDMathWrapper::resampleInSitu);
103//
104 def("stats", &SDMathWrapper::statistic);
105//
106 def ("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu);
107 def ("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu);
108 };
109
110 } // python
111} // asap
112
Note: See TracBrowser for help on using the repository browser.