Changeset 417 for trunk


Ignore:
Timestamp:
02/14/05 12:33:44 (20 years ago)
Author:
kil064
Message:

handle the cross correlation

  • place in polarization axis as Real(xPol) and Imag(xPol)
  • make up Tsys and flags from parallel hands
Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDContainer.cc

    r414 r417  
    4040#include <casa/Arrays/VectorIter.h>
    4141#include <casa/Arrays/ArrayAccessor.h>
     42#include <casa/Arrays/ArrayMath.h>
    4243#include <casa/BasicMath/Math.h>
    4344#include <casa/Quanta/MVTime.h>
     
    131132
    132133Bool SDContainer::setSpectrum(const Matrix<Float>& spec,
     134                              const Vector<Complex>& cSpec,
     135                              uInt whichBeam, uInt whichIF)
     136//
     137// spec is [nChan,nPol]
     138// cspec is [nChan]
     139// spectrum_ is [,,,nChan]
     140//
     141// nPOl_ = 4  - xx, yy, real(xy), imag(xy)
     142//
     143{
     144  AlwaysAssert(nPol_==4,AipsError);
     145
     146// Get slice  and check dim
     147
     148  Bool tSys = False;
     149  Bool xPol = True;
     150  IPosition start, end;
     151  setSlice (start, end, spec.shape(), spectrum_.shape(),
     152            whichBeam, whichIF, tSys, xPol);
     153
     154// Get a reference to the Pol/Chan slice we are interested in
     155
     156  Array<Float> subArr = spectrum_(start,end);
     157
     158// Iterate through pol-chan plane and fill
     159
     160  ReadOnlyVectorIterator<Float> inIt(spec,0);
     161  VectorIterator<Float> outIt(subArr,asap::ChanAxis);
     162  while (!outIt.pastEnd()) {
     163     const IPosition& pos = outIt.pos();
     164     if (pos(asap::PolAxis)<2) {
     165        outIt.vector() = inIt.vector();
     166        inIt.next();
     167     } else if (pos(asap::PolAxis)==2) {
     168        outIt.vector() = real(cSpec);
     169     } else if (pos(asap::PolAxis)==3) {
     170        outIt.vector() = imag(cSpec);
     171     }
     172//
     173     outIt.next();
     174  }
     175
     176  // unset flags for this spectrum, they might be set again by the
     177  // setFlags method
     178
     179  Array<uChar> arr(flags_(start,end));
     180  arr = uChar(0);
     181//
     182  return True;
     183}
     184
     185
     186Bool SDContainer::setSpectrum(const Matrix<Float>& spec,
    133187                              uInt whichBeam, uInt whichIF)
    134188//
     
    136190// spectrum_ is [,,,nChan]
    137191// How annoying.
    138 //
     192// nPol==2
    139193{
    140194
     
    143197  IPosition start, end;
    144198  setSlice (start, end, spec.shape(), spectrum_.shape(),
    145             whichBeam, whichIF, False);
     199            whichBeam, whichIF, False, False);
    146200
    147201// Get a reference to the Pol/Chan slice we are interested in
     
    153207  ReadOnlyVectorIterator<Float> inIt(spec,0);
    154208  VectorIterator<Float> outIt(subArr,asap::ChanAxis);
    155   while (!inIt.pastEnd()) {
     209  while (!outIt.pastEnd()) {
    156210     outIt.vector() = inIt.vector();
    157211//
     
    170224
    171225
     226
     227
    172228Bool SDContainer::setFlags (const Matrix<uChar>& flags,
    173                             uInt whichBeam, uInt whichIF)
     229                            uInt whichBeam, uInt whichIF,
     230                            Bool hasXPol)
    174231//
    175232// flags is [nChan,nPol]
    176233// flags_ is [,,,nChan]
    177234// How annoying.
    178 //
    179 {
     235// there are no separate flags for XY so make
     236// them up from X and Y
     237//
     238{
     239  if (hasXPol) AlwaysAssert(nPol_==4,AipsError);
     240
    180241// Get slice and check dim
    181242
    182243  IPosition start, end;
    183244  setSlice (start, end, flags.shape(), flags_.shape(),
    184             whichBeam, whichIF, False);
     245            whichBeam, whichIF, False, hasXPol);
    185246
    186247// Get a reference to the Pol/Chan slice we are interested in
     
    188249  Array<uChar> subArr = flags_(start,end);
    189250
    190 // Iterate through it and fill
     251// Iterate through pol/chan plane and fill
    191252
    192253  ReadOnlyVectorIterator<uChar> inIt(flags,0);
    193254  VectorIterator<uChar> outIt(subArr,asap::ChanAxis);
    194   while (!inIt.pastEnd()) {
    195      outIt.vector() = inIt.vector();
    196 //
    197      inIt.next();
     255//
     256  Vector<uChar> maskPol0;
     257  Vector<uChar> maskPol1;
     258  Vector<uChar> maskPol01;
     259  while (!outIt.pastEnd()) {
     260     const IPosition& pos = outIt.pos();
     261     if (pos(asap::PolAxis)<2) {
     262        outIt.vector() = inIt.vector();
     263//
     264        if (hasXPol) {
     265           if (pos(asap::PolAxis)==0) {
     266              maskPol0 = inIt.vector();
     267           } else if (pos(asap::PolAxis)==1) {
     268              maskPol1 = inIt.vector();
     269//
     270              maskPol01.resize(maskPol0.nelements());
     271              for (uInt i=0; i<maskPol01.nelements(); i++) maskPol01[i] = maskPol0[i]&maskPol1[i];
     272           }
     273        }
     274//
     275        inIt.next();
     276     } else if (pos(asap::PolAxis)==2) {
     277        outIt.vector() = maskPol01;
     278     } else if (pos(asap::PolAxis)==3) {
     279        outIt.vector() = maskPol01;
     280     }
     281//
    198282     outIt.next();
    199283  }
     
    204288
    205289Bool SDContainer::setTsys(const Vector<Float>& tsys,
    206                           uInt whichBeam, uInt whichIF)
     290                          uInt whichBeam, uInt whichIF,
     291                          Bool hasXpol)
    207292//
    208293// Tsys does not depend upon channel but is replicated
    209 // for simplicity of use
     294// for simplicity of use.
     295// There is no Tsys measurement for the cross polarization
     296// so I have set TSys for XY to sqrt(Tx*Ty)
    210297//
    211298{
     
    215302  IPosition start, end;
    216303  setSlice (start, end, tsys.shape(), tsys_.shape(),
    217             whichBeam, whichIF, True);
     304            whichBeam, whichIF, True, hasXpol);
    218305
    219306// Get a reference to the Pol/Chan slice we are interested in
     
    226313  uInt i=0;
    227314  while (!outIt.pastEnd()) {
    228      outIt.vector() = tsys(i++);
     315     const IPosition& pos = outIt.pos();
     316//
     317     if (pos(asap::PolAxis)<2) {
     318       outIt.vector() = tsys(i++);
     319     } else {
     320       outIt.vector() = sqrt(tsys[0]*tsys[1]);
     321     }
     322//
    229323     outIt.next();
    230324  }
     
    401495void SDContainer::setSlice (IPosition& start, IPosition& end,
    402496                            const IPosition& shpIn, const IPosition& shpOut,
    403                             uInt whichBeam, uInt whichIF, Bool tSys) const
     497                            uInt whichBeam, uInt whichIF, Bool tSys,
     498                            Bool xPol) const
    404499//
    405500// tSYs
     
    408503//   shpIn [nCHan,nPol]
    409504//
     505// if xPol present, the output nPol = 4 but
     506// the input spectra are nPol=2 (tSys) or nPol=2 (spectra)
     507//
    410508{
    411509  AlwaysAssert(asap::nAxes==4,AipsError);
     510  uInt pOff = 0;
     511  if (xPol) pOff += 2;
    412512  if (tSys) {
    413      AlwaysAssert(shpOut(asap::PolAxis)==shpIn(0),AipsError);     // pol
     513     AlwaysAssert(shpOut(asap::PolAxis)==shpIn(0)+pOff,AipsError);     // pol
    414514  } else {
    415      AlwaysAssert(shpOut(asap::ChanAxis)==shpIn(0),AipsError);    // chan
    416      AlwaysAssert(shpOut(asap::PolAxis)==shpIn(1),AipsError);     // pol
     515     AlwaysAssert(shpOut(asap::ChanAxis)==shpIn(0),AipsError);       // chan
     516     AlwaysAssert(shpOut(asap::PolAxis)==shpIn(1)+pOff,AipsError);   // pol
    417517  }
    418518//
  • trunk/src/SDContainer.h

    r396 r417  
    123123  casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
    124124                   casa::uInt whichBeam, casa::uInt whichIF);
     125  casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
     126                         const casa::Vector<casa::Complex>& cSpec,
     127                         casa::uInt whichBeam, casa::uInt whichIF);
    125128  casa::Bool putSpectrum(const casa::Array<casa::Float>& spec);
    126129
    127130  casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs,
    128                       casa::uInt whichBeam, casa::uInt whichIF);
     131                      casa::uInt whichBeam, casa::uInt whichIF,
     132                      casa::Bool hasXPol=casa::False);
    129133  casa::Bool putFlags(const casa::Array<casa::uChar>& spec);
    130134
    131135  casa::Bool setTsys(const casa::Vector<casa::Float>& ts,
    132                casa::uInt whichBeam, casa::uInt whichIF);
     136               casa::uInt whichBeam, casa::uInt whichIF,
     137               casa::Bool hasXpol);
    133138  casa::Bool putTsys(const casa::Array<casa::Float>& spec);
    134139
     
    197202  void setSlice (casa::IPosition& start, casa::IPosition& end,
    198203                 const casa::IPosition& shpIn, const casa::IPosition& shpOut,
    199                  casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol) const;
     204                 casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol,
     205                 casa::Bool xPol) const;
    200206};
    201207
Note: See TracChangeset for help on using the changeset viewer.