Changeset 2289 for trunk/external-alma/atnf/PKSIO
- Timestamp:
- 09/08/11 19:35:40 (13 years ago)
- Location:
- trunk/external-alma
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma
- Property svn:mergeinfo changed
/branches/parallel/external-alma (added) merged: 2240,2247,2262-2264,2266
- Property svn:mergeinfo changed
-
trunk/external-alma/atnf/PKSIO/NRODataset.cc
r2212 r2289 71 71 dataid_ = -1 ; 72 72 73 // OS endian 74 int i = 1 ; 75 endian_ = -1 ; 76 if ( *reinterpret_cast<char *>(&i) == 1 ) { 77 endian_ = LITTLE_ENDIAN ; 78 os << LogIO::NORMAL << "LITTLE_ENDIAN " << LogIO::POST ; 79 } 80 else { 81 endian_ = BIG_ENDIAN ; 82 os << LogIO::NORMAL << "BIG_ENDIAN " << LogIO::POST ; 83 } 73 // endian matches 84 74 same_ = -1 ; 85 75 … … 353 343 vector< vector<double> > NRODataset::getSpectrum() 354 344 { 355 vector< vector<double> > spec ;345 vector< vector<double> > spec(rowNum_); 356 346 357 347 for ( int i = 0 ; i < rowNum_ ; i++ ) { 358 spec .push_back( getSpectrum( i )) ;348 spec[i] = getSpectrum( i ) ; 359 349 } 360 350 … … 370 360 // 371 361 // size of spectrum is not chmax_ but dataset_->getNCH() after binding 372 int nchan = NUMCH ; 373 vector<double> spec( chmax_, 0.0 ) ; // spectrum "before" binding 362 const int nchan = NUMCH ; 374 363 vector<double> bspec( nchan, 0.0 ) ; // spectrum "after" binding 375 364 // DEBUG … … 379 368 NRODataRecord *record = getRecord( i ) ; 380 369 381 int bit = IBIT ; // fixed to 12 bit370 const int bit = IBIT ; // fixed to 12 bit 382 371 double scale = record->SFCTR ; 383 372 // DEBUG … … 392 381 return bspec ; 393 382 } 394 char *cdata =record->LDATA ;383 unsigned char *cdata = (unsigned char *)record->LDATA ; 395 384 vector<double> mscale = MLTSCF ; 396 385 double dscale = mscale[getIndex( i )] ; … … 400 389 // char -> int 401 390 vector<int> ispec( chmax_, 0 ) ; 402 union SharedMemory { 403 int ivalue ; 404 unsigned char cbuf[4] ; 405 } ; 406 SharedMemory u ; 391 392 static const int shift_right[] = { 393 4, 0 394 }; 395 static const int start_pos[] = { 396 0, 1 397 }; 398 static const int incr[] = { 399 0, 3 400 }; 407 401 int j = 0 ; 408 char ctmp = 0x00 ;409 int sw = 0 ;410 402 for ( int i = 0 ; i < chmax_ ; i++ ) { 403 int ivalue = 0 ; 411 404 if ( bit == 12 ) { // 12 bit qunatization 412 u.ivalue = 0 ; 413 414 if ( endian_ == BIG_ENDIAN ) { 415 // big endian 416 if ( sw == 0 ) { 417 char c0 = (cdata[j] >> 4) & 0x0f ; 418 char c1 = ((cdata[j] << 4) & 0xf0) | ((cdata[j+1] >> 4) & 0x0f) ; 419 ctmp = cdata[j+1] & 0x0f ; 420 u.cbuf[2] = c0 ; 421 u.cbuf[3] = c1 ; 422 j += 2 ; 423 sw = 1 ; 424 } 425 else if ( sw == 1 ) { 426 u.cbuf[2] = ctmp ; 427 u.cbuf[3] = cdata[j] ; 428 j++ ; 429 sw = 0 ; 430 } 431 } 432 else if ( endian_ == LITTLE_ENDIAN ) { 433 // little endian 434 if ( sw == 0 ) { 435 char c0 = (cdata[j] >> 4) & 0x0f ; 436 char c1 = ((cdata[j] << 4) & 0xf0) | ((cdata[j+1] >> 4) & 0x0f) ; 437 ctmp = cdata[j+1] & 0x0f ; 438 u.cbuf[1] = c0 ; 439 u.cbuf[0] = c1 ; 440 j += 2 ; 441 sw = 1 ; 442 } 443 else if ( sw == 1 ) { 444 u.cbuf[1] = ctmp ; 445 u.cbuf[0] = cdata[j] ; 446 j++ ; 447 sw = 0 ; 448 } 449 } 450 } 451 452 ispec[i] = u.ivalue ; 405 const int idx = j + start_pos[i & 1]; 406 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 ; 453 412 if ( ( ispec[i] < 0 ) || ( ispec[i] > 4096 ) ) { 454 413 //cerr << "NRODataset::getSpectrum() ispec[" << i << "] is out of range" << endl ; … … 461 420 } 462 421 422 double *const spec = new double[ chmax_ ] ; // spectrum "before" binding 463 423 // int -> double 464 424 for ( int i = 0 ; i < chmax_ ; i++ ) { … … 490 450 bspec[i] = spec[i] ; 491 451 } 452 delete[] spec; 492 453 493 454 // DEBUG -
trunk/external-alma/atnf/PKSIO/NRODataset.h
r2198 r2289 506 506 507 507 // OS endian 508 int endian_ ;509 508 int same_ ; 510 509 -
trunk/external-alma/atnf/PKSIO/NROReader.cc
r2261 r2289 531 531 String &srcname, 532 532 String &fieldname, 533 Array<Float> &spectra,534 Array<uChar> &flagtra,535 Array<Float> &tsys,536 Array<Double> &direction,533 Vector<Float> &spectra, 534 Vector<uChar> &flagtra, 535 Vector<Float> &tsys, 536 Vector<Double> &direction, 537 537 Float &azimuth, 538 538 Float &elevation, … … 548 548 Float &winddir, 549 549 Double &srcvel, 550 Array<Double> &propermotion,550 Vector<Double> &propermotion, 551 551 Vector<Double> &srcdir, 552 Array<Double> &scanrate ) 553 { 552 Vector<Double> &scanrate ) 553 { 554 static const IPosition oneByOne( 1, 1 ); 555 554 556 // DEBUG 555 557 //cout << "NROReader::getScanInfo() irow = " << irow << endl ; … … 589 591 590 592 // restfreq (for MOLECULE_ID) 591 Vector<Double> rf( IPosition( 1, 1 ) ) ; 592 rf( 0 ) = record->FREQ0 ; 593 restfreq = rf ; 593 restfreq.resize( oneByOne ) ; 594 restfreq[0] = record->FREQ0 ; 594 595 //cout << "restfreq = " << rf << endl ; 595 596 … … 617 618 // spectra 618 619 vector<double> spec = dataset_->getSpectrum( irow ) ; 619 Array<Float> sp( IPosition( 1, spec.size()) ) ;620 spectra.resize( spec.size() ) ; 620 621 int index = 0 ; 621 for ( Array<Float>::iterator itr = sp.begin() ; itr != sp.end() ; itr++ ) {622 for ( Vector<Float>::iterator itr = spectra.begin() ; itr != spectra.end() ; itr++ ) { 622 623 *itr = spec[index++] ; 623 624 } 624 spectra = sp ;625 625 //cout << "spec.size() = " << spec.size() << endl ; 626 626 627 627 // flagtra 628 Array<uChar> flag( spectra.shape() ) ; 629 flag.set( 0 ) ; 630 flagtra = flag ; 628 flagtra.resize( spectra.nelements() ) ; 629 flagtra.set( 0 ) ; 631 630 //cout << "flag.size() = " << flag.size() << endl ; 632 631 633 632 // tsys 634 Array<Float> tmp( IPosition( 1, 1 ), record->TSYS) ;635 tsys = tmp;633 tsys.resize( oneByOne ) ; 634 tsys[0] = record->TSYS ; 636 635 //cout << "tsys[0] = " << tsys[0] << endl ; 637 636 … … 693 692 694 693 // propermotion 695 Array<Double> srcarr( IPosition( 1, 2 ) ) ; 696 srcarr = 0.0 ; 697 propermotion = srcarr ; 698 //cout << "propermotion = [" << propermotion[0] << ", " << propermotion[1] << "]" << endl ; 694 // do nothing 699 695 700 696 // srcdir … … 703 699 704 700 // scanrate 705 Array<Double> sr( IPosition( 1, 1 ) ) ; 706 sr = 0.0 ; 707 scanrate = sr ; 708 //cout << "scanrate = " << scanrate[0] << endl ; 701 // do nothing 709 702 710 703 return 0 ; -
trunk/external-alma/atnf/PKSIO/NROReader.h
r2201 r2289 139 139 String &srcname, 140 140 String &fieldname, 141 Array<Float> &spectra,142 Array<uChar> &flagtra,143 Array<Float> &tsys,144 Array<Double> &direction,141 Vector<Float> &spectra, 142 Vector<uChar> &flagtra, 143 Vector<Float> &tsys, 144 Vector<Double> &direction, 145 145 Float &azimuth, 146 146 Float &elevation, … … 156 156 Float &winddir, 157 157 Double &srcvel, 158 Array<Double> &propermotion,158 Vector<Double> &propermotion, 159 159 Vector<Double> &srcdir, 160 Array<Double> &scanrate ) ;160 Vector<Double> &scanrate ) ; 161 161 162 162 // Get scan type
Note:
See TracChangeset
for help on using the changeset viewer.