Changeset 1295 for trunk/python
- Timestamp:
- 11/06/06 22:22:03 (18 years ago)
- Location:
- trunk/python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r1280 r1295 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): … … 298 300 'data/Sgr_86p262_best_SPC.sdfits'] 299 301 """ 300 import os301 302 if not os.path.isdir(path): 302 303 return None 303 valid = "rpf sdf sdfits mbf asap".split()304 valid = "rpf rpf.1 rpf.2 sdf sdfits mbf asap".split() 304 305 if not suffix in valid: 305 306 return None … … 325 326 return 326 327 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") 328 def mask_and(a, b): 329 assert(len(a)==len(b)) 330 return [ a[i] & b[i] for i in xrange(len(a)) ] 331 332 def mask_or(a, b): 333 assert(len(a)==len(b)) 334 return [ a[i] | b[i] for i in xrange(len(a)) ] 335 336 def mask_not(a): 337 return [ not i for i in a ] 334 338 335 339 from asapfitter import fitter … … 342 346 from linecatalog import linecatalog 343 347 344 mask_and = NUM.logical_and345 mask_or = NUM.logical_or346 mask_not = NUM.logical_not347 348 348 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 349 try: 350 from asapplotter import asapplotter 351 gui = os.environ.has_key('DISPLAY') and rcParams['plotter.gui'] 352 if gui: 353 import pylab as xyplotter 354 plotter = asapplotter(gui) 355 del gui 356 except ImportError: 357 print "Matplotlib not installed. No plotting available" 355 358 356 359 __date__ = '$Date$'.split()[1] … … 362 365 def version(): print "ASAP %s(%s)"% (__version__, __date__) 363 366 def list_scans(t = scantable): 364 import sys,types367 import types 365 368 globs = sys.modules['__main__'].__dict__.iteritems() 366 369 print "The user created scantables are:" -
trunk/python/asapfitter.py
r1273 r1295 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()) -
trunk/python/asapplotter.py
r1259 r1295 1 1 from asap import rcParams, print_log, selector 2 from asap import NUM3 2 import matplotlib.axes 4 3 import sre -
trunk/python/scantable.py
r1280 r1295 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): … … 345 345 print "--------------------------------------------------" 346 346 print out 347 return 348 else: 349 retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'], 350 'axes' : axes, 351 'data': statvals} 352 return retval 347 #else: 348 #retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'], 349 # 'axes' : axes, 350 # 'data': statvals} 351 return statvals 353 352 354 353 def stddev(self, mask=None): … … 721 720 asaplog.push(msg) 722 721 n = self.nchan() 723 msk = NUM.zeros(n)722 msk = _n_bools(n, False) 724 723 # test if args is a 'list' or a 'normal *args - UGLY!!! 725 724 … … 731 730 for i in range(n): 732 731 if data[i] >= window[0] and data[i] <= window[1]: 733 msk[i] = 1732 msk[i] = True 734 733 if kwargs.has_key('invert'): 735 734 if kwargs.get('invert'): 736 msk = NUM.logical_not(msk)735 msk = mask_not(msk) 737 736 print_log() 738 737 return msk … … 1202 1201 varlist = vars() 1203 1202 if mask is None: 1204 mask = list(NUM.ones(self.nchan(-1)))1203 mask = [True for i in xrange(self.nchan(-1))] 1205 1204 from asap.asapfitter import fitter 1206 1205 try:
Note:
See TracChangeset
for help on using the changeset viewer.