Changeset 896 for trunk/src/STMath.cpp


Ignore:
Timestamp:
03/10/06 12:09:29 (18 years ago)
Author:
mar637
Message:

enable polarimetry in asap2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r878 r896  
    871871  return out;
    872872}
     873
     874CountedPtr< Scantable >
     875  STMath::invertPhase( const CountedPtr < Scantable >& in )
     876{
     877  applyToPol(in, &STPol::invertPhase, Float(0.0));
     878}
     879
     880CountedPtr< Scantable >
     881  STMath::rotateXYPhase( const CountedPtr < Scantable >& in, float phase )
     882{
     883   return applyToPol(in, &STPol::rotatePhase, Float(phase));
     884}
     885
     886CountedPtr< Scantable >
     887  STMath::rotateLinPolPhase( const CountedPtr < Scantable >& in, float phase )
     888{
     889  return applyToPol(in, &STPol::rotateLinPolPhase, Float(phase));
     890}
     891
     892CountedPtr< Scantable > STMath::applyToPol( const CountedPtr<Scantable>& in,
     893                                             STPol::polOperation fptr,
     894                                             Float phase )
     895{
     896  CountedPtr< Scantable > out = getScantable(in, false);
     897  Table& tout = out->table();
     898  Block<String> cols(4);
     899  cols[0] = String("SCANNO");
     900  cols[1] = String("BEAMNO");
     901  cols[2] = String("IFNO");
     902  cols[3] = String("CYCLENO");
     903  TableIterator iter(tout, cols);
     904  STPol* stpol = NULL;
     905  stpol =STPol::getPolClass(Scantable::getFactories(), out->getPolType() );
     906  while (!iter.pastEnd()) {
     907    Table t = iter.table();
     908    ArrayColumn<Float> speccol(t, "SPECTRA");
     909    Matrix<Float> pols = speccol.getColumn();
     910    Matrix<Float> out;
     911    try {
     912      stpol->setSpectra(pols);
     913      (stpol->*fptr)(phase);
     914      speccol.putColumn(stpol->getSpectra());
     915      delete stpol;stpol=0;
     916    } catch (AipsError& e) {
     917      delete stpol;stpol=0;
     918      throw(e);
     919    }
     920    ++iter;
     921  }
     922  return out;
     923}
     924
     925CountedPtr< Scantable >
     926  STMath::swapPolarisations( const CountedPtr< Scantable > & in )
     927{
     928  CountedPtr< Scantable > out = getScantable(in, false);
     929  Table& tout = out->table();
     930  Table t0 = tout(tout.col("POLNO") == 0);
     931  Table t1 = tout(tout.col("POLNO") == 1);
     932  if ( t0.nrow() != t1.nrow() )
     933    throw(AipsError("Inconsistent number of polarisations"));
     934  ArrayColumn<Float> speccol0(t0, "SPECTRA");
     935  ArrayColumn<uChar> flagcol0(t0, "FLAGTRA");
     936  ArrayColumn<Float> speccol1(t1, "SPECTRA");
     937  ArrayColumn<uChar> flagcol1(t1, "FLAGTRA");
     938  Matrix<Float> s0 = speccol0.getColumn();
     939  Matrix<uChar> f0 = flagcol0.getColumn();
     940  speccol0.putColumn(speccol1.getColumn());
     941  flagcol0.putColumn(flagcol1.getColumn());
     942  speccol1.putColumn(s0);
     943  flagcol1.putColumn(f0);
     944  return out;
     945}
Note: See TracChangeset for help on using the changeset viewer.