[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] | 41 | using namespace casa;
|
---|
[2] | 42 | using namespace boost::python;
|
---|
| 43 |
|
---|
[83] | 44 | namespace 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);
|
---|
[653] | 60 | //
|
---|
[170] | 61 | SDMath sdm;
|
---|
| 62 | return SDMemTableWrapper(sdm.average(b, msk, Bool(scanAv), weightStr));
|
---|
[69] | 63 | };
|
---|
| 64 | } // namespace SDMathWrapper
|
---|
| 65 |
|
---|
[2] | 66 | namespace python {
|
---|
[69] | 67 | void python_SDMath() {
|
---|
[250] | 68 | def("b_operate", &SDMathWrapper::binaryOperate);
|
---|
[653] | 69 | //
|
---|
[69] | 70 | def("quotient", &SDMathWrapper::quotient);
|
---|
[167] | 71 | //
|
---|
[86] | 72 | def("scale", &SDMathWrapper::scale);
|
---|
[140] | 73 | def("scale_insitu", &SDMathWrapper::scaleInSitu);
|
---|
[167] | 74 | //
|
---|
[107] | 75 | def("add", &SDMathWrapper::add);
|
---|
[153] | 76 | def("add_insitu", &SDMathWrapper::addInSitu);
|
---|
[167] | 77 | //
|
---|
[178] | 78 | def("smooth", &SDMathWrapper::smooth);
|
---|
| 79 | def("smooth_insitu", &SDMathWrapper::smoothInSitu);
|
---|
[167] | 80 | //
|
---|
[223] | 81 | def("convertflux", &SDMathWrapper::convertFlux);
|
---|
| 82 | def("convertflux_insitu", &SDMathWrapper::convertFluxInSitu);
|
---|
| 83 | //
|
---|
[227] | 84 | def("gainel", &SDMathWrapper::gainElevation);
|
---|
| 85 | def("gainel_insitu", &SDMathWrapper::gainElevationInSitu);
|
---|
| 86 | //
|
---|
[311] | 87 | def("freq_align", &SDMathWrapper::frequencyAlignment);
|
---|
| 88 | def("freq_align_insitu", &SDMathWrapper::frequencyAlignmentInSitu);
|
---|
[264] | 89 | //
|
---|
[237] | 90 | def("opacity", &SDMathWrapper::opacity);
|
---|
| 91 | def("opacity_insitu", &SDMathWrapper::opacityInSitu);
|
---|
| 92 | //
|
---|
[145] | 93 | def("average", &SDMathWrapper::average);
|
---|
[167] | 94 | //
|
---|
[69] | 95 | def("averagepol", &SDMathWrapper::averagePol);
|
---|
[165] | 96 | def("averagepol_insitu", &SDMathWrapper::averagePolInSitu);
|
---|
[167] | 97 | //
|
---|
[69] | 98 | def("bin", &SDMathWrapper::bin);
|
---|
[167] | 99 | def("bin_insitu", &SDMathWrapper::binInSitu);
|
---|
| 100 | //
|
---|
[300] | 101 | def("resample", &SDMathWrapper::resample);
|
---|
| 102 | def("resample_insitu", &SDMathWrapper::resampleInSitu);
|
---|
| 103 | //
|
---|
[133] | 104 | def("stats", &SDMathWrapper::statistic);
|
---|
[457] | 105 | //
|
---|
[502] | 106 | def ("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu);
|
---|
| 107 | def ("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu);
|
---|
[69] | 108 | };
|
---|
[86] | 109 |
|
---|
[2] | 110 | } // python
|
---|
[83] | 111 | } // asap
|
---|
[55] | 112 |
|
---|