Changeset 948


Ignore:
Timestamp:
03/30/06 15:41:18 (18 years ago)
Author:
mar637
Message:

added get functions; added is_empty; added add to combine selections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/selector.py

    r932 r948  
    11from asap._asap import selector as _selector
     2from asap import unique, _to_list
     3
    24class selector(_selector):
     5    """
     6    A selection object to be applied to scantables to restrict the
     7    scantables to specific rows.
     8    """
    39    def __init(self):
    410        _selector.__init__(self)
     
    1016        self._reset()
    1117
    12        
     18    def is_empty(self):
     19        """
     20        Has anything been set?
     21        """
     22        return self._empty()
     23
    1324    def set_polarisations(self, pols=[]):
    1425        """
     
    2435             # reset the polarisation selection
    2536             sel.set_polarisations()
    26                          
     37
    2738        """
    2839        vec = _to_list(pols, str) and _to_list(pols, int)
     
    8293        else:
    8394            raise TypeError('Unknown Cycle number type. Use lists of integers.')
    84                                    
     95
    8596
    8697    def set_name(self, name):
     
    97108        else:
    98109            raise TypeError('name must be a string')
    99        
     110
    100111    def set_tsys(self, tsysmin=0.0, tsysmax=None):
    101112        """
     
    107118            # select all spectra with Tsys <= 500.0
    108119            selection.set_tsys(tsysmax=500.0)
    109            
     120
    110121        """
    111122        taql =  "SELECT FROM $1 WHERE TSYS >= %f" % (tsysmin)
     
    123134        taql = "SELECT FROM $1 WHERE " + query
    124135        self._settaql(taql)
    125        
     136
     137    def set_order(self, order):
     138        """
     139        Set the order the scantable should be sorted by.
     140        Parameters:
     141            order:    The list of column nmaes to sort by in order
     142        """
     143        self._setorder(order)
     144
     145    def get_scans(self):
     146        return list(self._getscans())
     147    def get_cycles(self):
     148        return list(self._getcycles())
     149    def get_beams(self):
     150        return list(self._getbeams())
     151    def get_ifs(self):
     152        return list(self._getifs())
     153    def get_pols(self):
     154        return list(self._getpols())
     155    def get_poltypes(self):
     156        return list(self._getpoltypes())
     157    def get_order(self):
     158        return list(self._getorder())
     159    def get_taql(self):
     160        return self._gettaql()
     161    def get_name(self):
     162        print "NYI"
     163        s = self._gettaql()
     164        return ""
     165
     166    def __add__(self, other):
     167        """
     168        Merge two selections.
     169        """
     170        union = selector()
     171        gets = [[self._getscans(), other._getscans(), union._setscans],
     172                [self._getcycles(), other._getcycles(),union._setcycles],
     173                [self._getbeams(), other._getbeams(), union._setbeams],
     174                [self._getifs(), other._getifs(), union._setifs],
     175                [self._getpols(), other._getpols(), union._setpols]]
     176        for v in gets:
     177            vec = list(v[0]+v[1])
     178            vec.sort()
     179            v[2](unique(vec))
     180        union._settaql(other._gettaql())
     181        return union
Note: See TracChangeset for help on using the changeset viewer.