Changeset 1504


Ignore:
Timestamp:
02/13/09 11:27:42 (15 years ago)
Author:
Malte Marquarding
Message:

Fix for ticket #151: added facilities to help with on/off scan identification/setting

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1472 r1504  
    114114    'scantable.verbosesummary'   : [False, _validate_bool],
    115115    'scantable.storage'   : ['memory', str],
    116     'scantable.history'   : [True, _validate_bool]
     116    'scantable.history'   : [True, _validate_bool],
     117    'scantable.reference'      : ['.*(e|w|_R)$', str]
    117118    # fitter
    118119    }
     
    180181scantable.verbosesummary   : False
    181182
     183# Control the identification of reference (off) scans
     184# This is has to be a regular expression
     185scantable.reference         : .*(e|w|_R)$
    182186# Fitter
    183187"""
  • trunk/python/scantable.py

    r1502 r1504  
    15151515            return s
    15161516
    1517     def set_sourcetype(self, match, sourcetype="reference"):
     1517    def set_sourcetype(self, match, matchtype="pattern",
     1518                       sourcetype="reference"):
    15181519        """
    15191520        Set the type of the source to be an source or reference scan
    15201521        using the provided pattern:
    15211522        Parameters:
    1522             match:          a Unix style pattern or asap selector
     1523            match:          a Unix style pattern, regular expression or selector
     1524            matchtype:      'pattern' (default) UNIX style pattern or
     1525                            'regex' regular expression
    15231526            sourcetype:     the type of the source to use (source/reference)
    15241527        """
     
    15301533        elif sourcetype.lower().startswith("s"):
    15311534            stype = 0
    1532         if stype == -1:
     1535        else:
    15331536            raise ValueError("Illegal sourcetype use s(ource) or r(eference)")
     1537        if matchtype.lower().startswith("p"):
     1538            matchtype = "pattern"
     1539        elif matchtype.lower().startswith("r"):
     1540            matchtype = "regex"
     1541        else:
     1542            raise ValueError("Illegal matchtype, use p(attern) or r(egex)")
    15341543        sel = selector()
    15351544        if isinstance(match, selector):
    15361545            sel = match
    15371546        else:
    1538             sel.set_query("SRCNAME == pattern('%s')" % match)
     1547            sel.set_query("SRCNAME == %s('%s')" % (matchtype, match))
    15391548        self.set_selection(basesel+sel)
    15401549        self._setsourcetype(stype)
     
    18311840            tbl = Scantable(stype)
    18321841            r = stfiller(tbl)
     1842            rx = rcParams['scantable.reference']
     1843            r._setreferenceexpr(rx)
    18331844            msg = "Importing %s..." % (name)
    18341845            asaplog.push(msg, False)
  • trunk/src/STFiller.cpp

    r1467 r1504  
    4444  reader_(0),
    4545  header_(0),
    46   table_(0)
     46  table_(0),
     47  refRx_(".*(e|w|_R)$")
    4748{
    4849}
     
    5152  reader_(0),
    5253  header_(0),
    53   table_(stbl)
     54  table_(stbl),
     55  refRx_(".*(e|w|_R)$")
    5456{
    5557}
     
    5860  reader_(0),
    5961  header_(0),
    60   table_(0)
     62  table_(0),
     63  refRx_(".*(e|w|_R)$")
    6164{
    6265  open(filename, whichIF, whichBeam);
     
    276279    *fieldnCol = pksrec.fieldName;
    277280    // try to auto-identify if it is on or off.
    278     Regex rx(".*(e|w|_R)$");
     281    Regex rx(refRx_);
    279282    Regex rx2("_S$");
    280283    Int match = pksrec.srcName.matches(rx);
  • trunk/src/STFiller.h

    r1391 r1504  
    9393  casa::CountedPtr<Scantable> getTable() const { return table_;}
    9494
     95  void setReferenceExpr(const std::string& rx) { refRx_ = rx; }
     96
    9597private:
    9698
     
    102104  casa::uInt ifOffset_, beamOffset_;
    103105  casa::Vector<casa::Bool> haveXPol_;
     106  casa::String refRx_;
    104107};
    105108
  • trunk/src/python_STFiller.cpp

    r1077 r1504  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id:$
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131#include <boost/python.hpp>
     
    4747        .def("_close", &STFillerWrapper::close)
    4848        .def("_getdata", &STFillerWrapper::getScantable)
     49        .def("_setreferenceexpr", &STFillerWrapper::setReferenceExpr)
    4950      ;
    5051    };
Note: See TracChangeset for help on using the changeset viewer.