Changeset 1134 for trunk/python


Ignore:
Timestamp:
08/14/06 14:13:10 (18 years ago)
Author:
mar637
Message:

added numpy/numarray detection

Location:
trunk/python
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1117 r1134  
    319319    return
    320320
     321try:
     322    import numpy.core as NUM
     323except ImportError:
     324    try:
     325        import numarray as NUM
     326    except ImportError:
     327        raise ImportError("You need to have numpy or numarray installed")
     328
    321329from asapfitter import fitter
    322330from asapreader import reader
     
    326334from scantable import scantable
    327335from asaplinefind import linefinder
    328 #from asapfit import *
    329 
    330 from numarray import logical_and as mask_and
    331 from numarray import logical_or as mask_or
    332 from numarray import logical_not as mask_not
     336from linecatalog import linecatalog
     337
     338mask_and = NUM.logical_and
     339mask_or = NUM.logical_or
     340mask_not = NUM.logical_not
    333341
    334342if rcParams['useplotter']:
     
    337345    plotter = asapplotter(gui)
    338346    del gui
    339 
    340347
    341348__date__ = '$Date$'.split()[1]
  • trunk/python/asapfitter.py

    r1116 r1134  
    22from asap import rcParams
    33from asap import print_log
     4from asap import NUM
    45
    56class fitter:
     
    4142        self.y = ydat
    4243        if mask == None:
    43             from numarray import ones
    44             self.mask = ones(len(xdat))
     44            self.mask = NUM.ones(len(xdat))
    4545        else:
    4646            self.mask = mask
     
    6565        self.mask = None
    6666        if mask is None:
    67             from numarray import ones
    68             self.mask = ones(self.data.nchan())
     67            self.mask = NUM.ones(self.data.nchan())
    6968        else:
    7069            self.mask = mask
     
    202201        if self.fitfunc == "gauss" and component is not None:
    203202            if not self.fitted and sum(self.fitter.getparameters()) == 0:
    204                 from numarray import zeros
    205                 pars = list(zeros(len(self.components)*3))
    206                 fxd = list(zeros(len(pars)))
     203                pars = list(NUM.zeros(len(self.components)*3))
     204                fxd = list(NUM.zeros(len(pars)))
    207205            else:
    208206                pars = list(self.fitter.getparameters())
  • trunk/python/scantable.py

    r1118 r1134  
    44from asap import asaplog
    55from asap import selector
    6 from numarray import ones
    7 from numarray import zeros
     6from asap import NUM
    87
    98class scantable(Scantable):
     
    666665            asaplog.push(msg)
    667666        n = self.nchan()
    668         msk = zeros(n)
     667        msk = NUM.zeros(n)
    669668        # test if args is a 'list' or a 'normal *args - UGLY!!!
    670669
     
    679678        if kwargs.has_key('invert'):
    680679            if kwargs.get('invert'):
    681                 from numarray import logical_not
    682                 msk = logical_not(msk)
     680                msk = NUM.logical_not(msk)
    683681        print_log()
    684682        return msk
     
    10931091        varlist = vars()
    10941092        if mask is None:
    1095             mask = list(ones(self.nchan(-1)))
     1093            mask = list(NUM.ones(self.nchan(-1)))
    10961094        from asap.asapfitter import fitter
    10971095        f = fitter()
Note: See TracChangeset for help on using the changeset viewer.