Changes in trunk/src [1848:1947]


Ignore:
Location:
trunk/src
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/AsapLogSink.cpp

    r1848 r1947  
    2121
    2222  void AsapLogSink::postMessage(const std::string& msg,
    23                                 const std::string& location,
    24                                 const std::string& priority)
     23                                const std::string& priority,
     24                                const std::string& origin)
    2525  {
    2626    LogMessage::Priority p;
     
    3232      p = LogMessage::SEVERE;
    3333    }
    34     LogMessage message(msg, LogOrigin(location), p);
     34    LogMessage message(msg, LogOrigin(origin), p);
    3535
    3636    MemoryLogSink::postLocally(message);
  • trunk/src/AsapLogSink.h

    r1848 r1947  
    3737
    3838  virtual void postMessage(const std::string& msg,
    39                            const std::string& location="",
    40                            const std::string& priority="INFO");
     39                           const std::string& priority="INFO",
     40                           const std::string& origin="");
    4141
    4242  std::string popMessages();
  • trunk/src/FillerBase.cpp

    r1848 r1947  
    3838  RecordFieldPtr< Array<Float> > tsysCol(row_.record(), "TSYS");
    3939
    40   *specCol = spectrum;
    41   *flagCol = flags;
    42   *tsysCol = tsys;
     40  //*specCol = spectrum;
     41  //*flagCol = flags;
     42  //*tsysCol = tsys;
     43  specCol.define(spectrum);
     44  flagCol.define(flags);
     45  tsysCol.define(tsys);
    4346}
    4447
  • trunk/src/FillerBase.h

    r1848 r1947  
    4343    virtual ~FillerBase() {;}
    4444
    45 //    virtual bool open(const std::string& filename, const Record& rec) = 0;
    46     virtual bool open(const std::string& filename) = 0;
     45    virtual bool open(const std::string& filename, const casa::Record& rec) = 0;
     46    //    virtual bool open(const std::string& filename) = 0;
    4747    virtual void fill() = 0;
    4848    virtual void close() = 0;
  • trunk/src/FillerWrapper.h

    r1848 r1947  
    1616#include <casa/Exceptions.h>
    1717#include <casa/Utilities/CountedPtr.h>
     18#include <casa/Containers/Record.h>
    1819#include <casa/OS/File.h>
    1920
     
    3839
    3940
    40 //  void open(const std::string& filename, casa::Record rec) {
    41   void open(const std::string& filename) {
     41  void open(const std::string& filename, const casa::Record& rec) {
     42    //  void open(const std::string& filename) {
    4243    casa::File file(filename);
    4344    if ( !file.exists() ) {
     
    4546    }
    4647    filler_ = new PKSFiller(stable_);
    47 //    if (filler_->open(filename, rec)) {
    48     if (filler_->open(filename)) {
     48    if (filler_->open(filename, rec)) {
     49      //    if (filler_->open(filename)) {
    4950      attached_ = true;
    5051      return;
    5152    }
    5253    filler_ = new NROFiller(stable_);
    53 //    if (filler_->open(filename, rec)) {
    54     if (filler_->open(filename)) {
     54    if (filler_->open(filename, rec)) {
     55      //    if (filler_->open(filename)) {
    5556      attached_ = true;
    5657      return;
  • trunk/src/Makefile

    r1848 r1947  
    77###    3. Replase library names in G2CARCH '-lcasa_*' with '-l*'.
    88###    4. Comment-IN the definition of 'CXXOPTS'.
    9 #TARGET   := /tmp/_asap.so
    10 TARGET   := /home/nakazato/tmp/_asap.so
     9TARGET   := /tmp/_asap.so
     10
     11ifndef ASAPROOT
     12        ASAPROOT := $(abspath ..)
     13endif
     14ATNFD := external-alma
    1115
    1216# the casa environment AIPSPATH has to be defined
    1317CASAROOT  := $(word 1, $(CASAPATH))
    1418CASAARCH  := $(word 2, $(CASAPATH))
     19
     20CXXFLAGS := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=CXXFLAGS eval_vars) && echo $$CXXFLAGS)
     21CXXOPTS := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=COPTFLAGS eval_vars) && echo $$COPTFLAGS)
     22LDFLAGS := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=LD_FLAGS eval_vars) && echo $$LD_FLAGS)
    1523
    1624COREINCD := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=COREINCD eval_vars) && echo $$COREINCD)
     
    2230PYTHONINCD := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=PYTHONINCD eval_vars) && echo $$PYTHONINCD)
    2331PYTHONLIB := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=PYTHONLIB eval_vars) && echo $$PYTHONLIB)
    24 #PYTHONVER := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=PYTHONVER eval_vars) && echo $$PYTHONVER)
    2532BOOSTROOT := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=BOOSTROOT eval_vars) && echo $$BOOSTROOT)
    2633RPFITSLIBD := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=RPFITSLIBD eval_vars) && echo $$RPFITSLIBD)
     34CFITSIOLIBD := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=CFITSIOLIBD eval_vars) && echo $$CFITSIOLIBD)
     35CFITSIOINCD := $(shell $(shell make -s -f $(CASAROOT)/$(CASAARCH)/makedefs VARS=CFITSIOINCD eval_vars) && echo $$CFITSIOINCD)
    2736
    2837CASAINC   := -I$(CASAROOT)/code/include -I$(COREINCD) -I$(CASAROOT)/$(CASAARCH)/include
    2938CASALIB   := $(CASAROOT)/$(CASAARCH)/lib
    30 #USELIB := lib64
    31 USELIB := lib
    3239
    3340# the compiler
     
    3744
    3845# compiler flags
    39 CXXFLAGS := -fPIC -O3 -g
    40 CXXFLAGS += -ansi -Wno-long-long -Wall
    41 #CXXOPTS := -DAIPS_64B
    42 
    43 # darwin specific flags
    44 ifeq "$(CASAARCH)" "darwin"
    45    #CXXFLAGS +=-DAIPS_DARWIN -arch i386 #For 10.6
    46    CXXFLAGS +=-DAIPS_DARWIN
    47    #CXXFLAGS += -Wno-long-double
    48 endif
    49 
    50 # cfitsio
    51 CFITSIOROOT := /usr
    52 CFITSIOINC := -I$(CFITSIOROOT)/include/cfitsio
     46CXXFLAGS += -fPIC -DHAVE_LIBPYRAP
     47
     48PYRAPD := $(ASAPROOT)/external/libpyrap
     49PYRAPLIBD := $(PYRAPD)
     50PYRAPINCD := $(PYRAPD)/pyrap-0.3.2
     51PYRAPLIB := -L$(PYRAPLIBD) -lpyrap
     52
     53
    5354CFITSIOLIB := -lcfitsio
    5455
    5556#rpfits
    56 RPFITSROOT := /usr
    5757RPFITSLIB := -lrpfits
    5858
     
    6060G2CLIB := -lgfortran
    6161
    62 # This assumes all casa libs are static only (*.a)
    63 # if not than there might by symbol resolution errors.
    64 CASAPPLIB := -L$(CASALIB) -latnf $(CORELIB) \
     62# links to external libraries
     63CASAPPLIB := -L$(ASAPROOT)/$(ATNFD) -latnf $(CORELIB) $(PYRAPLIB)\
    6564             -L$(WCSLIBLIBD) $(WCSLIBLIB) \
    6665             -L$(RPFITSLIBD) $(RPFITSLIB) $(CFITSIOLIB) $(G2CLIB) -lstdc++
    6766
    6867# darwin specific CASA flags
    69 ifeq "$(CASAARCH)" "darwin"
     68ifeq ($(shell uname), Darwin)
    7069   CASAPPLIB += -framework vecLib
    7170else
     
    7372endif
    7473
    75 # python
    76 PYTHONINC := $(addprefix -I,$(PYTHONINCD))
    77 PYTHONLIB := -L$(PYTHONLIBD) $(PYTHONLIB)
    78 
    79 # use python universal build
    80 #ifeq "$(CASAARCH)" "darwin"
    81 #   PYVERSION := 2.5
    82 #   PYTHONROOT := /Library/Frameworks/Python.framework/Versions/$(PYVERSION)
    83 #   PYTHONINC := -I$(PYTHONROOT)/include/python$(PYVERSION)
    84 #   PYTHONLIB := -L$(PYTHONROOT)/lib -framework Python
    85 #endif
    86 
    87 # the linker
    8874LD        := $(CXX)
    8975
     
    9278BOOSTINC  := -I$(BOOSTROOT)/include/boost -I$(BOOSTROOT)/include
    9379
    94 LDFLAGS   := -shared -Wl$(TARGET) -s -Xlinker -rpath -Xlinker $(BOOSTROOT)/lib:$(PYTHONROOT)/lib:$(CASALIB)
    95 ifeq "$(CASAARCH)" "darwin"
    96    LDFLAGS   := -bundle
    97 endif
     80LDFLAGS   += -shared
    9881
    9982
    10083# DO NOT MODIFY AFTER THIS
    101 INCDIRS   := -I. $(CASAINC)  $(CFITSIOINC) $(BOOSTINC) $(PYTHONINC)
     84INCDIRS   := -I. $(CASAINC)  -I$(CFITSIOINCD) $(BOOSTINC) $(addprefix -I, $(PYTHONINCD)) -I$(ASAPROOT)/$(ATNFD) -I$(PYRAPINCD)
    10285LIBS      := $(PYTHONLIB)  $(BOOSTLIB) $(CASAPPLIB)
    10386
  • trunk/src/NROFiller.cpp

    r1848 r1947  
    2020#include "NROFiller.h"
    2121#include "STHeader.h"
     22#include <casa/Containers/Record.h>
    2223#include <atnf/PKSIO/SrcType.h>
    2324
     
    3637}
    3738
    38 bool NROFiller::open(const std::string& filename)
     39  bool NROFiller::open(const std::string& filename, const Record& rec)
    3940{
    4041  bool status = true ;
  • trunk/src/NROFiller.h

    r1848 r1947  
    4545    virtual ~NROFiller();
    4646
    47     bool open(const std::string& filename) ;
     47    bool open(const std::string& filename, const casa::Record& rec) ;
    4848    void fill() ;
    4949    void close() ;
  • trunk/src/PKSFiller.cpp

    r1848 r1947  
    2020#include <casa/Arrays/ArrayLogical.h>
    2121#include <casa/Utilities/Regex.h>
     22#include <casa/Utilities/DataType.h>
    2223#include <casa/Logging/LogIO.h>
    2324
     25#include <casa/Containers/Record.h>
    2426#include <measures/Measures/MDirection.h>
    2527#include <measures/Measures/MeasConvert.h>
     
    3436
    3537#include <time.h>
     38#include <sstream>
    3639
    3740#include "STDefs.h"
     
    5861}
    5962
    60 bool PKSFiller::open( const std::string& filename)
     63bool PKSFiller::open( const std::string& filename, const Record& rec)
    6164{
    6265  Bool haveBase, haveSpectra;
     
    7477  Vector<uInt> nchans,npols;
    7578
    76   String antenna("0");
     79  String antenna("");
     80  Bool getPt = False;
     81
     82  // parsing MS options
     83  if ( rec.isDefined( "ms" ) ) {
     84    Record msrec = rec.asRecord( "ms" ) ;
     85    //msrec.print( cout ) ;
     86    if ( msrec.isDefined( "getpt" ) ) {
     87      getPt = msrec.asBool( "getpt" ) ;
     88    }
     89    if ( msrec.isDefined( "antenna" ) ) {
     90      if ( msrec.type( msrec.fieldNumber( "antenna" ) ) == TpInt ) {
     91        Int antInt = msrec.asInt( "antenna" ) ;
     92        ostringstream oss ;
     93        oss << antInt ;
     94        antenna = String( oss ) ;
     95      }
     96      else {
     97        antenna = msrec.asString( "antenna" ) ;
     98      }
     99    }
     100  }
    77101
    78102  reader_ = getPKSreader(inName, antenna, 0, 0, format, beams, ifs,
     
    146170  Vector<Int> start(nIF_, 1);
    147171  Vector<Int> end(nIF_, 0);
    148   Bool getPt = False;
    149172  reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0], False, getPt);
    150173  setHeader(header);
     
    263286    Int match = pksrec.srcName.matches(rx);
    264287    std::string srcname;
     288    Int srctype = Int(SrcType::NOTYPE);
    265289    if (match) {
    266290      srcname = pksrec.srcName;
     291      srctype =  Int(SrcType::PSOFF);
    267292    } else {
    268293      srcname = pksrec.srcName.before(rx2);
    269     }
    270     Int srctype = match;
    271     if ( pksrec.srcType != -1 ) {
     294      srctype =  Int(SrcType::PSON);
     295    }
     296    if ( pksrec.srcType != Int(SrcType::NOTYPE)) {
    272297      srctype = pksrec.srcType ;
    273298    }
  • trunk/src/PKSFiller.h

    r1848 r1947  
    2020#include <casa/Arrays/Vector.h>
    2121
     22
    2223#include "FillerBase.h"
    2324#include "Scantable.h"
    2425
     26class casa::Record;
    2527class PKSreader;
    2628
     
    3436    virtual ~PKSFiller();
    3537
    36 //    bool open(const std::string& filename, const Record& rec)=0;
    37     bool open(const std::string& filename);
     38    bool open(const std::string& filename, const casa::Record& rec);
     39    //    bool open(const std::string& filename);
    3840    void fill();
    3941    void close();
  • trunk/src/SConscript

    • Property svn:mergeinfo changed (with no actual effect on merging)
    r1848 r1947  
    88cpps = env.SGlob("*.cpp")
    99pycpps = env.SGlob("python_*.cpp")
    10 for pf in pycpps: cpps.remove(pf)
     10for pf in pycpps:
     11    cpps.remove(pf)
    1112
    1213# location of libcasav.a
     
    1819myenv.Prepend( LIBS =  ['asap'] )
    1920
     21shenv = myenv.Clone()
     22pyrapdir = shenv.get("pyrapint", None)
     23if pyrapdir:
     24    shenv.PrependUnique(CPPPATH=pyrapdir)   
     25    pycpps += shenv.Glob('%s/pyrap/*/*.cc' % pyrapdir)
    2026# Finally create the library for the module
    21 if not hasattr(myenv, "LoadableModule"):
    22     myenv.LoadableModule = myenv.SharedLibrary
    23 so = myenv.LoadableModule( target = "_asap.so", source = pycpps, SHLIBSUFFIX="" )
    24 #test = myenv.Program("test", cpps)
     27if not hasattr(shenv, "LoadableModule"):
     28    shenv.LoadableModule = shenv.SharedLibrary
     29so = shenv.LoadableModule( target = "_asap.so", source = pycpps, SHLIBSUFFIX="" )
     30#test = shenv.Program("test", cpps)
    2531Return("so")
    2632
  • trunk/src/STFit.cpp

    r1848 r1947  
    7070  table_.addColumn(ArrayColumnDesc<Int>("COMPONENTS"));
    7171  table_.addColumn(ArrayColumnDesc<Double>("PARAMETERS"));
     72  //  table_.addColumn(ArrayColumnDesc<Double>("ERRORS"));
    7273  table_.addColumn(ArrayColumnDesc<Bool>("PARMASKS"));
    7374  table_.addColumn(ArrayColumnDesc<String>("FRAMEINFO"));
     
    7778  compCol_.attach(table_,"COMPONENTS");
    7879  parCol_.attach(table_,"PARAMETERS");
     80  //  errCol_.attach(table_,"ERRORS");
    7981  maskCol_.attach(table_,"PARMASKS");
    8082  frameCol_.attach(table_,"FRAMEINFO");
     
    102104  // add new row if new id
    103105  if ( !foundentry ) table_.addRow();
     106
    104107  funcCol_.put(rno, mathutil::toVectorString(fit.getFunctions()));
    105108  compCol_.put(rno, Vector<Int>(fit.getComponents()));
    106   parCol_.put(rno, Vector<Double>(fit.getParameters()));
     109  const std::vector<float>& pvec = fit.getParameters();
     110  Vector<Double> dvec(pvec.size());
     111  for (size_t i=0; i < dvec.nelements(); ++i) {
     112    dvec[i] = Double(pvec[i]);
     113  }
     114  parCol_.put(rno, dvec);
     115  /*
     116  const std::vector<double>& evec = fit.getErrors();
     117  for (size_t i=0; i < dvec.nelements(); ++i) {
     118    dvec[i] = Double(evec[i]);
     119  }
     120  errCol_.put(rno, dvec);
     121  */
    107122  maskCol_.put(rno, Vector<Bool>(fit.getParmasks()));
    108123  frameCol_.put(rno, mathutil::toVectorString(fit.getFrameinfo()));
    109124  idCol_.put(rno, resultid);
     125
    110126  return resultid;
    111127}
     
    130146  fit.setComponents(istl);
    131147  Vector<Double> dvec;
    132   std::vector<double> dstl;
    133148  rec.get("PARAMETERS", dvec);
     149  std::vector<float> dstl(dvec.begin(), dvec.end());
     150  fit.setParameters(dstl);
     151  /*
    134152  dvec.tovector(dstl);
    135153  fit.setParameters(dstl);
     154  dvec.resize();
     155  rec.get("ERRORS", dvec);
     156  dvec.tovector(dstl);
     157  fit.setErrors(dstl);
     158  */
    136159  Vector<Bool> bvec;
    137160  std::vector<bool> bstl;
  • trunk/src/STFit.h

    r1848 r1947  
    4949  casa::ArrayColumn<casa::Int> compCol_;
    5050  casa::ArrayColumn<casa::Double> parCol_;
     51  //  casa::ArrayColumn<casa::Double> errCol_;
    5152  casa::ArrayColumn<casa::Bool> maskCol_;
    5253  casa::ArrayColumn<casa::String> frameCol_;
  • trunk/src/STFitEntry.cpp

    r1848 r1947  
    1111//
    1212#include "STFitEntry.h"
     13#include <casa/iostream.h>
    1314
     15using namespace casa;
    1416namespace asap {
    1517
    16 STFitEntry::STFitEntry()
     18  STFitEntry::STFitEntry()
     19  /* :
     20    functions_( std::vector<std::string>()),
     21    components_(std::vector<int>()),
     22    parameters_(std::vector<float>()),
     23    errors_(std::vector<float>()),
     24    parmasks_(std::vector<bool>()),
     25    frameinfo_(std::vector<std::string>())
     26  */
    1727{
    1828}
     
    2030{
    2131  if ( this != &other ) {
    22     this->functions_ = other.functions_;
     32    this->functions_ = std::vector<std::string>();
    2333    this->components_ = other.components_;
    2434    this->parameters_ = other.parameters_;
    25     this->parmasks_ = other.parmasks_;
     35    this->errors_ = other.errors_;
    2636    this->frameinfo_ = other.frameinfo_;
    2737  }
    2838}
    2939
     40STFitEntry& STFitEntry::operator=(const STFitEntry& other)
     41{
     42  if ( this != &other ) {
     43    this->functions_ = other.functions_;
     44    this->components_ = other.components_;
     45    this->parameters_ = other.parameters_;
     46    this->errors_ = other.errors_;
     47    this->parmasks_ = other.parmasks_;
     48    this->frameinfo_ = other.frameinfo_;
     49  }
     50  return *this;
     51}
    3052
    3153STFitEntry::~STFitEntry()
  • trunk/src/STFitEntry.h

    r1848 r1947  
    2828  STFitEntry(const STFitEntry& other);
    2929
     30  STFitEntry& operator=(const STFitEntry& other);
     31
    3032  ~STFitEntry();
    3133
     
    3436  void setComponents(const std::vector<int>& c)
    3537    { components_ = c; }
    36   void setParameters(const std::vector<double>& p)
     38  void setParameters(const std::vector<float>& p)
    3739    { parameters_ = p; }
     40  void setErrors(const std::vector<float>& p)
     41    { errors_ = p; }
    3842  void setParmasks(const std::vector<bool>& m)
    3943    { parmasks_ = m; }
    4044  void setFrameinfo(const std::vector<std::string>& f)
    4145    { frameinfo_ = f; }
    42 
    4346  std::vector<std::string> getFunctions() const { return functions_; }
    4447  std::vector<int> getComponents() const { return components_; }
    45   std::vector<double> getParameters() const { return parameters_; }
     48  std::vector<float> getParameters() const { return parameters_; }
     49  std::vector<float> getErrors() const { return errors_; }
    4650  std::vector<bool> getParmasks() const { return parmasks_; }
    4751  std::vector<std::string> getFrameinfo() const { return frameinfo_; }
    4852
    4953private:
     54
    5055  std::vector<std::string> functions_;
    5156  std::vector<int> components_;
    52   std::vector<double> parameters_;
     57  std::vector<float> parameters_;
     58  std::vector<float> errors_;
    5359  std::vector<bool> parmasks_;
    5460  std::vector<std::string> frameinfo_;
  • trunk/src/STFitter.cpp

    r1848 r1947  
    142142    if (ncomp < 1) throw (AipsError("Need at least one gaussian to fit."));
    143143    funcs_.resize(ncomp);
     144    funcnames_.clear();
     145    funccomponents_.clear();
    144146    for (Int k=0; k<ncomp; ++k) {
    145147      funcs_[k] = new Gaussian1D<Float>();
     148      funcnames_.push_back(expr);
     149      funccomponents_.push_back(3);
    146150    }
    147151  } else if (expr == "poly") {
    148152    funcs_.resize(1);
     153    funcnames_.clear();
     154    funccomponents_.clear();
    149155    funcs_[0] = new Polynomial<Float>(ncomp);
     156      funcnames_.push_back(expr);
     157      funccomponents_.push_back(ncomp);
    150158  } else if (expr == "lorentz") {
    151159    if (ncomp < 1) throw (AipsError("Need at least one lorentzian to fit."));
    152160    funcs_.resize(ncomp);
     161    funcnames_.clear();
     162    funccomponents_.clear();
    153163    for (Int k=0; k<ncomp; ++k) {
    154164      funcs_[k] = new Lorentzian1D<Float>();
     165      funcnames_.push_back(expr);
     166      funccomponents_.push_back(3);
    155167    }
    156168  } else {
     
    409421}
    410422
     423STFitEntry Fitter::getFitEntry() const
     424{
     425  STFitEntry fit;
     426  fit.setParameters(getParameters());
     427  fit.setErrors(getErrors());
     428  fit.setComponents(funccomponents_);
     429  fit.setFunctions(funcnames_);
     430  fit.setParmasks(getFixedParameters());
     431  return fit;
     432}
  • trunk/src/STFitter.h

    r1848 r1947  
    4040#include <scimath/Functionals/CompoundFunction.h>
    4141
     42#include "STFitEntry.h"
     43
    4244namespace asap {
    4345
     
    6971
    7072  std::vector<float> evaluate(int whichComp) const;
     73
     74  STFitEntry getFitEntry() const;
     75
    7176private:
    7277  void clear();
     
    7580  casa::Vector<casa::Bool> m_;
    7681  casa::PtrBlock<casa::Function<casa::Float>* > funcs_;
     82  std::vector<std::string> funcnames_;
     83  std::vector<int> funccomponents_;
     84 
    7785  //Bool estimateSet_;
    7886  casa::Float chisquared_;
  • trunk/src/STMath.cpp

    r1848 r1947  
    17961796    out.push_back(outstat);
    17971797  }
     1798  return out;
     1799}
     1800
     1801std::vector< float > STMath::statisticRow( const CountedPtr< Scantable > & in,
     1802                                        const std::vector< bool > & mask,
     1803                                        const std::string& which,
     1804                                        int row )
     1805{
     1806
     1807  Vector<Bool> m(mask);
     1808  const Table& tab = in->table();
     1809  ROArrayColumn<Float> specCol(tab, "SPECTRA");
     1810  ROArrayColumn<uChar> flagCol(tab, "FLAGTRA");
     1811  std::vector<float> out;
     1812
     1813  Vector<Float> spec; specCol.get(row, spec);
     1814  Vector<uChar> flag; flagCol.get(row, flag);
     1815  MaskedArray<Float> ma  = maskedArray(spec, flag);
     1816  float outstat = 0.0;
     1817  if ( spec.nelements() == m.nelements() ) {
     1818    outstat = mathutil::statistics(which, ma(m));
     1819  } else {
     1820    outstat = mathutil::statistics(which, ma);
     1821  }
     1822  out.push_back(outstat);
     1823
    17981824  return out;
    17991825}
  • trunk/src/STMath.h

    r1848 r1947  
    262262                                      const casa::CountedPtr<Scantable> &ref,
    263263                                      casa::Double choffset,
    264                                       casa::Double choffset = 0.0 );
     264                                      casa::Double choffset2 = 0.0 );
    265265
    266266  /**
     
    277277                               const std::vector<bool>& mask,
    278278                               const std::string& which);
     279
     280  std::vector<float> statisticRow(const casa::CountedPtr<Scantable>& in,
     281                               const std::vector<bool>& mask,
     282                               const std::string& which,
     283                               int row);
    279284
    280285  std::vector< int > minMaxChan(const casa::CountedPtr<Scantable>& in,
  • trunk/src/STMathWrapper.h

    r1848 r1947  
    132132  { return STMath::statistic(in.getCP(), mask, which); }
    133133
     134  std::vector<float> statisticRow(const ScantableWrapper& in,
     135                               const std::vector<bool>& mask,
     136                               const std::string& which,
     137                               int row)
     138  { return STMath::statisticRow(in.getCP(), mask, which, row); }
     139
    134140  std::vector<int> minMaxChan(const ScantableWrapper& in,
    135141                               const std::vector<bool>& mask,
  • trunk/src/STSelector.cpp

    r1848 r1947  
    270270}
    271271
     272std::vector< int > asap::STSelector::getRows( ) const
     273{
     274  return rowselection_ ;
     275}
     276
    272277std::string asap::STSelector::print( )
    273278{
  • trunk/src/STSelector.h

    r1848 r1947  
    5757  std::vector<int> getCycles() const;
    5858  std::vector<int> getTypes() const;
     59  std::vector<int> getRows() const;
    5960  std::vector<std::string> getPolTypes() const;
    6061  std::string getTaQL() const { return taql_; }
  • trunk/src/Scantable.cpp

    r1848 r1947  
    101101  fitTable_ = STFit(*this);
    102102  table_.rwKeywordSet().defineTable("FIT", fitTable_.table());
     103  table_.tableInfo().setType( "Scantable" ) ;
    103104  originalTable_ = table_;
    104105  attach();
     
    120121    table_ = tab;
    121122  }
     123  table_.tableInfo().setType( "Scantable" ) ;
    122124
    123125  attachSubtables();
     
    165167      table_.markForDelete();
    166168  }
     169  table_.tableInfo().setType( "Scantable" ) ;
    167170  /// @todo reindex SCANNO, recompute nbeam, nif, npol
    168171  if ( clear ) copySubtables(other);
     
    681684std::string Scantable::formatTime(const MEpoch& me, bool showdate) const
    682685{
     686  return formatTime(me, showdate, 0);
     687}
     688
     689std::string Scantable::formatTime(const MEpoch& me, bool showdate, uInt prec) const
     690{
    683691  MVTime mvt(me.getValue());
    684692  if (showdate)
    685     mvt.setFormat(MVTime::YMD);
     693    //mvt.setFormat(MVTime::YMD);
     694    mvt.setFormat(MVTime::YMD, prec);
    686695  else
    687     mvt.setFormat(MVTime::TIME);
     696    //mvt.setFormat(MVTime::TIME);
     697    mvt.setFormat(MVTime::TIME, prec);
    688698  ostringstream oss;
    689699  oss << mvt;
     
    10321042}
    10331043
    1034 std::string Scantable::getTime(int whichrow, bool showdate) const
    1035 {
    1036   MEpoch::ROScalarColumn timeCol(table_, "TIME");
     1044// std::string Scantable::getTime(int whichrow, bool showdate) const
     1045// {
     1046//   MEpoch::ROScalarColumn timeCol(table_, "TIME");
     1047//   MEpoch me;
     1048//   if (whichrow > -1) {
     1049//     me = timeCol(uInt(whichrow));
     1050//   } else {
     1051//     Double tm;
     1052//     table_.keywordSet().get("UTC",tm);
     1053//     me = MEpoch(MVEpoch(tm));
     1054//   }
     1055//   return formatTime(me, showdate);
     1056// }
     1057
     1058std::string Scantable::getTime(int whichrow, bool showdate, uInt prec) const
     1059{
    10371060  MEpoch me;
    1038   if (whichrow > -1) {
    1039     me = timeCol(uInt(whichrow));
    1040   } else {
    1041     Double tm;
    1042     table_.keywordSet().get("UTC",tm);
    1043     me = MEpoch(MVEpoch(tm));
    1044   }
    1045   return formatTime(me, showdate);
     1061  me = getEpoch(whichrow);
     1062  return formatTime(me, showdate, prec);
    10461063}
    10471064
     
    17091726}
    17101727
     1728bool Scantable::getFlagtraFast(int whichrow)
     1729{
     1730  uChar flag;
     1731  Vector<uChar> flags;
     1732  flagsCol_.get(uInt(whichrow), flags);
     1733  for (int i = 0; i < flags.size(); i++) {
     1734    if (i==0) {
     1735      flag = flags[i];
     1736    }
     1737    else {
     1738      flag &= flags[i];
     1739    }
     1740    return ((flag >> 7) == 1);
     1741   }
     1742}
     1743
     1744void Scantable::doPolyBaseline(const std::vector<bool>& mask, int order, int rowno, Fitter& fitter)
     1745{
     1746  fitter.setExpression("poly", order);
     1747
     1748  std::vector<double> abcsd = getAbcissa(rowno);
     1749  std::vector<float> abcs;
     1750  for (int i = 0; i < abcsd.size(); i++) {
     1751    abcs.push_back((float)abcsd[i]);
     1752  }
     1753  std::vector<float> spec = getSpectrum(rowno);
     1754  std::vector<bool> fmask = getMask(rowno);
     1755  if (fmask.size() != mask.size()) {
     1756    throw(AipsError("different mask sizes"));
     1757  }
     1758  for (int i = 0; i < fmask.size(); i++) {
     1759    fmask[i] = fmask[i] && mask[i];
     1760  }
     1761  fitter.setData(abcs, spec, fmask);
     1762
     1763  fitter.lfit();
     1764}
     1765
     1766void Scantable::polyBaselineBatch(const std::vector<bool>& mask, int order)
     1767{
     1768  Fitter fitter = Fitter();
     1769  for (uInt rowno=0; rowno < nrow(); ++rowno) {
     1770    doPolyBaseline(mask, order, rowno, fitter);
     1771    setSpectrum(fitter.getResidual(), rowno);
     1772  }
     1773}
     1774
     1775STFitEntry Scantable::polyBaseline(const std::vector<bool>& mask, int order, int rowno)
     1776{
     1777  Fitter fitter = Fitter();
     1778  doPolyBaseline(mask, order, rowno, fitter);
     1779  setSpectrum(fitter.getResidual(), rowno);
     1780  return fitter.getFitEntry();
     1781}
     1782
    17111783}
    17121784//namespace asap
  • trunk/src/Scantable.h

    r1848 r1947  
    1818// AIPS++
    1919#include <casa/aips.h>
     20#include <casa/Containers/Record.h>
    2021#include <casa/Arrays/MaskedArray.h>
    2122#include <casa/BasicSL/String.h>
     
    4748#include "STFit.h"
    4849#include "STFitEntry.h"
     50#include "STFitter.h"
    4951
    5052namespace asap {
     
    366368
    367369  std::string summary(bool verbose=false);
    368   std::string getTime(int whichrow=-1, bool showdate=true) const;
     370  //std::string getTime(int whichrow=-1, bool showdate=true) const;
     371  std::string getTime(int whichrow=-1, bool showdate=true, casa::uInt prec=0) const;
    369372  double getIntTime(int whichrow) const { return integrCol_(whichrow); }
    370373
     
    486489  void regridChannel( int nchan, double dnu, int irow ) ;
    487490
     491  bool getFlagtraFast(int whichrow);
     492
     493  void polyBaselineBatch(const std::vector<bool>& mask, int order);
     494  STFitEntry polyBaseline(const std::vector<bool>& mask, int order, int rowno);
    488495
    489496private:
     
    499506
    500507  std::string formatTime(const casa::MEpoch& me, bool showdate)const;
     508  std::string formatTime(const casa::MEpoch& me, bool showdate, casa::uInt prec)const;
    501509
    502510  /**
     
    506514   */
    507515  std::string formatDirection(const casa::MDirection& md) const;
    508 
    509516
    510517  /**
     
    598605                                                      const casa::String&,
    599606                                                      const casa::Array<T2>&);
     607
     608  void doPolyBaseline(const std::vector<bool>& mask, int order, int rowno, Fitter& fitter);
    600609};
    601610
  • trunk/src/ScantableWrapper.h

    r1848 r1947  
    1919#include "MathUtils.h"
    2020#include "STFit.h"
     21#include "STFitEntry.h"
    2122#include "Scantable.h"
    2223#include "STCoordinate.h"
     
    8384    { return table_->getTsys(whichrow); }
    8485
    85   std::string getTime(int whichrow=0) const
    86     { return table_->getTime(whichrow); }
     86  //std::string getTime(int whichrow=0) const
     87  //  { return table_->getTime(whichrow); }
     88  std::string getTime(int whichrow=0, int prec = 0) const
     89    { return table_->getTime(whichrow, true, casa::uInt(prec)); }
    8790
    8891  double getIntTime(int whichrow=0) const
     
    250253  { table_->reshapeSpectrum( nmin, nmax ); }
    251254
     255  STFitEntry polyBaseline(const std::vector<bool>& mask, int order, int rowno)
     256  { return table_->polyBaseline(mask, order, rowno); }
     257
     258  void polyBaselineBatch(const std::vector<bool>& mask, int order)
     259  { table_->polyBaselineBatch(mask, order); }
     260
     261  bool getFlagtraFast(int whichrow=0) const
     262    { return table_->getFlagtraFast(whichrow); }
     263
     264
    252265private:
    253266  casa::CountedPtr<Scantable> table_;
  • trunk/src/python_LogSink.cpp

    r1848 r1947  
    4141        .def( init <> () )
    4242        .def("post", &AsapLogSink::postMessage,
    43          (boost::python::arg("location")="",
    44          boost::python::arg("priority")="INFO"))
     43         (boost::python::arg("priority")="INFO",
     44         boost::python::arg("origin")=""))
    4545        .def("pop", &AsapLogSink::popMessages)
    4646      ;
  • trunk/src/python_STFitEntry.cpp

    r1848 r1947  
    4444        .def("getfixedparameters", &STFitEntry::getParmasks)
    4545        .def("getparameters", &STFitEntry::getParameters)
     46        .def("geterrors", &STFitEntry::getErrors)
    4647        .def("getfunctions", &STFitEntry::getFunctions)
    4748        .def("getcomponents", &STFitEntry::getComponents)
     
    4950        .def("setfixedparameters", &STFitEntry::setParmasks)
    5051        .def("setparameters", &STFitEntry::setParameters)
     52        .def("seterrors", &STFitEntry::setErrors)
    5153        .def("setfunctions", &STFitEntry::setFunctions)
    5254        .def("setcomponents", &STFitEntry::setComponents)
  • trunk/src/python_STMath.cpp

    r1848 r1947  
    5959        .def("_dofs", &STMathWrapper::dofs)
    6060        .def("_stats", &STMathWrapper::statistic)
     61        .def("_statsrow", &STMathWrapper::statisticRow)
    6162        .def("_minmaxchan", &STMathWrapper::minMaxChan)
    6263        .def("_freqswitch", &STMathWrapper::freqSwitch)
  • trunk/src/python_STSelector.cpp

    r1848 r1947  
    3030        .def("_getcycles", &STSelector::getCycles)
    3131        .def("_gettypes", &STSelector::getTypes)
     32        .def("_getrows", &STSelector::getRows)
    3233        .def("_gettaql", &STSelector::getTaQL)
    3334        .def("_getorder", &STSelector::getSortOrder)
  • trunk/src/python_Scantable.cpp

    r1848 r1947  
    9999    .def("_getparangle", &ScantableWrapper::getParAngle,
    100100         (boost::python::arg("whichrow")=0) )
     101    //.def("_gettime", &ScantableWrapper::getTime,
     102    //     (boost::python::arg("whichrow")=0) )
    101103    .def("_gettime", &ScantableWrapper::getTime,
    102          (boost::python::arg("whichrow")=0) )
     104         (boost::python::arg("whichrow")=0,
     105          boost::python::arg("prec")=0) )
    103106    .def("_getinttime", &ScantableWrapper::getIntTime,
    104107         (boost::python::arg("whichrow")=0) )
     
    139142         (boost::python::arg("nmin")=-1,
    140143          boost::python::arg("nmax")=-1) )
     144    .def("_poly_baseline", &ScantableWrapper::polyBaseline)
     145    .def("_poly_baseline_batch", &ScantableWrapper::polyBaselineBatch)
     146    .def("_getflagtrafast", &ScantableWrapper::getFlagtraFast,
     147         (boost::python::arg("whichrow")=0) )
    141148  ;
    142149};
  • trunk/src/python_asap.cpp

    r1848 r1947  
    4444  #include <pyrap/Converters/PycExcp.h>
    4545  #include <pyrap/Converters/PycBasicData.h>
     46  #include <pyrap/Converters/PycValueHolder.h>
     47  #include <pyrap/Converters/PycRecord.h>
    4648#endif
    4749
     
    108110  casa::pyrap::register_convert_basicdata();
    109111  casa::pyrap::register_convert_std_vector<asap::ScantableWrapper>();
     112  casa::pyrap::register_convert_std_vector<int>();
     113  casa::pyrap::register_convert_std_vector<uint>();
     114  casa::pyrap::register_convert_std_vector<float>();
     115  casa::pyrap::register_convert_std_vector<double>();
     116  casa::pyrap::register_convert_std_vector<std::string>();
     117  casa::pyrap::register_convert_std_vector<bool>();
     118  casa::pyrap::register_convert_casa_valueholder();
     119  casa::pyrap::register_convert_casa_record();
    110120#endif
    111121}
Note: See TracChangeset for help on using the changeset viewer.