Changeset 800


Ignore:
Timestamp:
01/10/06 15:11:58 (19 years ago)
Author:
mar637
Message:

Request: added channel based flagging

Location:
branches/Release12
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Release12/python/__init__.py

    r798 r800  
    268268
    269269__date__ = '$Date$'.split()[1]
    270 __version__  = '1.2.1'
     270__version__  = '1.2.2a'
    271271
    272272if rcParams['verbose']:
     
    318318            set_restfreqs   - set a list of rest frequencies
    319319            lines           - print list of known spectral lines
    320             flag_spectrum   - flag a whole Beam/IF/Pol
     320            flag_spectrum   - flag spectral channels
    321321            save            - save the scantable to disk as either 'ASAP'
    322322                              or 'SDFITS'
  • branches/Release12/python/scantable.py

    r798 r800  
    721721
    722722
    723     def flag_spectrum(self, thebeam, theif, thepol):
     723    def flag_spectrum(self, flags, row=-1, allaxes=None):
    724724        """
    725725        This flags a selected spectrum in the scan 'for good'.
     
    727727        Use masks for non-permanent exclusion of channels.
    728728        Parameters:
    729             thebeam,theif,thepol:    all have to be explicitly
    730                                      specified
    731         Example:
    732             scan.flag_spectrum(0,0,1)
    733             flags the spectrum for Beam=0, IF=0, Pol=1
    734         """
    735         if (thebeam < self.nbeam() and
    736             theif < self.nif() and
    737             thepol < self.npol()):
    738             sdtable.setbeam(self, thebeam)
    739             sdtable.setif(self, theif)
    740             sdtable.setpol(self, thepol)
    741             sdtable._flag(self)
    742             self._add_history("flag_spectrum", vars())
    743         else:
    744             print "Please specify a valid (Beam/IF/Pol)"
     729            flags:   a mask created with scantable.create_mask
     730            row:     the number of the row (intergration) to flag,
     731                     the deafult is -1, which is ALL rows.
     732            allaxes: if True apply to all spectra. Otherwise
     733                     apply only to the selected (beam/pol/if)spectra only
     734                     The default is taken from .asaprc (True if none)
     735        Example:
     736            scan.flag_spectrum() # flags everything, not very useful
     737            msk = scan.create_mask([511,513])
     738            scan,set_cursor(IF=1)
     739            scan.flag_spectrum(msk, allaxes=False)
     740            # flags the central three channels for all rows in the table,
     741            # using the selected IF only (e.g. a birdie)
     742        """
     743        if allaxes is None: allaxes = rcParams['scantable.allaxes']
     744        if len(flags) != self.nchan():
     745            msg  = "Length of mask invalid.",valid
     746            if rcParams['verbose']:
     747                print msg
     748                return
     749            else:
     750                raise AssertionError(msg)
     751        rows = range(self.nrow())
     752        if row > -1: rows = [row]
     753        for r in rows:
     754            if allaxes:
     755                beamSel,IFSel,polSel = (self.getbeam(),self.getif(),self.getpol())
     756                for i in range(self.nbeam()):
     757                    self.setbeam(i)
     758                    for j in range(self.nif()):
     759                        self.setif(j)
     760                        for k in range(self.npol()):
     761                            self.setpol(k)
     762                            sdtable._flagspectrum(self, flags, r)
     763                self.setbeam(beamSel)
     764                self.setif(IFSel)
     765                self.setpol(polSel)
     766            else:
     767                sdtable._flagspectrum(self, flags, r)
     768        self._add_history("flag_spectrum", vars())
    745769        return
    746770
     
    840864                         Otherwise, the scaling is done in-situ
    841865                         The default is taken from .asaprc (False)
    842             allaxes:         if True apply to all spectra. Otherwise
     866            allaxes:     if True apply to all spectra. Otherwise
    843867                         apply only to the selected (beam/pol/if)spectra only
    844868                         The default is taken from .asaprc (True if none)
  • branches/Release12/src/SDMemTable.cc

    r787 r800  
    16221622}
    16231623*/
    1624 void SDMemTable::flag(int whichRow)
     1624void SDMemTable::flagSpectrum(const std::vector<bool>& flags, int whichRow)
    16251625  {
    16261626  Array<uChar> arr;
    16271627  flagsCol_.get(whichRow, arr);
     1628
     1629  std::vector<bool>::const_iterator it = flags.begin();
     1630  if ( flags.size() != arr.shape()(asap::ChanAxis) )
     1631    throw(AipsError("Incorrect number of channels in flags"));
    16281632
    16291633  ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
     
    16341638  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    16351639
     1640  uChar userflag = 1 << 7; // user flag bit
    16361641  for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    1637     (*i) = uChar(True);
     1642    if (*it)
     1643      (*i) |= userflag;
     1644    ++it;
    16381645  }
    16391646
  • branches/Release12/src/SDMemTable.h

    r787 r800  
    182182  virtual void resetCursor();
    183183
    184   // Hard flags the current spectrum, not reversible
    185   virtual void flag(int whichRow);
     184  // Hard flags the current spectrum, (currently) not reversible
     185  virtual void flagSpectrum(const std::vector<bool>& flags, int whichRow);
    186186
    187187  // return the currently selected values
  • branches/Release12/src/SDMemTableWrapper.h

    r787 r800  
    131131  }
    132132
    133   void flag(int whichRow=-1) {
    134     table_->flag(whichRow);
    135   }
     133  void flagSpectrum(const std::vector<bool>& flags, int whichRow=-1) {
     134    table_->flagSpectrum(flags, whichRow);
     135  }
     136
    136137  std::string getSourceName(int whichRow=0) {
    137138    return table_->getSourceName(whichRow);
  • branches/Release12/src/python_SDMemTable.cc

    r787 r800  
    101101    .def("_gettime", &SDMemTableWrapper::getTime,
    102102         (boost::python::arg("whichRow")=0) )
    103     .def("_flag", &SDMemTableWrapper::flag,
     103    .def("_flagspectrum", &SDMemTableWrapper::flagSpectrum,
    104104         (boost::python::arg("whichRow")=-1) )
    105105    .def("_save",  &SDMemTableWrapper::makePersistent)
Note: See TracChangeset for help on using the changeset viewer.