- Timestamp:
- 07/29/09 19:00:30 (15 years ago)
- Location:
- branches/alma/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/src/STMath.cpp
r1607 r1609 133 133 uInt outrowCount = 0; 134 134 TableIterator iter(baset, cols); 135 int count = 0 ;135 // int count = 0 ; 136 136 while (!iter.pastEnd()) { 137 137 Table subt = iter.table(); … … 1192 1192 Table& tabout2=out2->table(); 1193 1193 ROScalarColumn<uInt> freqidCol1(tabout1, "FREQ_ID"); 1194 ROScalarColumn<uInt> freqidCol2(tabout2, "FREQ_ID");1194 ScalarColumn<uInt> freqidCol2(tabout2, "FREQ_ID"); 1195 1195 ROArrayColumn<Float> specCol(tabout2, "SPECTRA"); 1196 1196 Vector<Float> spec; specCol.get(0, spec); … … 1201 1201 out1->frequencies().getEntry(rp1, rv1, inc1, freqid1); 1202 1202 out2->frequencies().getEntry(rp2, rv2, inc2, freqid2); 1203 //cerr << out1->frequencies().table().nrow() << " " << out2->frequencies().table().nrow() << endl ; 1203 1204 if (rp1==rp2) { 1204 1205 Double foffset = rv1 - rv2; … … 1209 1210 } 1210 1211 } 1211 1212 1212 1213 if (nofold) { 1213 1214 std::vector< CountedPtr< Scantable > > tabs; … … 1217 1218 } 1218 1219 else { //folding is not implemented yet 1219 out = out1; 1220 //out = out1; 1221 Int choffset = static_cast<Int>((rv1-rv2)/inc2) ; 1222 out = dofold( out1, out2, choffset ) ; 1220 1223 } 1221 1224 1222 1225 return out; 1223 1226 } 1227 1228 CountedPtr<Scantable> STMath::dofold( const CountedPtr<Scantable> &sig, 1229 const CountedPtr<Scantable> &ref, 1230 Int choffset ) 1231 { 1232 // output scantable 1233 CountedPtr<Scantable> out = getScantable( sig, false ) ; 1234 1235 // get column 1236 ROArrayColumn<Float> specCol1( sig->table(), "SPECTRA" ) ; 1237 ROArrayColumn<Float> specCol2( ref->table(), "SPECTRA" ) ; 1238 ROArrayColumn<Float> tsysCol1( sig->table(), "TSYS" ) ; 1239 ROArrayColumn<Float> tsysCol2( ref->table(), "TSYS" ) ; 1240 ROArrayColumn<uChar> flagCol1( sig->table(), "FLAGTRA" ) ; 1241 ROArrayColumn<uChar> flagCol2( ref->table(), "FLAGTRA" ) ; 1242 ROScalarColumn<Double> mjdCol1( sig->table(), "TIME" ) ; 1243 ROScalarColumn<Double> mjdCol2( ref->table(), "TIME" ) ; 1244 ROScalarColumn<Double> intervalCol1( sig->table(), "INTERVAL" ) ; 1245 ROScalarColumn<Double> intervalCol2( ref->table(), "INTERVAL" ) ; 1246 1247 // check 1248 if ( choffset == 0 ) { 1249 cerr << "channel offset is zero, no folding" << endl ; 1250 return out ; 1251 } 1252 int nchan = ref->nchan() ; 1253 if ( abs(choffset) >= nchan ) { 1254 cerr << "out-band frequency switching, no folding" << endl ; 1255 return out ; 1256 } 1257 1258 // attach column for output scantable 1259 ArrayColumn<Float> specColOut( out->table(), "SPECTRA" ) ; 1260 ArrayColumn<uChar> flagColOut( out->table(), "FLAGTRA" ) ; 1261 ArrayColumn<Float> tsysColOut( out->table(), "TSYS" ) ; 1262 ScalarColumn<Double> mjdColOut( out->table(), "TIME" ) ; 1263 ScalarColumn<Double> intervalColOut( out->table(), "INTERVAL" ) ; 1264 1265 // for each row 1266 // assume that the data order are same between sig and ref 1267 RowAccumulator acc( asap::TINTSYS ) ; 1268 for ( int i = 0 ; i < sig->nrow() ; i++ ) { 1269 // get values 1270 Vector<Float> spsig ; 1271 specCol1.get( i, spsig ) ; 1272 Vector<Float> spref ; 1273 specCol2.get( i, spref ) ; 1274 Vector<Float> tsyssig ; 1275 tsysCol1.get( i, tsyssig ) ; 1276 Vector<Float> tsysref ; 1277 tsysCol2.get( i, tsysref ) ; 1278 Vector<uChar> flagsig ; 1279 flagCol1.get( i, flagsig ) ; 1280 Vector<uChar> flagref ; 1281 flagCol2.get( i, flagref ) ; 1282 Double timesig ; 1283 mjdCol1.get( i, timesig ) ; 1284 Double timeref ; 1285 mjdCol2.get( i, timeref ) ; 1286 Double intsig ; 1287 intervalCol1.get( i, intsig ) ; 1288 Double intref ; 1289 intervalCol2.get( i, intref ) ; 1290 1291 // shift reference spectra 1292 int refchan = spref.nelements() ; 1293 if ( choffset > 0 ) { 1294 for ( int j = 0 ; j < refchan-choffset ; j++ ) { 1295 spref[j] = spref[j+choffset] ; 1296 tsysref[j] = tsysref[j+choffset] ; 1297 flagref[j] = flagref[j+choffset] ; 1298 } 1299 for ( int j = refchan-choffset ; j < refchan ; j++ ) { 1300 spref[j] = spref[j-refchan+choffset] ; 1301 tsysref[j] = tsysref[j-refchan+choffset] ; 1302 flagref[j] = flagref[j-refchan+choffset] ; 1303 } 1304 } 1305 else { 1306 for ( int j = 0 ; j < abs(choffset) ; j++ ) { 1307 spref[j] = spref[refchan+choffset+j] ; 1308 tsysref[j] = tsysref[refchan+choffset+j] ; 1309 flagref[j] = flagref[refchan+choffset+j] ; 1310 } 1311 for ( int j = abs(choffset) ; j < refchan ; j++ ) { 1312 spref[j] = spref[j+choffset] ; 1313 tsysref[j] = tsysref[j+choffset] ; 1314 flagref[j] = flagref[j+choffset] ; 1315 } 1316 } 1317 1318 // folding 1319 acc.add( spsig, !flagsig, tsyssig, intsig, timesig ) ; 1320 acc.add( spref, !flagref, tsysref, intref, timeref ) ; 1321 1322 // put result 1323 specColOut.put( i, acc.getSpectrum() ) ; 1324 const Vector<Bool> &msk = acc.getMask() ; 1325 Vector<uChar> flg( msk.shape() ) ; 1326 convertArray( flg, !msk ) ; 1327 flagColOut.put( i, flg ) ; 1328 tsysColOut.put( i, acc.getTsys() ) ; 1329 intervalColOut.put( i, acc.getInterval() ) ; 1330 mjdColOut.put( i, acc.getTime() ) ; 1331 1332 acc.reset() ; 1333 } 1334 1335 return out ; 1336 } 1337 1224 1338 1225 1339 CountedPtr< Scantable > STMath::freqSwitch( const CountedPtr< Scantable >& in ) -
branches/alma/src/STMath.h
r1607 r1609 199 199 casa::Float tcal=0.0 ); 200 200 201 /** 202 * Folding frequency-switch data 203 * @param sig 204 * @param ref 205 * @param choffset 206 **/ 207 casa::CountedPtr<Scantable> dofold( const casa::CountedPtr<Scantable> &sig, 208 const casa::CountedPtr<Scantable> &ref, 209 casa::Int choffset ); 201 210 202 211 casa::CountedPtr<Scantable>
Note:
See TracChangeset
for help on using the changeset viewer.