Changeset 992 for trunk/src


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

added function to convert between polarisation types

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r985 r992  
    11281128  return out;
    11291129}
     1130
     1131CountedPtr<Scantable>
     1132  asap::STMath::convertPolarisation( const CountedPtr<Scantable>& in,
     1133                                     const std::string & newtype )
     1134{
     1135  if (in->npol() != 2 && in->npol() != 4)
     1136    throw(AipsError("Can only convert two or four polarisations."));
     1137  if ( in->getPolType() == newtype )
     1138    throw(AipsError("No need to convert."));
     1139  bool insitu = insitu_;
     1140  setInsitu(false);
     1141  CountedPtr< Scantable > out = getScantable(in, true);
     1142  setInsitu(insitu);
     1143  Table& tout = out->table();
     1144  tout.rwKeywordSet().define("POLTYPE", String(newtype));
     1145
     1146  Block<String> cols(4);
     1147  cols[0] = "SCANNO";
     1148  cols[1] = "CYCLENO";
     1149  cols[2] = "BEAMNO";
     1150  cols[3] = "IFNO";
     1151  TableIterator it(in->originalTable_, cols);
     1152  String basetype = in->getPolType();
     1153  STPol* stpol = STPol::getPolClass(in->factories_, basetype);
     1154  try {
     1155    while ( !it.pastEnd() ) {
     1156      Table tab = it.table();
     1157      uInt row = tab.rowNumbers()[0];
     1158      stpol->setSpectra(in->getPolMatrix(row));
     1159      Float fang,fhand,parang;
     1160      fang = in->focusTable_.getTotalFeedAngle(in->mfocusidCol_(row));
     1161      fhand = in->focusTable_.getFeedHand(in->mfocusidCol_(row));
     1162      parang = in->paraCol_(row);
     1163      /// @todo re-enable this
     1164      // disable total feed angle to support paralactifying Caswell style
     1165      stpol->setPhaseCorrections(parang, -parang, fhand);
     1166      Int npolout = 0;
     1167      for (uInt i=0; i<tab.nrow(); ++i) {
     1168        Vector<Float> outvec = stpol->getSpectrum(i, newtype);
     1169        if ( outvec.nelements() > 0 ) {
     1170          tout.addRow();
     1171          TableCopy::copyRows(tout, tab, tout.nrow()-1, 0, 1);
     1172          ArrayColumn<Float> sCol(tout,"SPECTRA");
     1173          ScalarColumn<uInt> pCol(tout,"POLNO");
     1174          sCol.put(tout.nrow()-1 ,outvec);
     1175          pCol.put(tout.nrow()-1 ,uInt(npolout));
     1176          npolout++;
     1177       }
     1178      }
     1179      tout.rwKeywordSet().define("nPol", npolout);
     1180      ++it;
     1181    }
     1182  } catch (AipsError& e) {
     1183    delete stpol;
     1184    throw(e);
     1185  }
     1186  delete stpol;
     1187  return out;
     1188}
  • trunk/src/STMath.h

    r977 r992  
    122122                    const std::string& method = "cubic" );
    123123
     124  casa::CountedPtr<Scantable>
     125    convertPolarisation( const casa::CountedPtr<Scantable>& in,
     126                         const std::string& newtype);
     127
    124128private:
    125129  casa::CountedPtr<Scantable>  applyToPol( const casa::CountedPtr<Scantable>& in,
  • trunk/src/STMathWrapper.h

    r978 r992  
    126126  { return ScantableWrapper(STMath::frequencyAlign(in.getCP())); }
    127127
     128  ScantableWrapper convertPolarisation( const ScantableWrapper& in,
     129                                        const std::string& newtype )
     130  { return ScantableWrapper(STMath::convertPolarisation(in.getCP(),newtype)); }
     131
    128132};
    129133
Note: See TracChangeset for help on using the changeset viewer.