Changeset 440


Ignore:
Timestamp:
02/15/05 11:20:11 (19 years ago)
Author:
kil064
Message:

add function SDPolUtil::stokesMask
fix error in nPol check in SDStokesENgine

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDPol.cc

    r437 r440  
    3535#include <casa/Arrays/Array.h>
    3636#include <casa/Arrays/ArrayMath.h>
     37#include <casa/Arrays/ArrayLogical.h>
    3738#include <casa/Containers/Record.h>
    3839#include <casa/BasicSL/Constants.h>
     
    179180   const uInt polAxis = asap::PolAxis;
    180181   const uInt nPol = inputShape(polAxis);
    181    AlwaysAssert(nPol==1 || nPol==2 || nPol==3, AipsError);
     182   AlwaysAssert(nPol==1 || nPol==2 || nPol==4, AipsError);
    182183
    183184// The silly Array slice operator does not give me back
     
    322323}
    323324
     325Array<Bool> SDPolUtil::stokesMask (Array<Bool> rawFlags,
     326                                   Bool doLinear)
     327//
     328// Generate mask for each Stokes parameter from the
     329// raw flags.  This is a lot of computational work and may
     330// not be worth the effort.
     331//
     332{
     333   IPosition shapeIn = rawFlags.shape();
     334   uInt nPol = shapeIn(asap::PolAxis);
     335   const uInt nDim = shapeIn.nelements();
     336   Array<Bool> stokesFlags;
     337//
     338   IPosition start(nDim,0);
     339   IPosition end(shapeIn-1);
     340   IPosition shapeOut = shapeIn;
     341//
     342   if (doLinear) {
     343      if (nPol==1) {
     344         stokesFlags.resize(shapeOut);
     345         stokesFlags = rawFlags;
     346      } else if (nPol==2 || nPol==4) {
     347
     348// Set shape of output array
     349
     350         if (nPol==2) {
     351            shapeOut(asap::PolAxis) = 1;
     352         } else {
     353            shapeOut(asap::PolAxis) = 4;
     354         }
     355         stokesFlags.resize(shapeOut);
     356
     357// Get reference slices and assign/compute
     358
     359         start(asap::PolAxis) = 0;
     360         end(asap::PolAxis) = 0;
     361         Array<Bool> M1In = rawFlags(start,end);
     362//
     363         start(asap::PolAxis) = 1;
     364         end(asap::PolAxis) = 1;
     365         Array<Bool> M2In = rawFlags(start,end);
     366//
     367         start(asap::PolAxis) = 0;
     368         end(asap::PolAxis) = 0;
     369         Array<Bool> M1Out = stokesFlags(start,end);
     370         M1Out = M1In && M2In;                             // I
     371//
     372         if (nPol==4) {   
     373            start(asap::PolAxis) = 2;
     374            end(asap::PolAxis) = 2;
     375            Array<Bool> M3In = rawFlags(start,end);
     376//
     377            start(asap::PolAxis) = 3;
     378            end(asap::PolAxis) = 3;
     379            Array<Bool> M4In = rawFlags(start,end);
     380//
     381            start(asap::PolAxis) = 1;
     382            end(asap::PolAxis) = 1;
     383            Array<Bool> M2Out = stokesFlags(start,end);
     384            M2Out = M1Out;                                  // Q
     385//
     386            start(asap::PolAxis) = 2;
     387            end(asap::PolAxis) = 2;
     388            Array<Bool> M3Out = stokesFlags(start,end);
     389            M3Out = M3In;                                   // U
     390//
     391            start(asap::PolAxis) = 3;
     392            end(asap::PolAxis) = 3;
     393            Array<Bool> M4Out = stokesFlags(start,end);
     394            M4Out = M4In;                                   // V
     395         }
     396      } else {
     397         throw(AipsError("Can only handle 1,2 or 4 polarizations"));
     398      }
     399   } else {
     400      throw (AipsError("Only implemented for Linear polarizations"));
     401   }
     402//
     403   return stokesFlags;
     404}
  • trunk/src/SDPol.h

    r438 r440  
    6363// Compute Circular polarization RR or LL from I and V
    6464  static casa::Array<casa::Float> circularPolarizationFromStokes (casa::Array<casa::Float>& I,
    65                                                                   casa::Array<casa::Float>& V,
     65                                                                  casa::Array<casa::Float>& V,  
    6666                                                                  casa::Bool doRR);
     67
     68// Compute Mask for STokes parameters from raw correlation masks
     69// Gets output shape right (e.g. XX,YY -> I)
     70  static casa::Array<casa::Bool> stokesMask (casa::Array<casa::Bool> rawFlags,
     71                                             casa::Bool doLinear);
     72
    6773};
    6874
Note: See TracChangeset for help on using the changeset viewer.