Changeset 1283


Ignore:
Timestamp:
11/06/06 12:10:26 (18 years ago)
Author:
mar637
Message:

Fix for Ticket #88 - removed use of numpy/numarray except for plotting where it is used via matplotlib.numerix

Location:
tags/Release2.1.1b/python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tags/Release2.1.1b/python/__init__.py

    r1274 r1283  
    253253    rcParams.update(rcParamsDefault)
    254254
     255def _n_bools(n, val):
     256    return [ val for i in xrange(n) ]
    255257
    256258def _is_sequence_or_number(param, ptype=int):
     
    301303    if not os.path.isdir(path):
    302304        return None
    303     valid = "rpf sdf sdfits mbf asap".split()
     305    valid = "rpf rpf.1 rpf.2 sdf sdfits mbf asap".split()
    304306    if not suffix in valid:
    305307        return None
     
    325327    return
    326328
    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")
     329def mask_and(a, b):
     330    assert(len(a)==len(b))
     331    return [ a[i] & b[i] for i in xrange(len(a)) ]
     332
     333def mask_or(a, b):
     334    assert(len(a)==len(b))
     335    return [ a[i] | b[i] for i in xrange(len(a)) ]
     336
     337def mask_not(a):
     338    return [ not i for i in a ]
    334339
    335340from asapfitter import fitter
     
    342347from linecatalog import linecatalog
    343348
    344 mask_and = NUM.logical_and
    345 mask_or = NUM.logical_or
    346 mask_not = NUM.logical_not
    347 
    348349if 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"
    355359
    356360__date__ = '$Date$'.split()[1]
  • tags/Release2.1.1b/python/asapfitter.py

    r1271 r1283  
    22from asap import rcParams
    33from asap import print_log
    4 from asap import NUM
     4from asap import _n_bools
    55
    66class fitter:
     
    4242        self.y = ydat
    4343        if mask == None:
    44             self.mask = NUM.ones(len(xdat))
     44            self.mask = _n_bools(len(xdat), True)
    4545        else:
    4646            self.mask = mask
     
    6565        self.mask = None
    6666        if mask is None:
    67             self.mask = NUM.ones(self.data.nchan())
     67            self.mask = _n_bools(self.data.nchan(), True)
    6868        else:
    6969            self.mask = mask
     
    215215        if self.fitfunc == "gauss" and component is not None:
    216216            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)
    219219            else:
    220220                pars = list(self.fitter.getparameters())
  • tags/Release2.1.1b/python/asapplotter.py

    r1259 r1283  
    11from asap import rcParams, print_log, selector
    2 from asap import NUM
    32import matplotlib.axes
    43import sre
  • tags/Release2.1.1b/python/scantable.py

    r1276 r1283  
    44from asap import asaplog
    55from asap import selector
    6 from asap import NUM
    76from asap import linecatalog
     7from asap import _n_bools, mask_not, mask_and, mask_or
    88
    99class scantable(Scantable):
     
    721721            asaplog.push(msg)
    722722        n = self.nchan()
    723         msk = NUM.zeros(n)
     723        msk = _n_bools(n, False)
    724724        # test if args is a 'list' or a 'normal *args - UGLY!!!
    725725
     
    731731            for i in range(n):
    732732                if data[i] >= window[0] and data[i] <= window[1]:
    733                     msk[i] = 1
     733                    msk[i] = True
    734734        if kwargs.has_key('invert'):
    735735            if kwargs.get('invert'):
    736                 msk = NUM.logical_not(msk)
     736                msk = mask_not(msk)
    737737        print_log()
    738738        return msk
     
    12021202        varlist = vars()
    12031203        if mask is None:
    1204             mask = list(NUM.ones(self.nchan(-1)))
     1204            mask = [True for i in xrange(self.nchan(-1))]
    12051205        from asap.asapfitter import fitter
    12061206        try:
Note: See TracChangeset for help on using the changeset viewer.