Changeset 272


Ignore:
Timestamp:
01/24/05 01:00:14 (19 years ago)
Author:
kil064
Message:

add reference time arg. to function 'VelocityAlignment?'

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r270 r272  
    4949#include <casa/Quanta/MVEpoch.h>
    5050#include <casa/Quanta/QC.h>
     51#include <casa/Quanta/MVTime.h>
    5152#include <casa/Utilities/Assert.h>
    5253
     
    107108
    108109
    109 SDMemTable* SDMath::velocityAlignment (const SDMemTable& in) const
     110SDMemTable* SDMath::velocityAlignment (const SDMemTable& in, const String& refTime) const
    110111{
    111112
     
    139140// Do it
    140141
    141    return velocityAlign (in, velSystem, velUnit, doppler);
     142   return velocityAlign (in, velSystem, velUnit, doppler, refTime);
    142143}
    143144
     
    11031104                                   MFrequency::Types velSystem,
    11041105                                   const String& velUnit,
    1105                                    MDoppler::Types doppler) const
     1106                                   MDoppler::Types doppler,
     1107                                   const String& refTime) const
    11061108{
    11071109// Get Header
     
    11321134   const uInt nSrcTab = srcTab.nelements();
    11331135   cerr << "Found " << srcTab.nelements() << " sources to align " << endl;
    1134 /*
    1135    cerr << "source table = " << srcTab << endl;
    1136    cerr << "source idx = " << srcIdx << endl;
    1137    cerr << "first row = " << firstRow << endl;
    1138 */
    1139 
    1140 // Set reference Epoch to time of first row
    1141 
    1142    MEpoch::Ref timeRef = MEpoch::Ref(in.getTimeReference());
     1136
     1137// Set reference Epoch to time of first row or given String
     1138
    11431139   Unit DAY(String("d"));
    1144    Quantum<Double> tQ(times[0], DAY);
    1145    MVEpoch mve(tQ);
    1146    MEpoch refTime(mve, timeRef);
     1140   MEpoch::Ref epochRef(in.getTimeReference());
     1141   MEpoch refEpoch;
     1142   if (refTime.length()>0) {
     1143      refEpoch = epochFromString(refTime, in.getTimeReference());
     1144   } else {
     1145      Quantum<Double> tQ(times[0], DAY);
     1146      MVEpoch mve(tQ);
     1147      refEpoch = MEpoch(mve, epochRef);
     1148   }
     1149   cerr << "Aligning at reference Epoch " << formatEpoch(refEpoch) << endl;
    11471150
    11481151// Set Reference Position
     
    11661169         MDirection refDir = in.getDirection(firstRow[iSrc]);
    11671170         uInt idx = (iSrc*nFreqIDs) + fqID;
    1168          vA[idx] = new VelocityAligner<Float>(sC, nChan, refTime, refDir, refPos,
     1171         vA[idx] = new VelocityAligner<Float>(sC, nChan, refEpoch, refDir, refPos,
    11691172                                              velUnit, doppler, velSystem);
    11701173      }
     
    11961199    Quantum<Double> tQ2(times[iRow],DAY);
    11971200    MVEpoch mv2(tQ2);
    1198     MEpoch epoch(mv2, timeRef);
     1201    MEpoch epoch(mv2, epochRef);
    11991202
    12001203// Get FreqID vector.  One freqID per IF
     
    16101613   }
    16111614}
     1615
     1616MEpoch SDMath::epochFromString (const String& str, MEpoch::Types timeRef) const
     1617{
     1618   Quantum<Double> qt;
     1619   if (MVTime::read(qt,str)) {
     1620      MVEpoch mv(qt);
     1621      MEpoch me(mv, timeRef);
     1622      return me;
     1623   } else {
     1624      throw(AipsError("Invalid format for Epoch string"));
     1625   }
     1626}
     1627
     1628
     1629String SDMath::formatEpoch(const MEpoch& epoch)  const
     1630{
     1631   MVTime mvt(epoch.getValue());
     1632   return mvt.string(MVTime::YMD) + String(" (") + epoch.getRefString() + String(")");
     1633}
     1634
  • trunk/src/SDMath.h

    r267 r272  
    3939
    4040class casa::Table;
     41class casa::MEpoch;
     42
    4143
    4244namespace asap {
     
    9597
    9698// Velocity Alignment
    97    SDMemTable* velocityAlignment (const SDMemTable& in) const;
     99   SDMemTable* velocityAlignment (const SDMemTable& in, const casa::String& refTime) const;
    98100
    99101// Opacity correction
     
    186188                              casa::MFrequency::Types velSystem,
    187189                              const casa::String& velUnit,
    188                               casa::MDoppler::Types doppler) const;
     190                              casa::MDoppler::Types doppler,
     191                              const casa::String& timeRef) const;
     192
     193// Convert time String to Epoch
     194   casa::MEpoch epochFromString (const casa::String& str, casa::MEpoch::Types timeRef) const;
     195
     196// Format EPoch
     197   casa::String formatEpoch(const casa::MEpoch& epoch)  const;
    189198};
    190199
  • trunk/src/SDMathWrapper.cc

    r268 r272  
    228228}
    229229
    230 void SDMathWrapper::velocityAlignmentInSitu (SDMemTableWrapper& in)
    231 {
    232   SDMemTable* pIn = in.getPtr();
    233   SDMath sdm;
    234   SDMemTable* pOut = sdm.velocityAlignment(*pIn);
    235   *pIn = *pOut;
    236   delete pOut;
    237 }
    238 
    239 
    240 SDMemTableWrapper SDMathWrapper::velocityAlignment (const SDMemTableWrapper& in)
    241 {
    242   const CountedPtr<SDMemTable>& pIn = in.getCP();
    243   SDMath sdm;
    244   return CountedPtr<SDMemTable>(sdm.velocityAlignment(*pIn));
     230void SDMathWrapper::velocityAlignmentInSitu (SDMemTableWrapper& in, const std::string& refTime)
     231{
     232  SDMemTable* pIn = in.getPtr();
     233  SDMath sdm;
     234  SDMemTable* pOut = sdm.velocityAlignment(*pIn, String(refTime));
     235  *pIn = *pOut;
     236  delete pOut;
     237}
     238
     239
     240SDMemTableWrapper SDMathWrapper::velocityAlignment (const SDMemTableWrapper& in,
     241                                                    const std::string& refTime)
     242{
     243  const CountedPtr<SDMemTable>& pIn = in.getCP();
     244  SDMath sdm;
     245  return CountedPtr<SDMemTable>(sdm.velocityAlignment(*pIn, String(refTime)));
    245246}
    246247
  • trunk/src/SDMathWrapper.h

    r268 r272  
    8585
    8686// Apply velocity alignment
    87   void velocityAlignmentInSitu (SDMemTableWrapper& in);
    88   SDMemTableWrapper velocityAlignment(const SDMemTableWrapper& in);
     87  void velocityAlignmentInSitu (SDMemTableWrapper& in, const std::string& refTime);
     88  SDMemTableWrapper velocityAlignment(const SDMemTableWrapper& in, const std::string& refTime);
    8989
    9090// Apply opacity correction
Note: See TracChangeset for help on using the changeset viewer.