source: trunk/src/SDPol2.cc@ 463

Last change on this file since 463 was 459, checked in by kil064, 20 years ago

make templatyed function SDPolUtil::stokesData to handle stokesMask
and stokesTsys calculation. Delete the non-templated versions.

In SDStokesEngone track interface changes in Table system (some bug fixes for me)

Mo

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDPol2.cc: Templated polarimetric functionality
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31
32#include "SDPol.h"
33#include "SDDefs.h"
34
35#include <casa/Arrays/Array.h>
36#include <casa/Arrays/ArrayMath.h>
37#include <casa/Arrays/ArrayLogical.h>
38#include <casa/BasicSL/String.h>
39#include <casa/Utilities/Assert.h>
40#include <casa/Utilities/DataType.h>
41#include <casa/Utilities/Assert.h>
42
43
44using namespace casa;
45using namespace asap;
46
47
48template <class T>
49Array<T> SDPolUtil::stokesData (Array<T>& rawData, Bool doLinear)
50//
51// Generate data for each Stokes parameter from the
52// raw flags. This is a lot of computational work and may
53// not be worth the effort.
54//
55// Designed for use
56// Bool for mask
57// Float for TSys
58//
59{
60 T* t;
61 DataType type = whatType(t);
62 AlwaysAssert(type==TpFloat || type==TpBool, AipsError);
63//
64 IPosition shapeIn = rawData.shape();
65 uInt nPol = shapeIn(asap::PolAxis);
66 const uInt nDim = shapeIn.nelements();
67 Array<T> stokesData;
68//
69 IPosition start(nDim,0);
70 IPosition end(shapeIn-1);
71 IPosition shapeOut = shapeIn;
72//
73 if (doLinear) {
74 if (nPol==1) {
75 stokesData.resize(shapeOut);
76 stokesData = rawData;
77 } else if (nPol==2 || nPol==4) {
78
79// Set shape of output array
80
81 if (nPol==2) {
82 shapeOut(asap::PolAxis) = 1;
83 } else {
84 shapeOut(asap::PolAxis) = 4;
85 }
86 stokesData.resize(shapeOut);
87
88// Get reference slices and assign/compute
89
90 start(asap::PolAxis) = 0;
91 end(asap::PolAxis) = 0;
92 Array<T> M1In = rawData(start,end);
93//
94 start(asap::PolAxis) = 1;
95 end(asap::PolAxis) = 1;
96 Array<T> M2In = rawData(start,end);
97//
98 start(asap::PolAxis) = 0;
99 end(asap::PolAxis) = 0;
100 Array<T> M1Out = stokesData(start,end);
101 M1Out = SDPolUtil::andArrays (M1In, M2In); // I
102//
103 if (nPol==4) {
104 start(asap::PolAxis) = 2;
105 end(asap::PolAxis) = 2;
106 Array<T> M3In = rawData(start,end);
107//
108 start(asap::PolAxis) = 3;
109 end(asap::PolAxis) = 3;
110 Array<T> M4In = rawData(start,end);
111//
112 start(asap::PolAxis) = 1;
113 end(asap::PolAxis) = 1;
114 Array<T> M2Out = stokesData(start,end);
115 M2Out = M1Out; // Q
116//
117 start(asap::PolAxis) = 2;
118 end(asap::PolAxis) = 2;
119 Array<T> M3Out = stokesData(start,end);
120 M3Out = M3In; // U
121//
122 start(asap::PolAxis) = 3;
123 end(asap::PolAxis) = 3;
124 Array<T> M4Out = stokesData(start,end);
125 M4Out = M4In; // V
126 }
127 } else {
128 throw(AipsError("Can only handle 1,2 or 4 polarizations"));
129 }
130 } else {
131 throw (AipsError("Only implemented for Linear polarizations"));
132 }
133//
134 return stokesData;
135}
136
Note: See TracBrowser for help on using the repository browser.