Changeset 2590 for branches/hpc34/external-alma/atnf/PKSIO
- Timestamp:
- 07/09/12 14:41:03 (12 years ago)
- Location:
- branches/hpc34/external-alma/atnf/PKSIO
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc34/external-alma/atnf/PKSIO/NRODataset.cc
r2434 r2590 388 388 389 389 // char -> int 390 vector<int> ispec( chmax_, 0 ) ; 390 int *ispec = new int[chmax_] ; 391 int *int_p = ispec ; 391 392 392 393 static const int shift_right[] = { … … 403 404 int ivalue = 0 ; 404 405 if ( bit == 12 ) { // 12 bit qunatization 405 const int idx = j + start_pos[i & 1]; 406 const int ialt = i & 1 ; 407 const int idx = j + start_pos[ialt]; 406 408 const unsigned tmp = unsigned(cdata[idx]) << 8 | cdata[idx + 1]; 407 ivalue = int((tmp >> shift_right[i & 1]) & 0xFFF); 408 j += incr[i & 1]; 409 } 410 411 ispec[i] = ivalue ; 412 if ( ( ispec[i] < 0 ) || ( ispec[i] > 4096 ) ) { 409 ivalue = int((tmp >> shift_right[ialt]) & 0xFFF); 410 j += incr[ialt]; 411 } 412 413 if ( ( ivalue < 0 ) || ( ivalue > 4096 ) ) { 413 414 //cerr << "NRODataset::getSpectrum() ispec[" << i << "] is out of range" << endl ; 414 415 os << LogIO::SEVERE << "ispec[" << i << "] is out of range" << LogIO::EXCEPTION ; 416 delete ispec ; 415 417 return bspec ; 416 418 } … … 418 420 //cout << "NRODataset::getSpectrum() ispec[" << i << "] = " << ispec[i] << endl ; 419 421 // 422 *int_p = ivalue ; 423 int_p++ ; 420 424 } 421 425 422 426 double *const spec = new double[ chmax_ ] ; // spectrum "before" binding 423 427 // int -> double 428 int_p = ispec ; 429 double *double_p = spec ; 424 430 for ( int i = 0 ; i < chmax_ ; i++ ) { 425 spec[i] = (double)( ispec[i]* scale + offset ) * dscale ;431 *double_p = (double)( (*int_p) * scale + offset ) * dscale ; 426 432 // DEBUG 427 433 //cout << "NRODataset::getSpectrum() spec[" << i << "] = " << spec[i] << endl ; 428 434 // 429 } 435 int_p++ ; 436 double_p++ ; 437 } 438 delete ispec ; 430 439 431 440 // channel binding 432 441 if ( cbind != 1 ) { 433 int k = chmin ; 434 double sum0 = 0 ; 435 double sum1 = 0 ; 436 for ( int i = 0 ; i < nchan ; i++ ) { 437 for ( int j = k ; j < k + cbind ; j++ ) { 438 sum0 += spec[k] ; 439 sum1++ ; 442 double_p = &(spec[chmin]) ; 443 for ( vector<double>::iterator i = bspec.begin() ; 444 i != bspec.end() ; i++ ) { 445 double sum0 = 0 ; 446 double sum1 = 0 ; 447 for ( int j = 0 ; j < cbind ; j++ ) { 448 sum0 += *double_p ; 449 sum1 += 1.0 ; 450 double_p++ ; 440 451 } 441 bspec[i]= sum0 / sum1 ;442 k += cbind;452 *i = sum0 / sum1 ; 453 i++ ; 443 454 // DEBUG 444 455 //cout << "NRODataset::getSpectrum() bspec[" << i << "] = " << bspec[i] << endl ; … … 447 458 } 448 459 else { 449 for ( int i = 0 ; i < nchan ; i++ ) 450 bspec[i] = spec[i] ; 460 double_p = spec ; 461 for ( vector<double>::iterator i = bspec.begin() ; 462 i != bspec.end() ; i++ ) { 463 *i = *double_p ; 464 double_p++ ; 465 } 451 466 } 452 467 delete[] spec; -
branches/hpc34/external-alma/atnf/PKSIO/NROReader.cc
r2588 r2590 613 613 spectra.resize( spec.size() ) ; 614 614 int index = 0 ; 615 for ( Vector<Float>::iterator itr = spectra.begin() ; itr != spectra.end() ; itr++ ) { 616 *itr = spec[index++] ; 617 } 615 Bool b ; 616 Float *fp = spectra.getStorage( b ) ; 617 Float *wp = fp ; 618 for ( vector<double>::iterator i = spec.begin() ; 619 i != spec.end() ; i++ ) { 620 *wp = *i ; 621 wp++ ; 622 } 623 spectra.putStorage( fp, b ) ; 618 624 //cout << "spec.size() = " << spec.size() << endl ; 619 625 620 626 // flagtra 621 627 bool setValue = !( flagtra.nelements() == spectra.nelements() ) ; 622 flagtra.resize( spectra.nelements() ) ;623 628 if ( setValue ) { 624 629 //cout << "flagtra resized. reset values..." << endl ; 630 flagtra.resize( spectra.nelements() ) ; 625 631 flagtra.set( 0 ) ; 626 632 }
Note:
See TracChangeset
for help on using the changeset viewer.