Changeset 469 for trunk/src/SDPol2.cc
- Timestamp:
- 02/18/05 11:11:01 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDPol2.cc
r459 r469 54 54 // 55 55 // Designed for use 56 // Bool for mask56 // Bool or uChar for mask 57 57 // Float for TSys 58 // 59 // Input arrays should be of shape 60 // [nBeam,nIF,nPol,nChan] 58 61 // 59 62 { 60 63 T* t; 61 64 DataType type = whatType(t); 62 AlwaysAssert(type==TpFloat || type==TpBool , AipsError);65 AlwaysAssert(type==TpFloat || type==TpBool || type==TpUChar, AipsError); 63 66 // 64 67 IPosition shapeIn = rawData.shape(); 68 const uInt nDim = shapeIn.nelements(); 69 uInt polAxis = 0; 70 AlwaysAssert(nDim==asap::nAxes, AipsError); 71 // 65 72 uInt nPol = shapeIn(asap::PolAxis); 66 const uInt nDim = shapeIn.nelements();67 73 Array<T> stokesData; 68 74 // … … 135 141 } 136 142 143 144 145 template <class T> 146 Array<T> SDPolUtil::computeStokesDataForWriter (Array<T>& rawData, Bool doLinear) 147 // 148 // Generate data for each Stokes parameter from the 149 // raw flags. This is a lot of computational work and may 150 // not be worth the effort. This function is specifically 151 // for the SDWriter 152 // 153 // Designed for use 154 // Bool or uChar for mask 155 // Float for TSys 156 // 157 // Input arrays should be of shape 158 // [nChan,nPol] Bool/uChar 159 // [nPol] Float 160 // 161 { 162 T* t; 163 DataType type = whatType(t); 164 AlwaysAssert(type==TpFloat || type==TpBool || type==TpUChar, AipsError); 165 // 166 IPosition shapeIn = rawData.shape(); 167 const uInt nDim = shapeIn.nelements(); 168 uInt polAxis = 0; 169 if (type==TpFloat) { 170 AlwaysAssert(nDim==1,AipsError); 171 } else { 172 AlwaysAssert(nDim==2,AipsError); 173 polAxis = 1; 174 } 175 // 176 uInt nPol = shapeIn(polAxis); 177 Array<T> stokesData; 178 // 179 IPosition start(nDim,0); 180 IPosition end(shapeIn-1); 181 IPosition shapeOut = shapeIn; 182 // 183 if (doLinear) { 184 if (nPol==1) { 185 stokesData.resize(shapeOut); 186 stokesData = rawData; 187 } else if (nPol==2 || nPol==4) { 188 189 // Set shape of output array 190 191 if (nPol==2) { 192 shapeOut(polAxis) = 1; 193 } else { 194 shapeOut(polAxis) = 4; 195 } 196 stokesData.resize(shapeOut); 197 198 // Get reference slices and assign/compute 199 200 start(polAxis) = 0; 201 end(polAxis) = 0; 202 Array<T> M1In = rawData(start,end); 203 // 204 start(polAxis) = 1; 205 end(polAxis) = 1; 206 Array<T> M2In = rawData(start,end); 207 // 208 start(polAxis) = 0; 209 end(polAxis) = 0; 210 Array<T> M1Out = stokesData(start,end); 211 M1Out = SDPolUtil::andArrays (M1In, M2In); // I 212 // 213 if (nPol==4) { 214 start(polAxis) = 2; 215 end(polAxis) = 2; 216 Array<T> M3In = rawData(start,end); 217 // 218 start(polAxis) = 3; 219 end(polAxis) = 3; 220 Array<T> M4In = rawData(start,end); 221 // 222 start(polAxis) = 1; 223 end(polAxis) = 1; 224 Array<T> M2Out = stokesData(start,end); 225 M2Out = M1Out; // Q 226 // 227 start(polAxis) = 2; 228 end(polAxis) = 2; 229 Array<T> M3Out = stokesData(start,end); 230 M3Out = M3In; // U 231 // 232 start(polAxis) = 3; 233 end(polAxis) = 3; 234 Array<T> M4Out = stokesData(start,end); 235 M4Out = M4In; // V 236 } 237 } else { 238 throw(AipsError("Can only handle 1,2 or 4 polarizations")); 239 } 240 } else { 241 throw (AipsError("Only implemented for Linear polarizations")); 242 } 243 // 244 return stokesData; 245 } 246 247
Note: See TracChangeset
for help on using the changeset viewer.