Ignore:
Timestamp:
01/11/13 18:48:37 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-4770, CAS-4774

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Updated STApplyCal to be able to specify interpolation method.
The method can be specified in time and frequency axes independently.
Possible options are nearest, linear (default), (natural) cubic spline,
and polynomial with arbitrary order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STApplyCal.cpp

    r2722 r2727  
    3434#include "PSAlmaCalibrator.h"
    3535#include "NearestInterpolator1D.h"
     36#include "BufferedLinearInterpolator1D.h"
     37#include "PolynomialInterpolator1D.h"
     38#include "CubicSplineInterpolator1D.h"
    3639#include <atnf/PKSIO/SrcType.h>
    3740
     
    6265  doTsys_ = False;
    6366  interp_.resize((int)STCalEnum::NumAxis);
     67  // default is linear interpolation
     68  for (unsigned int i = 0; i < interp_.size(); i++) {
     69    interp_[i] = STCalEnum::LinearInterpolation;
     70  }
    6471}
    6572
     
    125132
    126133  // interpolator
    127   interpolatorS_ = new NearestInterpolator1D();
    128   interpolatorT_ = new NearestInterpolator1D();
    129   interpolatorF_ = new NearestInterpolator1D();
     134  initInterpolator();
    130135
    131136  // select data
     
    450455}
    451456
    452 }
     457void STApplyCal::initInterpolator()
     458{
     459  int ta = (int)STCalEnum::TimeAxis;
     460  int fa = (int)STCalEnum::FrequencyAxis;
     461  int order = (order_ > 0) ? order_ : 1;
     462  switch (interp_[ta]) {
     463  case STCalEnum::NearestInterpolation:
     464    {
     465      os_ << "use NearestInterpolator in time axis" << LogIO::POST;
     466      interpolatorS_ = new NearestInterpolator1D();
     467      interpolatorT_ = new NearestInterpolator1D();
     468      break;
     469    }
     470  case STCalEnum::LinearInterpolation:
     471    {
     472      os_ << "use BufferedLinearInterpolator in time axis" << LogIO::POST;
     473      interpolatorS_ = new BufferedLinearInterpolator1D();
     474      interpolatorT_ = new BufferedLinearInterpolator1D();
     475      break;     
     476    }
     477  case STCalEnum::CubicSplineInterpolation:
     478    {
     479      os_ << "use CubicSplineInterpolator in time axis" << LogIO::POST;
     480      interpolatorS_ = new CubicSplineInterpolator1D();
     481      interpolatorT_ = new CubicSplineInterpolator1D();
     482      break;
     483    }
     484  case STCalEnum::PolynomialInterpolation:
     485    {
     486      os_ << "use PolynomialInterpolator in time axis" << LogIO::POST;
     487      if (order == 0) {
     488        interpolatorS_ = new NearestInterpolator1D();
     489        interpolatorT_ = new NearestInterpolator1D();
     490      }
     491      else {
     492        interpolatorS_ = new PolynomialInterpolator1D();
     493        interpolatorT_ = new PolynomialInterpolator1D();
     494        interpolatorS_->setOrder(order);
     495        interpolatorT_->setOrder(order);
     496      }
     497      break;
     498    }
     499  default:
     500    {
     501      os_ << "use BufferedLinearInterpolator in time axis" << LogIO::POST;
     502      interpolatorS_ = new BufferedLinearInterpolator1D();
     503      interpolatorT_ = new BufferedLinearInterpolator1D();
     504      break;     
     505    }
     506  }
     507   
     508  switch (interp_[fa]) {
     509  case STCalEnum::NearestInterpolation:
     510    {
     511      os_ << "use NearestInterpolator in frequency axis" << LogIO::POST;
     512      interpolatorF_ = new NearestInterpolator1D();
     513      break;
     514    }
     515  case STCalEnum::LinearInterpolation:
     516    {
     517      os_ << "use BufferedLinearInterpolator in frequency axis" << LogIO::POST;
     518      interpolatorF_ = new BufferedLinearInterpolator1D();
     519      break;     
     520    }
     521  case STCalEnum::CubicSplineInterpolation:
     522    {
     523      os_ << "use CubicSplineInterpolator in frequency axis" << LogIO::POST;
     524      interpolatorF_ = new CubicSplineInterpolator1D();
     525      break;
     526    }
     527  case STCalEnum::PolynomialInterpolation:
     528    {
     529      os_ << "use PolynomialInterpolator in frequency axis" << LogIO::POST;
     530      if (order == 0) {
     531        interpolatorF_ = new NearestInterpolator1D();
     532      }
     533      else {
     534        interpolatorF_ = new PolynomialInterpolator1D();
     535        interpolatorF_->setOrder(order);
     536      }
     537      break;
     538    }
     539  default:
     540    {
     541      os_ << "use LinearInterpolator in frequency axis" << LogIO::POST;
     542      interpolatorF_ = new BufferedLinearInterpolator1D();
     543      break;     
     544    }
     545  }
     546}
     547}
Note: See TracChangeset for help on using the changeset viewer.