Changeset 324 for trunk/src


Ignore:
Timestamp:
01/30/05 18:01:46 (20 years ago)
Author:
kil064
Message:

the majority of the frequency information for each row was not being
written out. make some effort to

1) implement this
2) get it right - not really sure about some of the assumption of the

underlying writer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDWriter.cc

    r199 r324  
    3939#include <atnf/PKSIO/PKSMS2writer.h>
    4040#include <atnf/PKSIO/PKSSDwriter.h>
     41
     42#include <tables/Tables/ArrayColumn.h>
     43
    4144
    4245#include "SDContainer.h"
     
    107110// finished.
    108111
    109 Int SDWriter::write(const CountedPtr<SDMemTable> table,
     112Int SDWriter::write(const CountedPtr<SDMemTable> in,
    110113                    const std::string &filename)
    111114{
     
    116119     Bool verbose = True;
    117120     SDFITSImageWriter iw;
    118      if (iw.write(*table, filename, verbose)) {
     121     if (iw.write(*in, filename, verbose)) {
    119122        return 0;
    120123     } else {
     
    123126  } else if (cFormat=="ASCII") {
    124127     SDAsciiWriter iw;
    125      if (iw.write(*table, filename)) {
     128     if (iw.write(*in, filename)) {
    126129        return 0;
    127130     } else {
     
    133136
    134137  // Extract the header from the table.
    135   SDHeader hdr = table->getSDHeader();
    136   Int nPol  = hdr.npol;
    137   Int nChan = hdr.nchan;
     138  SDHeader hdr = in->getSDHeader();
     139  const Int nPol  = hdr.npol;
     140  const Int nChan = hdr.nchan;
     141
     142// Get Freq table
     143
     144  SDFrequencyTable sdft = in->getSDFreqTable();
     145  Vector<Double> restFreqs;
     146  String restFreqUnit;
     147  sdft.restFrequencies(restFreqs, restFreqUnit);
     148  Double restFreq = 0.0;
     149  if (restFreqs.nelements()>0) {
     150     Quantum<Double> rF(restFreqs(0), Unit(restFreqUnit));
     151     restFreq = rF.getValue(Unit("Hz"));
     152  }
     153
     154// Table columns
     155
     156  const Table table = in->table();
     157  ROArrayColumn<uInt> freqIDCol(table, "FREQID");
     158  Vector<uInt> freqIDs;
    138159
    139160  // Create the output file and write static data.
     
    152173
    153174  Int count = 0;
    154   for (Int iRow = 0; iRow < table->nRow(); iRow++) {
     175  for (Int iRow = 0; iRow < in->nRow(); iRow++) {
    155176    // Extract the next integration from the table.
    156     SDContainer sd = table->getSDContainer(iRow);
     177    SDContainer sd = in->getSDContainer(iRow);
    157178    if (sd.scanid != scanNo) {
    158179      scanNo = sd.scanid;
     
    163184    }
    164185
     186    // Get FreqID vector
     187    freqIDCol.get(iRow, freqIDs);
     188
    165189    // Write it out beam by beam.
    166190    for (Int iBeam = 0; iBeam < hdr.nbeam; iBeam++) {
     
    168192      // Write it out IF by IF.
    169193      for (Int iIF = 0; iIF < hdr.nif; iIF++) {
     194        uInt freqID = freqIDs(iIF);
     195
    170196        // None of these are stored in SDMemTable by SDReader.
    171197        //String          fieldName = "";
     
    173199        Vector<Double>  srcPM(2, 0.0);
    174200        Double          srcVel = 0.0;
    175         Double          freqInc = 0.0;
    176         Double          restFreq = 0.0;
     201
     202// The writer will assume refPix = nChan/2 + 1.  So recompute
     203// the frequency at this location.
     204
     205        Double          cdelt = sdft.increment(freqID);
     206        Double          crval = sdft.referenceValue(freqID);
     207        Double          crpix = sdft.referencePixel(freqID);
     208        Double          pixel = nChan/2 + 1;
     209        Double          refFreqNew = (pixel-crpix)*cdelt + crval;
     210//
    177211        //Vector<Float>   tcal(2, 0.0f);
    178212        //String          tcalTime = "";
     
    197231        Complex         xCalFctr;
    198232        Vector<Complex> xPol;
     233//
    199234        if (status = cWriter->write(sd.scanid, cycleNo, sd.timestamp,
    200235                                    sd.interval, sd.fieldname, sd.sourcename,
    201236                                    sd.getDirection(iBeam),
    202                                     srcPM, srcVel, iIF+1, hdr.reffreq,
    203                                     hdr.bandwidth, freqInc, restFreq, sd.tcal,
     237                                    srcPM, srcVel, iIF+1, refFreqNew,
     238                                    nChan*abs(cdelt), cdelt, restFreq, sd.tcal,
    204239                                    sd.tcaltime, sd.azimuth, sd.elevation,
    205240                                    sd.parangle,
Note: See TracChangeset for help on using the changeset viewer.