Changeset 309


Ignore:
Timestamp:
01/27/05 21:49:56 (19 years ago)
Author:
kil064
Message:

remove 'velocityALignment' functions for new 'frequencyAlignment' ones

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r304 r309  
    5555#include <coordinates/Coordinates/CoordinateSystem.h>
    5656#include <coordinates/Coordinates/CoordinateUtil.h>
    57 #include <coordinates/Coordinates/VelocityAligner.h>
     57#include <coordinates/Coordinates/FrequencyAligner.h>
    5858
    5959#include <lattices/Lattices/LatticeUtilities.h>
     
    108108
    109109
    110 SDMemTable* SDMath::velocityAlignment (const SDMemTable& in, const String& refTime) const
    111 {
    112 
    113 // Get velocity/frame info from Table
     110SDMemTable* SDMath::frequencyAlignment (const SDMemTable& in, const String& refTime) const
     111{
     112
     113// Get frame info from Table
    114114
    115115   std::vector<std::string> info = in.getCoordInfo();
    116116
    117 // Parse unit ("" means channels)
    118 
    119    String velUnit(info[0]);
    120    if (velUnit.length()==0) {
    121       throw(AipsError("You have not set a velocity abcissa unit - use function set_unit"));
    122    } else {
    123       Unit velUnitU(velUnit);
    124       if (velUnitU!=Unit(String("m/s"))) {
    125          throw(AipsError("Specified abcissa unit is not consistent with km/s - use function set_unit"));
    126       }
     117// Parse frequency system
     118
     119   String systemStr(info[1]);
     120   String baseSystemStr(info[3]);
     121   if (baseSystemStr==systemStr) {
     122      throw(AipsError("You have not set a frequency frame different from the initial - use function set_freqframe"));
    127123   }
    128 
    129 // Parse doppler
    130 
    131    String dopplerStr(info[2]);
    132    String velSystemStr(info[1]);
    133    String velBaseSystemStr(info[3]);
    134    if (velBaseSystemStr==velSystemStr) {
    135       throw(AipsError("You have not set a velocity frame different from the initial - use function set_freqframe"));
    136    }
    137 
    138 // Parse frequency system
    139 
    140    MFrequency::Types velSystem;
    141    MFrequency::getType(velSystem, velSystemStr);
    142    MDoppler::Types doppler;
    143    MDoppler::getType(doppler, dopplerStr);
     124//
     125   MFrequency::Types freqSystem;
     126   MFrequency::getType(freqSystem, systemStr);
    144127
    145128// Do it
    146129
    147    return velocityAlign (in, velSystem, velUnit, doppler, refTime);
     130   return frequencyAlign (in, freqSystem, refTime);
    148131}
    149132
     
    152135CountedPtr<SDMemTable> SDMath::average(const Block<CountedPtr<SDMemTable> >& in,
    153136                                       const Vector<Bool>& mask, Bool scanAv,
    154                                        const String& weightStr, Bool alignVelocity) const
     137                                       const String& weightStr, Bool alignFreq) const
    155138//
    156139// Weighted averaging of spectra from one or more Tables.
     
    256239  for (uInt iTab=0; iTab<nTables; iTab++) {
    257240
    258 // Should check that the frequency tables don't change if doing VelocityAlignment
     241// Should check that the frequency tables don't change if doing FreqAlignment
    259242
    260243// Attach columns to Table
     
    646629{
    647630   Bool doVel = False;
     631   if (doVel) {
     632      for (uInt j=0; j<in.nCoordinates(); ++j) {
     633         SpectralCoordinate sC = in.getSpectralCoordinate(j);
     634      }
     635   }
     636
    648637
    649638// Interpolation method
     
    12571246// 'private' functions
    12581247
    1259 SDMemTable* SDMath::velocityAlign (const SDMemTable& in,
    1260                                    MFrequency::Types velSystem,
    1261                                    const String& velUnit,
    1262                                    MDoppler::Types doppler,
     1248
     1249SDMemTable* SDMath::frequencyAlign (const SDMemTable& in,
     1250                                   MFrequency::Types freqSystem,
    12631251                                   const String& refTime) const
    12641252{
     
    13011289      refEpoch = in.getEpoch(0);
    13021290   }
    1303    cerr << "Aligning at reference Epoch " << formatEpoch(refEpoch) << endl;
     1291   cerr << "Aligning at reference Epoch " << formatEpoch(refEpoch) <<
     1292           " in frame " << MFrequency::showType(freqSystem) << endl;
    13041293
    13051294// Get Reference Position
     
    13121301   const uInt nFreqIDs = fTab.length();
    13131302
    1314 // Create VelocityAligner Block. One VA for each possible
     1303// Create FrequencyAligner Block. One VA for each possible
    13151304// source/freqID combination
    13161305
    1317    PtrBlock<VelocityAligner<Float>* > vA(nFreqIDs*nSrcTab);
    1318    generateVelocityAligners (vA, in, nChan, nFreqIDs, nSrcTab, firstRow,
    1319                              velSystem, velUnit, doppler, refPos, refEpoch);
     1306   PtrBlock<FrequencyAligner<Float>* > a(nFreqIDs*nSrcTab);
     1307   generateFrequencyAligners (a, in, nChan, nFreqIDs, nSrcTab, firstRow,
     1308                              freqSystem, refPos, refEpoch);
    13201309
    13211310// New output Table
     
    13261315
    13271316   const IPosition polChanAxes(2, asap::PolAxis, asap::ChanAxis);
    1328    VelocityAligner<Float>::Method method = VelocityAligner<Float>::LINEAR;
     1317   FrequencyAligner<Float>::Method method = FrequencyAligner<Float>::LINEAR;
    13291318   Bool extrapolate=False;
    13301319   Bool useCachedAbcissa = False;
     
    13331322   Vector<Float> yOut;
    13341323   Vector<Bool> maskOut;
    1335    uInt ifIdx, vaIdx;
     1324   uInt ifIdx, faIdx;
    13361325//
    13371326   for (uInt iRow=0; iRow<nRows; ++iRow) {
     
    13581347// cerr << "values in = " << values(IPosition(4,0,0,0,0),IPosition(4,0,0,0,9)) << endl;
    13591348
    1360 // For each row, the Velocity abcissa will be the same regardless
     1349// For each row, the Frequency abcissa will be the same regardless
    13611350// of polarization.  For all other axes (IF and BEAM) the abcissa
    13621351// will change.  So we iterate through the data by pol-chan planes
     
    13701359     while (!itValuesPlane.pastEnd()) {
    13711360
    1372 // Find the IF index and then the VA PtrBlock index
     1361// Find the IF index and then the FA PtrBlock index
    13731362
    13741363        const IPosition& pos = itValuesPlane.pos();
    13751364        ifIdx = pos(asap::IFAxis);
    1376         vaIdx = (srcIdx[iRow]*nFreqIDs) + freqID[ifIdx];
     1365        faIdx = (srcIdx[iRow]*nFreqIDs) + freqID[ifIdx];
    13771366//
    13781367        VectorIterator<Float> itValuesVec(itValuesPlane.array(), 1);
     
    13821371        useCachedAbcissa=False;
    13831372        while (!itValuesVec.pastEnd()) {     
    1384            ok = vA[vaIdx]->align (yOut, maskOut, itValuesVec.vector(),
     1373           ok = a[faIdx]->align (yOut, maskOut, itValuesVec.vector(),
    13851374                                  itMaskVec.vector(), epoch, useCachedAbcissa,
    13861375                                  method, extrapolate);
     
    14111400   }
    14121401
     1402
     1403// Write out correct frequency table information for output.
     1404// CLone from input and overwrite
     1405
     1406   SDFrequencyTable freqTab = in.getSDFreqTable();
     1407   freqTab.setLength(0);
     1408
     1409// Note that we don't have anyway to hold frequency table information
     1410// in the SDMemTable which is source dependent.  Each FrequencyAligner
     1411// is generated for an freqID/Source combination.  Don't know what to
     1412// do about this apart from to pick the aligned SC from the first source
     1413// at the moment.  ASAP really needs to handle data description id
     1414// like in aips++ which is a combination of source and freqid. Otherwise
     1415// all else I can do in this function is disallow multiple sources
     1416
     1417   Bool linear=True;
     1418   Vector<String> units(1);
     1419   units = String("Hz");
     1420   for (uInt fqID=0; fqID<nFreqIDs; fqID++) {
     1421      for (uInt iSrc=0; iSrc<nSrcTab; iSrc++) {
     1422         uInt idx = (iSrc*nFreqIDs) + fqID;
     1423
     1424// Get Aligned SC in Hz
     1425
     1426         if (iSrc==0) {
     1427            SpectralCoordinate sC = a[idx]->alignedSpectralCoordinate(linear);
     1428            sC.setWorldAxisUnits(units);
     1429
     1430// Write out frequency table information to SDMemTable
     1431
     1432            Int idx = freqTab.addFrequency(sC.referencePixel()[0],
     1433                                           sC.referenceValue()[0],
     1434                                           sC.increment()[0]);
     1435         }
     1436      }
     1437   }
     1438   pTabOut->putSDFreqTable(freqTab);
     1439
     1440// Now we must set the base and extra frames to the
     1441// input frame
     1442
     1443   std::vector<string> info = pTabOut->getCoordInfo();
     1444   info[1] = MFrequency::showType(freqSystem);   // Conversion frame
     1445   info[3] = info[1];                            // Base frame
     1446   pTabOut->setCoordInfo(info);
     1447
    14131448// Clean up PointerBlock
    14141449
    1415   for (uInt i=0; i<vA.nelements(); i++) delete vA[i];
    1416 //
    1417   pTabOut->resetCursor();
    1418   return pTabOut;
     1450   for (uInt i=0; i<a.nelements(); i++) delete a[i];
     1451//
     1452   return pTabOut;
    14191453}
    14201454
     
    17801814
    17811815
    1782 void SDMath::generateVelocityAligners (PtrBlock<VelocityAligner<Float>* >& vA,
     1816
     1817void SDMath::generateFrequencyAligners (PtrBlock<FrequencyAligner<Float>* >& a,
    17831818                                       const SDMemTable& in, uInt nChan,
    17841819                                       uInt nFreqIDs, uInt nSrcTab,
    17851820                                       const Vector<uInt>& firstRow,
    1786                                        MFrequency::Types velSystem,
    1787                                        const String& velUnit,
    1788                                        MDoppler::Types doppler,
     1821                                       MFrequency::Types system,
    17891822                                       const MPosition& refPos,
    17901823                                       const MEpoch& refEpoch) const
     
    17951828         MDirection refDir = in.getDirection(firstRow[iSrc]);
    17961829         uInt idx = (iSrc*nFreqIDs) + fqID;
    1797          vA[idx] = new VelocityAligner<Float>(sC, nChan, refEpoch, refDir, refPos,
    1798                                               velUnit, doppler, velSystem);
     1830         a[idx] = new FrequencyAligner<Float>(sC, nChan, refEpoch, refDir, refPos, system);
    17991831      }
    18001832   }
    18011833}
    18021834
     1835
  • trunk/src/SDMath.h

    r299 r309  
    3636#include <casa/aips.h>
    3737#include <casa/Utilities/CountedPtr.h>
    38 #include <coordinates/Coordinates/VelocityAligner.h>
     38#include <coordinates/Coordinates/FrequencyAligner.h>
    3939
    4040#include "SDDefs.h"
     
    4444class casa::MPosition;
    4545template<class T> class casa::PtrBlock;
    46 //template<class T> class casa::VelocityAligner;
    4746
    4847
     
    7877                                         casa::Bool scanAverage,
    7978                                         const casa::String& weightStr,
    80                                          casa::Bool alignVelocity=casa::False) const;
     79                                         casa::Bool align=casa::False) const;
    8180
    8281// Statistics. If row<0, all rows are done otherwise, just the
     
    106105                              const casa::String& method, casa::Bool doAll) const;
    107106
    108 // Velocity Alignment
    109    SDMemTable* velocityAlignment (const SDMemTable& in, const casa::String& refTime) const;
     107// Frequency Alignment
     108   SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime) const;
    110109
    111110// Opacity correction
     
    194193                             const casa::Vector<casa::String>& srcNames) const;
    195194
    196 // Generate velocity aligners
    197    void generateVelocityAligners (casa::PtrBlock<casa::VelocityAligner<casa::Float>* >& vA,
    198                                   const SDMemTable& in, casa::uInt nChan,
    199                                   casa::uInt nFreqIDs, casa::uInt nSrcTab,
    200                                   const casa::Vector<casa::uInt>& firstRow,
    201                                   casa::MFrequency::Types velSystem,
    202                                   const casa::String& velUnit,
    203                                   casa::MDoppler::Types doppler,
    204                                   const casa::MPosition& refPos,
    205                                   const casa::MEpoch& refEpoch) const;
    206 
    207 // Align in Velocity
    208    SDMemTable* velocityAlign (const SDMemTable& in,
    209                               casa::MFrequency::Types velSystem,
    210                               const casa::String& velUnit,
    211                               casa::MDoppler::Types doppler,
     195// Generate frequency aligners
     196   void generateFrequencyAligners (casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a,
     197                                   const SDMemTable& in, casa::uInt nChan,
     198                                   casa::uInt nFreqIDs, casa::uInt nSrcTab,
     199                                   const casa::Vector<casa::uInt>& firstRow,
     200                                   casa::MFrequency::Types system,
     201                                   const casa::MPosition& refPos,
     202                                   const casa::MEpoch& refEpoch) const;
     203
     204// Align in Frequency
     205   SDMemTable* frequencyAlign (const SDMemTable& in,
     206                              casa::MFrequency::Types system,
    212207                              const casa::String& timeRef) const;
    213208
Note: See TracChangeset for help on using the changeset viewer.