Changeset 1283
- Timestamp:
- 11/06/06 12:10:26 (18 years ago)
- Location:
- tags/Release2.1.1b/python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/Release2.1.1b/python/__init__.py
r1274 r1283 253 253 rcParams.update(rcParamsDefault) 254 254 255 def _n_bools(n, val): 256 return [ val for i in xrange(n) ] 255 257 256 258 def _is_sequence_or_number(param, ptype=int): … … 301 303 if not os.path.isdir(path): 302 304 return None 303 valid = "rpf sdf sdfits mbf asap".split()305 valid = "rpf rpf.1 rpf.2 sdf sdfits mbf asap".split() 304 306 if not suffix in valid: 305 307 return None … … 325 327 return 326 328 327 try: 328 import numpy.core as NUM 329 except ImportError: 330 try: 331 import numarray as NUM 332 except ImportError: 333 raise ImportError("You need to have numpy or numarray installed") 329 def mask_and(a, b): 330 assert(len(a)==len(b)) 331 return [ a[i] & b[i] for i in xrange(len(a)) ] 332 333 def mask_or(a, b): 334 assert(len(a)==len(b)) 335 return [ a[i] | b[i] for i in xrange(len(a)) ] 336 337 def mask_not(a): 338 return [ not i for i in a ] 334 339 335 340 from asapfitter import fitter … … 342 347 from linecatalog import linecatalog 343 348 344 mask_and = NUM.logical_and345 mask_or = NUM.logical_or346 mask_not = NUM.logical_not347 348 349 if rcParams['useplotter']: 349 from asapplotter import asapplotter 350 gui = os.environ.has_key('DISPLAY') and rcParams['plotter.gui'] 351 if gui: 352 import pylab as xyplotter 353 plotter = asapplotter(gui) 354 del gui 350 try: 351 from asapplotter import asapplotter 352 gui = os.environ.has_key('DISPLAY') and rcParams['plotter.gui'] 353 if gui: 354 import pylab as xyplotter 355 plotter = asapplotter(gui) 356 del gui 357 except ImportError: 358 print "Matplotlib not installed. No plotting available" 355 359 356 360 __date__ = '$Date$'.split()[1] -
tags/Release2.1.1b/python/asapfitter.py
r1271 r1283 2 2 from asap import rcParams 3 3 from asap import print_log 4 from asap import NUM4 from asap import _n_bools 5 5 6 6 class fitter: … … 42 42 self.y = ydat 43 43 if mask == None: 44 self.mask = NUM.ones(len(xdat))44 self.mask = _n_bools(len(xdat), True) 45 45 else: 46 46 self.mask = mask … … 65 65 self.mask = None 66 66 if mask is None: 67 self.mask = NUM.ones(self.data.nchan())67 self.mask = _n_bools(self.data.nchan(), True) 68 68 else: 69 69 self.mask = mask … … 215 215 if self.fitfunc == "gauss" and component is not None: 216 216 if not self.fitted and sum(self.fitter.getparameters()) == 0: 217 pars = list(NUM.zeros(len(self.components)*3))218 fxd = list(NUM.zeros(len(pars)))217 pars = _n_bools(len(self.components)*3, False) 218 fxd = _n_bools(len(pars), False) 219 219 else: 220 220 pars = list(self.fitter.getparameters()) -
tags/Release2.1.1b/python/asapplotter.py
r1259 r1283 1 1 from asap import rcParams, print_log, selector 2 from asap import NUM3 2 import matplotlib.axes 4 3 import sre -
tags/Release2.1.1b/python/scantable.py
r1276 r1283 4 4 from asap import asaplog 5 5 from asap import selector 6 from asap import NUM7 6 from asap import linecatalog 7 from asap import _n_bools, mask_not, mask_and, mask_or 8 8 9 9 class scantable(Scantable): … … 721 721 asaplog.push(msg) 722 722 n = self.nchan() 723 msk = NUM.zeros(n)723 msk = _n_bools(n, False) 724 724 # test if args is a 'list' or a 'normal *args - UGLY!!! 725 725 … … 731 731 for i in range(n): 732 732 if data[i] >= window[0] and data[i] <= window[1]: 733 msk[i] = 1733 msk[i] = True 734 734 if kwargs.has_key('invert'): 735 735 if kwargs.get('invert'): 736 msk = NUM.logical_not(msk)736 msk = mask_not(msk) 737 737 print_log() 738 738 return msk … … 1202 1202 varlist = vars() 1203 1203 if mask is None: 1204 mask = list(NUM.ones(self.nchan(-1)))1204 mask = [True for i in xrange(self.nchan(-1))] 1205 1205 from asap.asapfitter import fitter 1206 1206 try:
Note:
See TracChangeset
for help on using the changeset viewer.