Changeset 2320 for trunk/python


Ignore:
Timestamp:
10/04/11 13:40:03 (13 years ago)
Author:
Malte Marquarding
Message:

Ticket #251: fixed copy of input scantable which breaks scantable selection

Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapmath.py

    r2150 r2320  
    10121012
    10131013@asaplog_post_dec
    1014 def _array2dOp( scan, value, mode="ADD", tsys=False ):
     1014def _array2dOp( scan, value, mode="ADD", tsys=False, insitu=None):
    10151015    """
    10161016    This function is workaround on the basic operation of scantable
     
    10241024    nrow = scan.nrow()
    10251025    s = None
     1026    from asap._asap import stmath
     1027    stm = stmath()
     1028    stm._setinsitu(insitu)
    10261029    if len( value ) == 1:
    1027         from asap._asap import stmath
    1028         stm = stmath()
    1029         s = scantable( stm._arrayop( scan.copy(), value[0], mode, tsys ) )
    1030         del stm
     1030        s = scantable( stm._arrayop( scan, value[0], mode, tsys ) )
    10311031    elif len( value ) != nrow:
    10321032        raise ValueError( 'len(value) must be 1 or conform to scan.nrow()' )
    10331033    else:
    10341034        from asap._asap import stmath
    1035         stm = stmath()
    1036         # insitu must be True
     1035        if not insitu:
     1036            s = scan.copy()
     1037        else:
     1038            s = scan
     1039        # insitu must be True as we go row by row on the same data
    10371040        stm._setinsitu( True )
    1038         s = scan.copy()
    1039         sel = selector()
     1041        basesel = s.get_selection()
     1042        sel = selector()+basesel
    10401043        for irow in range( nrow ):
    10411044            sel.set_rows( irow )
     
    10461049                #stm._arrayop( s, value[irow], mode, tsys, 'channel' )
    10471050                stm._arrayop( s, value[irow], mode, tsys )
    1048             s.set_selection()
    1049             sel.reset()
    1050         del sel
    1051         del stm
     1051        s.set_selection(basesel)
    10521052    return s
  • trunk/python/scantable.py

    r2315 r2320  
    575575                for k in kw:
    576576                    if k not in selector.fields:
    577                         raise KeyError("Invalid selection key '%s', valid keys are %s" % (k, selector.fields))
     577                        raise KeyError("Invalid selection key '%s', "
     578                                       "valid keys are %s" % (k,
     579                                                              selector.fields))
    578580                selection = selector(**kw)
    579581        self._setselection(selection)
     
    31163118        import numpy
    31173119        if isinstance(factor, list) or isinstance(factor, numpy.ndarray):
    3118             if isinstance(factor[0], list) or isinstance(factor[0], numpy.ndarray):
     3120            if isinstance(factor[0], list) or isinstance(factor[0],
     3121                                                         numpy.ndarray):
    31193122                from asapmath import _array2dOp
    3120                 s = _array2dOp( self.copy(), factor, "MUL", tsys )
     3123                s = _array2dOp( self, factor, "MUL", tsys, insitu )
    31213124            else:
    3122                 s = scantable( self._math._arrayop( self.copy(), factor, "MUL", tsys ) )
     3125                s = scantable( self._math._arrayop( self, factor,
     3126                                                    "MUL", tsys ) )
    31233127        else:
    3124             s = scantable(self._math._unaryop(self.copy(), factor, "MUL", tsys))
     3128            s = scantable(self._math._unaryop(self, factor, "MUL", tsys))
    31253129        s._add_history("scale", varlist)
    31263130        if insitu:
Note: See TracChangeset for help on using the changeset viewer.