Changeset 2791


Ignore:
Timestamp:
03/15/13 14:36:12 (12 years ago)
Author:
Malte Marquarding
Message:

Ticket #289: added anility to set Tsys, both for scalar and vector values

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r2771 r2791  
    907907        """
    908908        return self._get_column( self._gettsysspectrum, row )
     909
     910    def set_tsys(self, values, row=-1):
     911        """\
     912        Set the Tsys value(s) of the given 'row' or the whole scantable
     913        (selection).
     914       
     915        Parameters:
     916
     917            values:    a scalar or list (if Tsys is a vector) of Tsys value(s)
     918            row:       the row number to apply Tsys values to.
     919                       (default all rows)
     920                       
     921        """
     922           
     923        if not hasattr(values, "__len__"):
     924            values = [values]
     925        self._settsys(values, row)
    909926
    910927    def get_weather(self, row=-1):
  • trunk/src/Scantable.cpp

    r2789 r2791  
    55//
    66//
    7 // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2005
     7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2005-2013
    88//
    99// Copyright: See COPYING file that comes with this distribution
     
    51685168}
    51695169
     5170void Scantable::setTsys(const std::vector<float>& newvals, int whichrow) {
     5171  Vector<Float> tsys(newvals);
     5172  if (whichrow > -1) {
     5173    if (tsysCol_.shape(whichrow) != tsys.shape())
     5174      throw(AipsError("Given Tsys values are not of the same shape"));
     5175    tsysCol_.put(whichrow, tsys);
     5176  } else {
     5177    tsysCol_.fillColumn(tsys);
     5178  }
     5179}
     5180
    51705181vector<float> Scantable::getTsysSpectrum( int whichrow ) const
    51715182{
  • trunk/src/Scantable.h

    r2789 r2791  
    342342    { return casa::Vector<casa::Float>(tsysCol_(whichrow))(0); }
    343343  std::vector<float> getTsysSpectrum(int whichrow) const ;
     344 
     345  void setTsys(const std::vector<float>& newvals, int whichrow);
     346
    344347  float getElevation(int whichrow) const
    345348    { return elCol_(whichrow); }
  • trunk/src/ScantableWrapper.h

    r2789 r2791  
    9393    { return table_->getTsysSpectrum(whichrow); }
    9494
     95  void setTsys(const std::vector<float>& newvals, int whichrow=-1)
     96  { return table_->setTsys(newvals, whichrow); }
     97
    9598  //std::string getTime(int whichrow=0) const
    9699  //  { return table_->getTime(whichrow); }
  • trunk/src/python_Scantable.cpp

    r2789 r2791  
    9494    .def("_gettsys", &ScantableWrapper::getTsys)
    9595    .def("_gettsysspectrum", &ScantableWrapper::getTsysSpectrum )
     96    .def("_settsys", &ScantableWrapper::setTsys)
    9697    .def("_getsourcename", &ScantableWrapper::getSourceName,
    9798         (boost::python::arg("whichrow")=0) )
  • trunk/test/test_scantable.py

    r2787 r2791  
    120120    def test_get_tsys(self):
    121121        assert_almost_equal(self.st.get_tsys()[0], 175.830429077)
     122
     123    def test_set_tsys(self):
     124        s = self.st.copy()
     125        newval = 100.0
     126        s.set_tsys(newval, 0)
     127        assert_almost_equal(s.get_tsys()[0], newval)
     128        s2 = self.st.copy()
     129        s2.set_tsys(newval)
     130        out = s2.get_tsys()
     131        for i in xrange(len(out)):
     132            assert_almost_equal(out[i], newval)
    122133
    123134    def test_get_time(self):
Note: See TracChangeset for help on using the changeset viewer.