Changeset 1093 for trunk/python


Ignore:
Timestamp:
07/28/06 15:12:20 (18 years ago)
Author:
mar637
Message:

removed FITS output, added drop_scan function

Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1080 r1093  
    356356            get_scan        - gets a specific scan out of a scantable
    357357                              (by name or number)
     358            drop_scan       - drops a specific scan out of a scantable
     359                              (by number)
    358360            set_selection   - set a new subselection of the data
    359361            get_selection   - get the current selection object
  • trunk/python/scantable.py

    r1079 r1093  
    7575        Image FITS or MS2 format.
    7676        Parameters:
    77             name:        the name of the outputfile. For format="FITS" this
    78                          is the directory file name into which all the files
    79                          will be written (default is 'asap_FITS'). For format
    80                          "ASCII" this is the root file name (data in 'name'.txt
     77            name:        the name of the outputfile. For format "ASCII"
     78                         this is the root file name (data in 'name'.txt
    8179                         and header in 'name'_header.txt)
    8280            format:      an optional file format. Default is ASAP.
    8381                         Allowed are - 'ASAP' (save as ASAP [aips++] Table),
    8482                                       'SDFITS' (save as SDFITS file)
    85                                        'FITS' (saves each row as a FITS Image)
    8683                                       'ASCII' (saves as ascii text file)
    8784                                       'MS2' (saves as an aips++
     
    131128        sd = scantable(Scantable._copy(self))
    132129        return sd
     130
     131    def drop_scan(self, scanid=None):
     132        """
     133        Return a new scantable where the specified scan number(s) has(have)
     134        been dropped.
     135        Parameters:
     136            scanid:    a (list of) scan number(s)
     137        """
     138        from asap import _is_sequence_or_number as _is_valid
     139        from asap import _to_list
     140        from asap import unique
     141        if not _is_valid(scanid):
     142            if rcParams['verbose']:
     143                print "Please specify a scanno to drop from the scantable"
     144                return
     145            else:
     146                raise RuntimeError("No scan given")
     147        try:
     148            scanid = _to_list(scanid)
     149            allscans = unique([ self.getscan(i) for i in range(self.nrow())])
     150            for sid in scanid: allscans.remove(sid)
     151            if len(allscans) == 0: raise ValueError("Can't remove all scans")
     152        except ValueError:
     153            if rcParams['verbose']:
     154                print "Couldn't find any match."
     155                return
     156            else: raise
     157        try:
     158            bsel = self.get_selection()
     159            sel = selector()
     160            sel.set_scans(allscans)
     161            self.set_selection(bsel+sel)
     162            scopy = self._copy()
     163            self.set_selection(bsel)
     164            return scantable(scopy)
     165        except RuntimeError:
     166            if rcParams['verbose']: print "Couldn't find any match."
     167            else: raise
     168
    133169
    134170    def get_scan(self, scanid=None):
Note: See TracChangeset for help on using the changeset viewer.