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

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