- Timestamp:
- 10/04/11 13:40:03 (13 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r2150 r2320 1012 1012 1013 1013 @asaplog_post_dec 1014 def _array2dOp( scan, value, mode="ADD", tsys=False 1014 def _array2dOp( scan, value, mode="ADD", tsys=False, insitu=None): 1015 1015 """ 1016 1016 This function is workaround on the basic operation of scantable … … 1024 1024 nrow = scan.nrow() 1025 1025 s = None 1026 from asap._asap import stmath 1027 stm = stmath() 1028 stm._setinsitu(insitu) 1026 1029 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 ) ) 1031 1031 elif len( value ) != nrow: 1032 1032 raise ValueError( 'len(value) must be 1 or conform to scan.nrow()' ) 1033 1033 else: 1034 1034 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 1037 1040 stm._setinsitu( True ) 1038 s = scan.copy()1039 sel = selector() 1041 basesel = s.get_selection() 1042 sel = selector()+basesel 1040 1043 for irow in range( nrow ): 1041 1044 sel.set_rows( irow ) … … 1046 1049 #stm._arrayop( s, value[irow], mode, tsys, 'channel' ) 1047 1050 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) 1052 1052 return s -
trunk/python/scantable.py
r2315 r2320 575 575 for k in kw: 576 576 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)) 578 580 selection = selector(**kw) 579 581 self._setselection(selection) … … 3116 3118 import numpy 3117 3119 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): 3119 3122 from asapmath import _array2dOp 3120 s = _array2dOp( self .copy(), factor, "MUL", tsys)3123 s = _array2dOp( self, factor, "MUL", tsys, insitu ) 3121 3124 else: 3122 s = scantable( self._math._arrayop( self.copy(), factor, "MUL", tsys ) ) 3125 s = scantable( self._math._arrayop( self, factor, 3126 "MUL", tsys ) ) 3123 3127 else: 3124 s = scantable(self._math._unaryop(self .copy(), factor, "MUL", tsys))3128 s = scantable(self._math._unaryop(self, factor, "MUL", tsys)) 3125 3129 s._add_history("scale", varlist) 3126 3130 if insitu:
Note:
See TracChangeset
for help on using the changeset viewer.