Ignore:
Timestamp:
03/15/11 18:31:04 (13 years ago)
Author:
WataruKawasaki
Message:

New Development: Yes

JIRA Issue: Yes CAS-2847

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: Yes

Module(s): scantable

Description: added {auto_}sinusoid_baseline() for sinusoidal baseline fitting. also minor bug fixes for asapfitter.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFitter.cpp

    r1932 r2047  
    3939#include <scimath/Functionals/Gaussian1D.h>
    4040#include "Lorentzian1D.h"
     41#include <scimath/Functionals/Sinusoid1D.h>
    4142#include <scimath/Functionals/Polynomial.h>
    4243#include <scimath/Mathematics/AutoDiff.h>
     
    149150      funccomponents_.push_back(3);
    150151    }
    151   } else if (expr == "poly") {
    152     funcs_.resize(1);
    153     funcnames_.clear();
    154     funccomponents_.clear();
    155     funcs_[0] = new Polynomial<Float>(ncomp);
    156       funcnames_.push_back(expr);
    157       funccomponents_.push_back(ncomp);
    158152  } else if (expr == "lorentz") {
    159153    if (ncomp < 1) throw (AipsError("Need at least one lorentzian to fit."));
     
    166160      funccomponents_.push_back(3);
    167161    }
     162  } else if (expr == "sinusoid") {
     163    if (ncomp < 1) throw (AipsError("Need at least one sinusoid to fit."));
     164    funcs_.resize(ncomp);
     165    funcnames_.clear();
     166    funccomponents_.clear();
     167    for (Int k=0; k<ncomp; ++k) {
     168      funcs_[k] = new Sinusoid1D<Float>();
     169      funcnames_.push_back(expr);
     170      funccomponents_.push_back(3);
     171    }
     172  } else if (expr == "poly") {
     173    funcs_.resize(1);
     174    funcnames_.clear();
     175    funccomponents_.clear();
     176    funcs_[0] = new Polynomial<Float>(ncomp);
     177      funcnames_.push_back(expr);
     178      funccomponents_.push_back(ncomp);
    168179  } else {
    169     //cerr << " compiled functions not yet implemented" << endl;
    170180    LogIO os( LogOrigin( "Fitter", "setExpression()", WHERE ) ) ;
    171181    os << LogIO::WARN << " compiled functions not yet implemented" << LogIO::POST;
     
    244254            }
    245255        }
     256    } else if (dynamic_cast<Lorentzian1D<Float>* >(funcs_[0]) != 0) {
     257        uInt count = 0;
     258        for (uInt j=0; j < funcs_.nelements(); ++j) {
     259            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
     260                (funcs_[j]->parameters())[i] = tmppar[count];
     261                parameters_[count] = tmppar[count];
     262                ++count;
     263            }
     264        }
     265    } else if (dynamic_cast<Sinusoid1D<Float>* >(funcs_[0]) != 0) {
     266        uInt count = 0;
     267        for (uInt j=0; j < funcs_.nelements(); ++j) {
     268            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
     269                (funcs_[j]->parameters())[i] = tmppar[count];
     270                parameters_[count] = tmppar[count];
     271                ++count;
     272            }
     273        }
    246274    } else if (dynamic_cast<Polynomial<Float>* >(funcs_[0]) != 0) {
    247275        for (uInt i=0; i < funcs_[0]->nparameters(); ++i) {
    248276            parameters_[i] = tmppar[i];
    249277            (funcs_[0]->parameters())[i] =  tmppar[i];
    250         }
    251     } else if (dynamic_cast<Lorentzian1D<Float>* >(funcs_[0]) != 0) {
    252         uInt count = 0;
    253         for (uInt j=0; j < funcs_.nelements(); ++j) {
    254             for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
    255                 (funcs_[j]->parameters())[i] = tmppar[count];
    256                 parameters_[count] = tmppar[count];
    257                 ++count;
    258             }
    259278        }
    260279    }
     
    286305            }
    287306        }
     307    } else if (dynamic_cast<Lorentzian1D<Float>* >(funcs_[0]) != 0) {
     308      uInt count = 0;
     309        for (uInt j=0; j < funcs_.nelements(); ++j) {
     310            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
     311                funcs_[j]->mask(i) = !fixed[count];
     312                fixedpar_[count] = fixed[count];
     313                ++count;
     314            }
     315        }
     316    } else if (dynamic_cast<Sinusoid1D<Float>* >(funcs_[0]) != 0) {
     317      uInt count = 0;
     318        for (uInt j=0; j < funcs_.nelements(); ++j) {
     319            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
     320                funcs_[j]->mask(i) = !fixed[count];
     321                fixedpar_[count] = fixed[count];
     322                ++count;
     323            }
     324        }
    288325    } else if (dynamic_cast<Polynomial<Float>* >(funcs_[0]) != 0) {
    289326        for (uInt i=0; i < funcs_[0]->nparameters(); ++i) {
    290327            fixedpar_[i] = fixed[i];
    291328            funcs_[0]->mask(i) =  !fixed[i];
    292         }
    293     } else if (dynamic_cast<Lorentzian1D<Float>* >(funcs_[0]) != 0) {
    294       uInt count = 0;
    295         for (uInt j=0; j < funcs_.nelements(); ++j) {
    296             for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
    297                 funcs_[j]->mask(i) = !fixed[count];
    298                 fixedpar_[count] = fixed[count];
    299                 ++count;
    300             }
    301329        }
    302330    }
Note: See TracChangeset for help on using the changeset viewer.