Changeset 1575 for trunk


Ignore:
Timestamp:
06/29/09 13:32:17 (15 years ago)
Author:
Malte Marquarding
Message:

Ticket #168; align data to convert frequency frame before export

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STWriter.cpp

    r1477 r1575  
    5151#include "STAsciiWriter.h"
    5252#include "STHeader.h"
     53#include "STMath.h"
     54
    5355
    5456#include "STWriter.h"
     
    104106                    const std::string &filename)
    105107{
     108  // If we write out foreign formats we have to convert the frequency system
     109  // into the output frame, as we do everything related to SPectarlCoordinates
     110  // in asap on-the-fly.
     111
     112  CountedPtr<Scantable> inst = in;
     113  if (in->frequencies().getFrame(true) != in->frequencies().getFrame(false)) {
     114    STMath stm(false);
     115    inst = stm.frequencyAlign(in);
     116  }
    106117
    107118  if (format_=="ASCII") {
    108119    STAsciiWriter iw;
     120    // ASCII calls SpectralCoordinate::toWorld so no freqAlign use 'in'
    109121    if (iw.write(*in, filename)) {
    110122      return 0;
     
    117129      iw.setClass(True);
    118130    }
    119     if (iw.write(*in, filename)) {
     131    if (iw.write(*inst, filename)) {
    120132      return 0;
    121133    }
     
    127139  // this is a little different from what I have done
    128140  // before. Need to check with the Offline User Test data
    129   STHeader hdr = in->getHeader();
     141  STHeader hdr = inst->getHeader();
    130142  //const Int nPol  = hdr.npol;
    131143  //const Int nChan = hdr.nchan;
    132   std::vector<uint> ifs = in->getIFNos();
    133   int nIF = in->nif();//ifs.size();
     144  std::vector<uint> ifs = inst->getIFNos();
     145  int nIF = inst->nif();//ifs.size();
    134146  Vector<uInt> nPol(nIF),nChan(nIF);
    135147  Vector<Bool> havexpol(nIF);
     
    138150  nPol = 0;nChan = 0; havexpol = False;
    139151  for (uint i=0;i<ifs.size();++i) {
    140     nPol(ifs[i]) = in->npol();
    141     nChan(ifs[i]) = in->nchan(ifs[i]);
     152    nPol(ifs[i]) = inst->npol();
     153    nChan(ifs[i]) = inst->nchan(ifs[i]);
    142154    havexpol(ifs[i]) = nPol(ifs[i]) > 2;
    143155  }
    144156
    145   const Table table = in->table();
     157  const Table table = inst->table();
    146158
    147159  // Create the output file and write static data.
     
    155167    throw(AipsError("Failed to create output file"));
    156168  }
    157 
    158169
    159170  Int count = 0;
     
    201212          Float tmp0,tmp1,tmp2,tmp3,tmp4;
    202213          String stmp0,stmp1;
    203           in->frequencies().getEntry(crpix,crval, pksrec.freqInc,
     214          inst->frequencies().getEntry(crpix,crval, pksrec.freqInc,
    204215                                     rec.asuInt("FREQ_ID"));
    205           in->focus().getEntry(pksrec.focusAxi, pksrec.focusTan,
     216          inst->focus().getEntry(pksrec.focusAxi, pksrec.focusTan,
    206217                               pksrec.focusRot, tmp0,tmp1,tmp2,tmp3,tmp4,
    207218                               rec.asuInt("FOCUS_ID"));
    208           in->molecules().getEntry(pksrec.restFreq,stmp0,stmp1,
     219          inst->molecules().getEntry(pksrec.restFreq,stmp0,stmp1,
    209220                                   rec.asuInt("MOLECULE_ID"));
    210           in->tcal().getEntry(pksrec.tcalTime, pksrec.tcal,
     221          inst->tcal().getEntry(pksrec.tcalTime, pksrec.tcal,
    211222                              rec.asuInt("TCAL_ID"));
    212           in->weather().getEntry(pksrec.temperature, pksrec.pressure,
     223          inst->weather().getEntry(pksrec.temperature, pksrec.pressure,
    213224                                 pksrec.humidity, pksrec.windSpeed,
    214225                                 pksrec.windAz, rec.asuInt("WEATHER_ID"));
Note: See TracChangeset for help on using the changeset viewer.