Changeset 1779 for branches/mergetest/src/STFiller.cpp
- Timestamp:
- 07/29/10 19:13:46 (14 years ago)
- Location:
- branches/mergetest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mergetest
- Property svn:mergeinfo changed
-
branches/mergetest/src/STFiller.cpp
r1777 r1779 25 25 #include <tables/Tables/TableRow.h> 26 26 27 #include <measures/Measures/MDirection.h> 28 #include <measures/Measures/MeasConvert.h> 29 27 30 #include <atnf/PKSIO/PKSrecord.h> 28 31 #include <atnf/PKSIO/PKSreader.h> … … 30 33 #include <casa/System/ProgressMeter.h> 31 34 #endif 35 #include <casa/System/ProgressMeter.h> 36 #include <atnf/PKSIO/NROReader.h> 37 #include <casa/Logging/LogIO.h> 38 39 #include <time.h> 40 32 41 33 42 #include "STDefs.h" … … 45 54 header_(0), 46 55 table_(0), 47 refRx_(".*(e|w|_R)$") 56 refRx_(".*(e|w|_R)$"), 57 nreader_(0) 48 58 { 49 59 } … … 53 63 header_(0), 54 64 table_(stbl), 55 refRx_(".*(e|w|_R)$") 65 refRx_(".*(e|w|_R)$"), 66 nreader_(0) 56 67 { 57 68 } … … 61 72 header_(0), 62 73 table_(0), 63 refRx_(".*(e|w|_R)$") 74 refRx_(".*(e|w|_R)$"), 75 nreader_(0) 64 76 { 65 open(filename, whichIF, whichBeam);77 open(filename, "", whichIF, whichBeam); 66 78 } 67 79 … … 70 82 close(); 71 83 } 72 73 void STFiller::open( const std::string& filename, int whichIF, int whichBeam)84 85 void STFiller::open( const std::string& filename, const std::string& antenna, int whichIF, int whichBeam, casa::Bool getPt ) 74 86 { 75 87 if (table_.null()) { … … 93 105 Vector<Bool> beams, ifs; 94 106 Vector<uInt> nchans,npols; 95 if ( (reader_ = getPKSreader(inName, 0, 0, format, beams, ifs, 107 108 // 109 // if isNRO_ is true, try NROReader 110 // 111 // 2008/11/11 Takeshi Nakazato 112 isNRO_ = fileCheck() ; 113 if ( isNRO_ ) { 114 if ( (nreader_ = getNROReader( inName, format )) == 0 ) { 115 throw(AipsError("Creation of NROReader failed")) ; 116 } 117 else { 118 openNRO( whichIF, whichBeam ) ; 119 return ; 120 } 121 } 122 // 123 124 if ( (reader_ = getPKSreader(inName, antenna, 0, 0, format, beams, ifs, 96 125 nchans, npols, haveXPol_,haveBase, haveSpectra 97 126 )) == 0 ) { … … 197 226 Vector<Int> start(nIF_, 1); 198 227 Vector<Int> end(nIF_, 0); 199 reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0] );228 reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0], False, getPt); 200 229 table_->setHeader(*header_); 201 230 //For MS, add the location of POINTING of the input MS so one get 202 231 //pointing data from there, if necessary. 203 //Also find nrow in MS 232 //Also find nrow in MS 204 233 nInDataRow = 0; 205 234 if (format == "MS2") { 206 Path datapath(inName); 235 Path datapath(inName); 207 236 String ptTabPath = datapath.absoluteName(); 208 237 Table inMS(ptTabPath); … … 216 245 } 217 246 } 247 String freqFrame = header_->freqref; 248 //translate frequency reference frame back to 249 //MS style (as PKSMS2reader converts the original frame 250 //in FITS standard style) 251 if (freqFrame == "TOPOCENT") { 252 freqFrame = "TOPO"; 253 } else if (freqFrame == "GEOCENER") { 254 freqFrame = "GEO"; 255 } else if (freqFrame == "BARYCENT") { 256 freqFrame = "BARY"; 257 } else if (freqFrame == "GALACTOC") { 258 freqFrame = "GALACTO"; 259 } else if (freqFrame == "LOCALGRP") { 260 freqFrame = "LGROUP"; 261 } else if (freqFrame == "CMBDIPOL") { 262 freqFrame = "CMB"; 263 } else if (freqFrame == "SOURCE") { 264 freqFrame = "REST"; 265 } 266 // set both "FRAME" and "BASEFRAME" 267 table_->frequencies().setFrame(freqFrame, false); 268 table_->frequencies().setFrame(freqFrame,true); 218 269 //table_->focus().setParallactify(true); 219 270 } … … 222 273 { 223 274 delete reader_;reader_=0; 275 delete nreader_;nreader_=0; 224 276 delete header_;header_=0; 225 277 table_ = 0; … … 229 281 { 230 282 int status = 0; 283 284 // 285 // for NRO data 286 // 287 // 2008/11/12 Takeshi Nakazato 288 if ( isNRO_ ) { 289 status = readNRO() ; 290 return status ; 291 } 292 // 293 294 /** 295 Int beamNo, IFno, refBeam, scanNo, cycleNo; 296 Float azimuth, elevation, focusAxi, focusRot, focusTan, 297 humidity, parAngle, pressure, temperature, windAz, windSpeed; 298 Double bandwidth, freqInc, interval, mjd, refFreq, srcVel; 299 String fieldName, srcName, tcalTime, obsType; 300 Vector<Float> calFctr, sigma, tcal, tsys; 301 Matrix<Float> baseLin, baseSub; 302 Vector<Double> direction(2), scanRate(2), srcDir(2), srcPM(2), restFreq(1); 303 Matrix<Float> spectra; 304 Matrix<uChar> flagtra; 305 Complex xCalFctr; 306 Vector<Complex> xPol; 307 **/ 231 308 232 309 Double min = 0.0; … … 236 313 #endif 237 314 PKSrecord pksrec; 315 pksrec.srcType=-1; 238 316 int n = 0; 317 bool isGBTFITS = false ; 318 if ((header_->antennaname.find( "GBT" ) != String::npos) && File(filename_).isRegular()) { 319 FILE *fp = fopen( filename_.c_str(), "r" ) ; 320 fseek( fp, 640, SEEK_SET ) ; 321 char buf[81] ; 322 fread( buf, 80, 1, fp ) ; 323 buf[80] = '\0' ; 324 if ( strstr( buf, "NRAO_GBT" ) != NULL ) { 325 isGBTFITS = true ; 326 } 327 fclose( fp ) ; 328 } 239 329 while ( status == 0 ) { 240 330 status = reader_->read(pksrec); … … 288 378 //*srcnCol = pksrec.srcName;//.before(rx2); 289 379 *srctCol = match; 380 if ( pksrec.srcType != -1 ) { 381 *srctCol = pksrec.srcType ; 382 } 290 383 RecordFieldPtr<uInt> beamCol(rec, "BEAMNO"); 291 384 *beamCol = pksrec.beamNo-beamOffset_-1; … … 298 391 uInt id; 299 392 /// @todo this has to change when nchan isn't global anymore 300 id = table_->frequencies().addEntry(Double(header_->nchan/2), 301 pksrec.refFreq, pksrec.freqInc); 393 //id = table_->frequencies().addEntry(Double(header_->nchan/2), 394 // pksrec.refFreq, pksrec.freqInc); 395 if ( pksrec.nchan == 1 ) { 396 id = table_->frequencies().addEntry(Double(0), 397 pksrec.refFreq, pksrec.freqInc); 398 } 399 else { 400 id = table_->frequencies().addEntry(Double(pksrec.nchan/2), 401 pksrec.refFreq, pksrec.freqInc); 402 } 302 403 RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID"); 303 404 *mfreqidCol = id; 405 //*ifCol = id; 304 406 305 407 id = table_->molecules().addEntry(pksrec.restFreq); … … 317 419 318 420 RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID"); 319 id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi, 421 id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi, 320 422 pksrec.focusTan, pksrec.focusRot); 321 423 *mfocusidCol = id; … … 335 437 // into 2-4 rows in the scantable 336 438 Vector<Float> tsysvec(1); 337 // Why is pksrec.spectra.ncolumn() == 3 for haveXPol_ == True439 // Why is spectra.ncolumn() == 3 for haveXPol_ == True 338 440 uInt npol = (pksrec.spectra.ncolumn()==1 ? 1: 2); 339 441 for ( uInt i=0; i< npol; ++i ) { 340 442 tsysvec = pksrec.tsys(i); 341 443 *tsysCol = tsysvec; 342 *polnoCol = i; 444 if (isGBTFITS) 445 *polnoCol = pksrec.polNo ; 446 else 447 *polnoCol = i; 343 448 344 449 *specCol = pksrec.spectra.column(i); … … 347 452 row.put(table_->table().nrow()-1, rec); 348 453 } 454 455 RecordFieldPtr< uInt > flagrowCol(rec, "FLAGROW"); 456 *flagrowCol = pksrec.flagrow; 457 349 458 if ( haveXPol_[0] ) { 350 459 // no tsys given for xpol, so emulate it … … 381 490 } 382 491 492 /** 493 * For NRO data 494 * 495 * 2008/11/11 Takeshi Nakazato 496 **/ 497 void STFiller::openNRO( int whichIF, int whichBeam ) 498 { 499 // open file 500 // DEBUG 501 time_t t0 ; 502 time( &t0 ) ; 503 tm *ttm = localtime( &t0 ) ; 504 LogIO os( LogOrigin( "STFiller", "openNRO()", WHERE ) ) ; 505 // cout << "STFiller::openNRO() Start time = " << t0 506 // << " (" 507 // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 508 // << " " 509 // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 510 // << ")" << endl ; 511 os << "Start time = " << t0 512 << " (" 513 << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 514 << " " 515 << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 516 << ")" << LogIO::POST ; 517 518 // fill STHeader 519 header_ = new STHeader() ; 520 521 if ( nreader_->getHeaderInfo( header_->nchan, 522 header_->npol, 523 nIF_, 524 nBeam_, 525 header_->observer, 526 header_->project, 527 header_->obstype, 528 header_->antennaname, 529 header_->antennaposition, 530 header_->equinox, 531 header_->freqref, 532 header_->reffreq, 533 header_->bandwidth, 534 header_->utc, 535 header_->fluxunit, 536 header_->epoch, 537 header_->poltype ) ) { 538 // cout << "STFiller::openNRO() Failed to get header information." << endl ; 539 // return ; 540 throw( AipsError("Failed to get header information.") ) ; 541 } 542 543 // set FRAME and BASEFRAME keyword of FREQUENCIES table 544 if ( header_->freqref != "TOPO" ) { 545 table_->frequencies().setFrame( header_->freqref, false ) ; 546 table_->frequencies().setFrame( header_->freqref, true ) ; 547 } 548 549 ifOffset_ = 0; 550 vector<Bool> ifs = nreader_->getIFs() ; 551 if ( whichIF >= 0 ) { 552 if ( whichIF >= 0 && whichIF < nIF_ ) { 553 for ( int i = 0 ; i < nIF_ ; i++ ) 554 ifs[i] = False ; 555 ifs[whichIF] = True ; 556 header_->nif = 1; 557 nIF_ = 1; 558 ifOffset_ = whichIF; 559 } else { 560 delete reader_; 561 reader_ = 0; 562 delete header_; 563 header_ = 0; 564 throw(AipsError("Illegal IF selection")); 565 } 566 } 567 568 beamOffset_ = 0; 569 vector<Bool> beams = nreader_->getBeams() ; 570 if (whichBeam>=0) { 571 if (whichBeam>=0 && whichBeam<nBeam_) { 572 for ( int i = 0 ; i < nBeam_ ; i++ ) 573 beams[i] = False ; 574 beams[whichBeam] = True; 575 header_->nbeam = 1; 576 nBeam_ = 1; 577 beamOffset_ = whichBeam; 578 } else { 579 delete reader_; 580 reader_ = 0; 581 delete header_; 582 header_ = 0; 583 throw(AipsError("Illegal Beam selection")); 584 } 585 } 586 587 header_->nbeam = nBeam_ ; 588 header_->nif = nIF_ ; 589 590 // set header 591 table_->setHeader( *header_ ) ; 592 593 // DEBUG 594 time_t t1 ; 595 time( &t1 ) ; 596 ttm = localtime( &t1 ) ; 597 // cout << "STFiller::openNRO() End time = " << t1 598 // << " (" 599 // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 600 // << " " 601 // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 602 // << ")" << endl ; 603 // cout << "STFiller::openNRO() Elapsed time = " << t1 - t0 << " sec" << endl ; 604 os << "End time = " << t1 605 << " (" 606 << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 607 << " " 608 << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 609 << ")" << endl ; 610 os << "Elapsed time = " << t1 - t0 << " sec" << endl ; 611 os.post() ; 612 // 613 614 return ; 615 } 616 617 int STFiller::readNRO() 618 { 619 // DEBUG 620 time_t t0 ; 621 time( &t0 ) ; 622 tm *ttm = localtime( &t0 ) ; 623 LogIO os( LogOrigin( "STFiller", "readNRO()", WHERE ) ) ; 624 // cout << "STFiller::readNRO() Start time = " << t0 625 // << " (" 626 // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 627 // << " " 628 // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 629 // << ")" << endl ; 630 os << "Start time = " << t0 631 << " (" 632 << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 633 << " " 634 << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 635 << ")" << LogIO::POST ; 636 // 637 638 // fill row 639 uInt id ; 640 uInt imax = nreader_->getRowNum() ; 641 vector< vector<double > > freqs ; 642 uInt i = 0 ; 643 int count = 0 ; 644 uInt scanno ; 645 uInt cycleno ; 646 uInt beamno ; 647 uInt polno ; 648 vector<double> fqs ; 649 Vector<Double> restfreq ; 650 uInt refbeamno ; 651 Double scantime ; 652 Double interval ; 653 String srcname ; 654 String fieldname ; 655 Array<Float> spectra ; 656 Array<uChar> flagtra ; 657 Array<Float> tsys ; 658 Array<Double> direction ; 659 Float azimuth ; 660 Float elevation ; 661 Float parangle ; 662 Float opacity ; 663 uInt tcalid ; 664 Int fitid ; 665 uInt focusid ; 666 Float temperature ; 667 Float pressure ; 668 Float humidity ; 669 Float windvel ; 670 Float winddir ; 671 Double srcvel ; 672 Array<Double> propermotion ; 673 Vector<Double> srcdir ; 674 Array<Double> scanrate ; 675 for ( i = 0 ; i < imax ; i++ ) { 676 string scanType = nreader_->getScanType( i ) ; 677 Int srcType = -1 ; 678 if ( scanType.compare( 0, 2, "ON") == 0 ) { 679 // os << "ON srcType: " << i << LogIO::POST ; 680 srcType = 0 ; 681 } 682 else if ( scanType.compare( 0, 3, "OFF" ) == 0 ) { 683 //os << "OFF srcType: " << i << LogIO::POST ; 684 srcType = 1 ; 685 } 686 else if ( scanType.compare( 0, 4, "ZERO" ) == 0 ) { 687 //os << "ZERO srcType: " << i << LogIO::POST ; 688 srcType = 2 ; 689 } 690 else { 691 //os << "Undefined srcType: " << i << LogIO::POST ; 692 srcType = 3 ; 693 } 694 695 // if srcType is 2 (ZERO scan), ignore scan 696 if ( srcType != 2 && srcType != -1 && srcType != 3 ) { 697 TableRow row( table_->table() ) ; 698 TableRecord& rec = row.record(); 699 700 if ( nreader_->getScanInfo( i, 701 scanno, 702 cycleno, 703 beamno, 704 polno, 705 fqs, 706 restfreq, 707 refbeamno, 708 scantime, 709 interval, 710 srcname, 711 fieldname, 712 spectra, 713 flagtra, 714 tsys, 715 direction, 716 azimuth, 717 elevation, 718 parangle, 719 opacity, 720 tcalid, 721 fitid, 722 focusid, 723 temperature, 724 pressure, 725 humidity, 726 windvel, 727 winddir, 728 srcvel, 729 propermotion, 730 srcdir, 731 scanrate ) ) { 732 // cerr << "STFiller::readNRO() Failed to get scan information." << endl ; 733 // return 1 ; 734 throw( AipsError("Failed to get scan information.") ) ; 735 } 736 737 RecordFieldPtr<uInt> scannoCol( rec, "SCANNO" ) ; 738 *scannoCol = scanno ; 739 RecordFieldPtr<uInt> cyclenoCol(rec, "CYCLENO") ; 740 *cyclenoCol = cycleno ; 741 RecordFieldPtr<uInt> beamCol(rec, "BEAMNO") ; 742 *beamCol = beamno ; 743 RecordFieldPtr<uInt> ifCol(rec, "IFNO") ; 744 RecordFieldPtr< uInt > polnoCol(rec, "POLNO") ; 745 *polnoCol = polno ; 746 RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID") ; 747 if ( freqs.size() == 0 ) { 748 id = table_->frequencies().addEntry( Double( fqs[0] ), 749 Double( fqs[1] ), 750 Double( fqs[2] ) ) ; 751 *mfreqidCol = id ; 752 *ifCol = id ; 753 freqs.push_back( fqs ) ; 754 } 755 else { 756 int iadd = -1 ; 757 for ( uInt iif = 0 ; iif < freqs.size() ; iif++ ) { 758 //os << "freqs[" << iif << "][1] = " << freqs[iif][1] << LogIO::POST ; 759 double fdiff = abs( freqs[iif][1] - fqs[1] ) / freqs[iif][1] ; 760 //os << "fdiff = " << fdiff << LogIO::POST ; 761 if ( fdiff < 1.0e-8 ) { 762 iadd = iif ; 763 break ; 764 } 765 } 766 if ( iadd == -1 ) { 767 id = table_->frequencies().addEntry( Double( fqs[0] ), 768 Double( fqs[1] ), 769 Double( fqs[2] ) ) ; 770 *mfreqidCol = id ; 771 *ifCol = id ; 772 freqs.push_back( fqs ) ; 773 } 774 else { 775 *mfreqidCol = iadd ; 776 *ifCol = iadd ; 777 } 778 } 779 RecordFieldPtr<uInt> molidCol(rec, "MOLECULE_ID") ; 780 id = table_->molecules().addEntry( restfreq ) ; 781 *molidCol = id ; 782 RecordFieldPtr<Int> rbCol(rec, "REFBEAMNO") ; 783 *rbCol = refbeamno ; 784 RecordFieldPtr<Double> mjdCol( rec, "TIME" ) ; 785 *mjdCol = scantime ; 786 RecordFieldPtr<Double> intervalCol( rec, "INTERVAL" ) ; 787 *intervalCol = interval ; 788 RecordFieldPtr<String> srcnCol(rec, "SRCNAME") ; 789 *srcnCol = srcname ; 790 RecordFieldPtr<Int> srctCol(rec, "SRCTYPE") ; 791 *srctCol = srcType ; 792 RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME"); 793 *fieldnCol = fieldname ; 794 RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA") ; 795 *specCol = spectra ; 796 RecordFieldPtr< Array<uChar> > flagCol(rec, "FLAGTRA") ; 797 *flagCol = flagtra ; 798 RecordFieldPtr< Array<Float> > tsysCol(rec, "TSYS") ; 799 *tsysCol = tsys ; 800 RecordFieldPtr< Array<Double> > dirCol(rec, "DIRECTION") ; 801 *dirCol = direction ; 802 RecordFieldPtr<Float> azCol(rec, "AZIMUTH") ; 803 *azCol = azimuth ; 804 RecordFieldPtr<Float> elCol(rec, "ELEVATION") ; 805 *elCol = elevation ; 806 RecordFieldPtr<Float> parCol(rec, "PARANGLE") ; 807 *parCol = parangle ; 808 RecordFieldPtr<Float> tauCol(rec, "OPACITY") ; 809 *tauCol = opacity ; 810 RecordFieldPtr<uInt> mcalidCol(rec, "TCAL_ID") ; 811 *mcalidCol = tcalid ; 812 RecordFieldPtr<Int> fitCol(rec, "FIT_ID") ; 813 *fitCol = fitid ; 814 RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID") ; 815 *mfocusidCol = focusid ; 816 RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID") ; 817 id = table_->weather().addEntry( temperature, 818 pressure, 819 humidity, 820 windvel, 821 winddir ) ; 822 *mweatheridCol = id ; 823 RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY") ; 824 *svelCol = srcvel ; 825 RecordFieldPtr<Array<Double> > spmCol(rec, "SRCPROPERMOTION") ; 826 *spmCol = propermotion ; 827 RecordFieldPtr<Array<Double> > sdirCol(rec, "SRCDIRECTION") ; 828 *sdirCol = srcdir ; 829 RecordFieldPtr<Array<Double> > srateCol(rec, "SCANRATE"); 830 *srateCol = scanrate ; 831 832 table_->table().addRow() ; 833 row.put(table_->table().nrow()-1, rec) ; 834 } 835 else { 836 count++ ; 837 } 838 // DEBUG 839 //int rownum = nreader_->getRowNum() ; 840 //os << "Finished row " << i << "/" << rownum << LogIO::POST ; 841 // 842 } 843 844 // DEBUG 845 time_t t1 ; 846 time( &t1 ) ; 847 ttm = localtime( &t1 ) ; 848 // cout << "STFiller::readNRO() Processed " << i << " rows" << endl ; 849 // cout << "STFiller::readNRO() Added " << i - count << " rows (ignored " 850 // << count << " \"ZERO\" scans)" << endl ; 851 // cout << "STFiller::readNRO() End time = " << t1 852 // << " (" 853 // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 854 // << " " 855 // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 856 // << ")" << endl ; 857 // cout << "STFiller::readNRO() Elapsed time = " << t1 - t0 << " sec" << endl ; 858 os << "Processed " << i << " rows" << endl ; 859 os << "Added " << i - count << " rows (ignored " 860 << count << " \"ZERO\" scans)" << endl ; 861 os.post() ; 862 os << "End time = " << t1 863 << " (" 864 << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 865 << " " 866 << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 867 << ")" << endl ; 868 os << "Elapsed time = " << t1 - t0 << " sec" << endl ; 869 os.post() ; 870 // 871 872 return 0 ; 873 } 874 875 Bool STFiller::fileCheck() 876 { 877 bool bval = false ; 878 879 // if filename_ is directory, return false 880 File inFile( filename_ ) ; 881 if ( inFile.isDirectory() ) 882 return bval ; 883 884 // if beginning of header data is "RW", return true 885 // otherwise, return false ; 886 FILE *fp = fopen( filename_.c_str(), "r" ) ; 887 char buf[9] ; 888 char buf2[80] ; 889 fread( buf, 4, 1, fp ) ; 890 buf[4] = '\0' ; 891 fseek( fp, 640, SEEK_SET ) ; 892 fread( buf2, 80, 1, fp ) ; 893 if ( ( strncmp( buf, "RW", 2 ) == 0 ) || ( strstr( buf2, "NRO45M" ) != NULL ) ) { 894 bval = true ; 895 } 896 fclose( fp ) ; 897 return bval ; 898 } 899 383 900 }//namespace asap
Note:
See TracChangeset
for help on using the changeset viewer.