Changeset 1700 for branches/alma


Ignore:
Timestamp:
02/16/10 16:21:26 (14 years ago)
Author:
WataruKawasaki
Message:

New Development: Yes

JIRA Issue: Yes (CAS-1800 + CAS-1807)

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed: added parameters fitfunc for sdfit and clip, clipmaxmin, clipoutside for sdflag

Test Programs:

Put in Release Notes: No

Module(s): sdfit, sdflag

Description: Added a parameter for enabling Lorentzian line fitting with sdfit, and parameters for y-axis clipping with sdflag. Also 4 files for Lorentzian function class are (Lorentzian1D*) added.


Location:
branches/alma/src
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/src/Makefile

    r1693 r1700  
    2424CASAINC   := -I$(CASAROOT)/code/include -I$(COREINCD) -I$(CASAROOT)/$(CASAARCH)/include
    2525CASALIB   := $(CASAROOT)/$(CASAARCH)/lib
    26 USELIB := lib
     26USELIB := lib64
    2727
    2828# the compiler
     
    3434CXXFLAGS := -fPIC -O3 -g
    3535CXXFLAGS += -ansi -Wno-long-long -Wall
     36CXXOPTS := -DAIPS_64B
    3637
    3738# darwin specific flags
     
    5657# if not than there might by symbol resolution errors.
    5758CASAPPLIB := -L$(CASALIB) -latnf $(CORELIB) \
    58              -L$(WCSLIBLIBD) $(WCSLIBLIB) \
     59                /usr/lib64/libwcs.so \
    5960             $(RPFITSLIB) $(CFITSIOLIB) $(G2CLIB) -lstdc++
     61#             -L$(WCSLIBLIBD) $(WCSLIBLIB) \
    6062
    6163# darwin specific CASA flags
     
    140142
    141143HEADERS   := MathUtils.h \
     144             Lorentzian1D.h \
     145             Lorentzian1DParam.h \
    142146             Logger.h \
    143147             STAttr.h \
  • branches/alma/src/STFitter.cpp

    r1616 r1700  
    3838#include <scimath/Functionals/CompoundFunction.h>
    3939#include <scimath/Functionals/Gaussian1D.h>
     40#include "Lorentzian1D.h"
    4041#include <scimath/Functionals/Polynomial.h>
    4142#include <scimath/Mathematics/AutoDiff.h>
     
    147148    funcs_.resize(1);
    148149    funcs_[0] = new Polynomial<Float>(ncomp);
     150  } else if (expr == "lorentz") {
     151    if (ncomp < 1) throw (AipsError("Need at least one lorentzian to fit."));
     152    funcs_.resize(ncomp);
     153    for (Int k=0; k<ncomp; ++k) {
     154      funcs_[k] = new Lorentzian1D<Float>();
     155    }
    149156  } else {
    150157    //cerr << " compiled functions not yet implemented" << endl;
     
    230237            (funcs_[0]->parameters())[i] =  tmppar[i];
    231238        }
     239    } else if (dynamic_cast<Lorentzian1D<Float>* >(funcs_[0]) != 0) {
     240        uInt count = 0;
     241        for (uInt j=0; j < funcs_.nelements(); ++j) {
     242            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
     243                (funcs_[j]->parameters())[i] = tmppar[count];
     244                parameters_[count] = tmppar[count];
     245                ++count;
     246            }
     247        }
    232248    }
    233249    // reset
     
    263279            funcs_[0]->mask(i) =  !fixed[i];
    264280        }
     281    } else if (dynamic_cast<Lorentzian1D<Float>* >(funcs_[0]) != 0) {
     282      uInt count = 0;
     283        for (uInt j=0; j < funcs_.nelements(); ++j) {
     284            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
     285                funcs_[j]->mask(i) = !fixed[count];
     286                fixedpar_[count] = fixed[count];
     287                ++count;
     288            }
     289        }
    265290    }
    266291    return true;
  • branches/alma/src/Scantable.cpp

    r1656 r1700  
    701701  }
    702702  pushLog(String(oss));
     703}
     704
     705void Scantable::clip(const Float uthres, const Float dthres, bool clipoutside, bool unflag)
     706{
     707  for (uInt i=0; i<table_.nrow(); ++i) {
     708    Vector<Float> spcs = specCol_(i);
     709    Vector<uChar> flgs = flagsCol_(i);
     710    if (spcs.nelements() != nchan) {
     711      throw(AipsError("Data has incorrect number of channels"));
     712    }
     713    uChar userflag = 1 << 7;
     714    if (unflag) {
     715      userflag = 0 << 7;
     716    }
     717    if (clipoutside) {
     718      for (uInt j = 0; j < nchan; ++j) {
     719        Float spc = spcs(j);
     720        if ((spc >= uthres) || (spc <= dthres)) {
     721          flgs(j) = userflag;
     722        }
     723      }
     724    } else {
     725      for (uInt j = 0; j < nchan; ++j) {
     726        Float spc = spcs(j);
     727        if ((spc < uthres) && (spc > dthres)) {
     728          flgs(j) = userflag;
     729        }
     730      }
     731    }
     732    flagsCol_.put(i, flgs);
     733  }
    703734}
    704735
  • branches/alma/src/Scantable.h

    r1656 r1700  
    244244
    245245  /**
     246   * Flag the data outside a specified range (in a channel-based manner).
     247   * (CAS-1807 Wataru Kawasaki)
     248   */
     249  void Scantable::clip(const Float uthres, const Float dthres, bool clipoutside, bool unflag);
     250
     251  /**
    246252   * Return a list of row numbers with respect to the original table.
    247253   * @return a list of unsigned ints
  • branches/alma/src/ScantableWrapper.h

    r1656 r1700  
    114114    { return table_->getFlagRow(whichrow); }
    115115
     116  void clip(const Float uthres, const Float dthres, bool clipoutside=true, bool unflag=false)
     117    { table_->clip(uthres, dthres, clipoutside, unflag); }
     118
    116119  std::string getSourceName(int whichrow=0) const
    117120    { return table_->getSourceName(whichrow); }
  • branches/alma/src/python_Scantable.cpp

    r1656 r1700  
    108108    .def("_getflagrow", &ScantableWrapper::getFlagRow,
    109109         (boost::python::arg("whichrow")=0) )
     110    .def("_clip", &ScantableWrapper::clip,
     111         (boost::python::arg("clipoutside")=true,
     112          boost::python::arg("unflag")=false) )
    110113    .def("_save",  &ScantableWrapper::makePersistent)
    111114    .def("_summary",  &ScantableWrapper::summary,
Note: See TracChangeset for help on using the changeset viewer.