Changeset 940 for trunk


Ignore:
Timestamp:
03/30/06 15:34:32 (19 years ago)
Author:
mar637
Message:

added averagePolarisations; added log output to frequencyAlign; removed couts; made frequencyAlign non insitu

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r934 r940  
    7777    String epoch = scantbls[0]->getTime(0);
    7878    for (int i=0; i< scantbls.size(); ++i ) {
     79
    7980      inaligned.push_back(frequencyAlign(scantbls[i], epoch));
    8081    }
     
    978979
    979980CountedPtr< Scantable >
     981  STMath::averagePolarisations( const CountedPtr< Scantable > & in,
     982                                const std::vector<bool>& mask,
     983                                const std::string& weight )
     984{
     985  if (in->getPolType() != "linear"  || in->npol() != 2 )
     986    throw(AipsError("averagePolarisations can only be applied to two linear polarisations."));
     987  CountedPtr<Scantable> pol0( new Scantable(*in), false);
     988  CountedPtr<Scantable> pol1( new Scantable(*in), false);
     989  Table& tpol0 = pol0->table();
     990  Table& tpol1 = pol1->table();
     991  Vector<uInt> pol0rows = tpol0(tpol0.col("POLNO") == 0).rowNumbers();
     992  Vector<uInt> pol1rows = tpol1(tpol1.col("POLNO") == 1).rowNumbers();
     993  tpol0.removeRow(pol1rows);
     994  tpol1.removeRow(pol0rows);
     995  // give both tables the same POLNO
     996  TableVector<uInt> vec(tpol1,"POLNO");
     997  vec = 0;
     998  std::vector<CountedPtr<Scantable> > pols;
     999  pols.push_back(pol0);
     1000  pols.push_back(pol1);
     1001  CountedPtr< Scantable > out = average(pols, mask, weight, "NONE", false);
     1002  out->table_.rwKeywordSet().define("nPol",Int(1));
     1003  return out;
     1004}
     1005
     1006
     1007CountedPtr< Scantable >
    9801008  asap::STMath::frequencyAlign( const CountedPtr< Scantable > & in,
    9811009                                const std::string & refTime,
    9821010                                const std::string & method)
    9831011{
     1012  // clone as this is not working insitu
     1013  bool insitu = insitu_;
     1014  setInsitu(false);
    9841015  CountedPtr< Scantable > out = getScantable(in, false);
     1016  setInsitu(insitu);
    9851017  Table& tout = out->table();
    9861018  // clear ouput frequency table
    987   Table ftable = out->frequencies().table();
    988   ftable.removeRow(ftable.rowNumbers());
     1019  //Table ftable = out->frequencies().table();
     1020  //ftable.removeRow(ftable.rowNumbers());
    9891021  // Get reference Epoch to time of first row or given String
    9901022  Unit DAY(String("d"));
     
    10031035  }
    10041036  MPosition refPos = in->getAntennaPosition();
    1005 /*  ostringstream oss;
    1006   oss << "Aligned at reference Epoch " << formatEpoch(refEpoch)
    1007       << " in frame " << MFrequency::showType(freqSystem);
    1008   pushLog(String(oss));
    1009 */
     1037
    10101038  InterpolateArray1D<Double,Float>::InterpolationMethod interp;
    10111039  Int interpMethod(stringToIMethod(method));
     
    10161044  }
    10171045  MFrequency::Types system = in->frequencies().getFrame();
    1018   out->frequencies().setFrame(system, true);
     1046  MVTime mvt(refEpoch.getValue());
     1047  String epochout = mvt.string(MVTime::YMD) + String(" (") + refEpoch.getRefString() + String(")");
     1048  ostringstream oss;
     1049  oss << "Aligned at reference Epoch " << epochout
     1050      << " in frame " << MFrequency::showType(system);
     1051  pushLog(String(oss));
    10191052  // set up the iterator
    10201053  Block<String> cols(4);
     
    10411074      ScalarColumn<uInt> freqidCol(ftab, "FREQ_ID");
    10421075      // get the SpectralCoordinate for the freqid, which we are iterating over
    1043       cout << freqidCol.getColumn() << endl;
    10441076      SpectralCoordinate sC = in->frequencies().getSpectralCoordinate(freqidCol(0));
    10451077      FrequencyAligner<Float> fa( sC, nchan, refEpoch,
     
    10861118                             interp, False);
    10871119          // back into scantable
    1088           cout << spec[spec.nelements()/2] << " --- " << specOut[specOut.nelements()/2] << endl;
    10891120          flagOut.resize(maskOut.nelements());
    10901121          convertArray(flagOut, maskOut);
     
    10971128        ++timeiter;
    10981129      }
    1099       // nect FREQ_ID
     1130      // next FREQ_ID
    11001131      ++fiter;
    11011132    }
     
    11031134    ++iter;
    11041135  }
    1105   return out;
    1106 }
     1136  // set this afterwards to ensure we are doing insitu correctly.
     1137  out->frequencies().setFrame(system, true);
     1138  return out;
     1139}
  • trunk/src/STMath.h

    r927 r940  
    5959             const std::string& avmode = "SCAN",
    6060             bool alignfreq = false );
     61  casa::CountedPtr< Scantable >
     62    averagePolarisations( const casa::CountedPtr< Scantable > & in,
     63                                const std::vector<bool>& mask,
     64                                const std::string& weight );
    6165
    6266  casa::CountedPtr<Scantable>
  • trunk/src/STMathWrapper.h

    r927 r940  
    4747    return ScantableWrapper(STMath::average(sts, mask, weight, avmode, alignfreq));
    4848  }
     49  ScantableWrapper
     50    averagePolarisations( const ScantableWrapper& in,
     51                          const std::vector<bool>& mask,
     52                          const std::string& weight)
     53  { return ScantableWrapper(STMath::averagePolarisations(in.getCP(),mask, weight));}
    4954
    5055  ScantableWrapper
  • trunk/src/python_STMath.cpp

    r927 r940  
    4545        .def("_setinsitu", &STMathWrapper::setInsitu)
    4646        .def("_average", &STMathWrapper::average)
     47        .def("_averagepol", &STMathWrapper::averagePolarisations)
    4748        .def("_unaryop", &STMathWrapper::unaryOperate)
    4849        .def("_quotient", &STMathWrapper::quotient)
Note: See TracChangeset for help on using the changeset viewer.