Changeset 272 for trunk/src/SDMath.cc


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

add reference time arg. to function 'VelocityAlignment?'

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.