Changeset 17274
- Timestamp:
- 10/20/13 17:28:37 (11 years ago)
- Location:
- trunk/Mars/mcore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/DrsCalib.h
r17265 r17274 1234 1234 std::string ReadFitsImp(const std::string &str, std::vector<float> &vec) 1235 1235 { 1236 #ifndef __MARS__1237 std::fits file(str);1238 #else1239 1236 fits file(str); 1240 #endif1241 1237 if (!file) 1242 1238 { -
trunk/Mars/mcore/factfits.h
r17264 r17274 135 135 if (calib.bad()) 136 136 { 137 clear(rdstate()| ios::badbit);137 clear(rdstate()|std::ios::badbit); 138 138 return; 139 139 } … … 145 145 if (calib.GetNumRows() != 1) 146 146 { 147 clear(rdstate()| ios::badbit);148 #ifdef __EXCEPTIONS 149 throw runtime_error("Table 'ZDrsCellOffsets' found, but not with one row as expected");147 clear(rdstate()|std::ios::badbit); 148 #ifdef __EXCEPTIONS 149 throw std::runtime_error("Table 'ZDrsCellOffsets' found, but not with one row as expected"); 150 150 #else 151 151 gLog << ___err___ << "ERROR - Table 'ZDrsCellOffsets' found, but not with one row as expected" << endl; … … 155 155 if (calib.GetStr("TTYPE1") != "OffsetCalibration") 156 156 { 157 clear(rdstate()| ios::badbit);158 #ifdef __EXCEPTIONS 159 throw runtime_error("Table 'DrsCalib' found, but first column is not the one expected");157 clear(rdstate()|std::ios::badbit); 158 #ifdef __EXCEPTIONS 159 throw std::runtime_error("Table 'DrsCalib' found, but first column is not the one expected"); 160 160 #else 161 161 gLog << ___err___ << "ERROR - Table 'DrsCalib' found, but first column is not the one expected" << endl; … … 165 165 if (calib.GetStr("TFORM1") != "1474560I") // 1024*1440 166 166 { 167 clear(rdstate()| ios::badbit);168 #ifdef __EXCEPTIONS 169 throw runtime_error("Table 'DrsCalib' has wrong column format (TFROM1)");167 clear(rdstate()|std::ios::badbit); 168 #ifdef __EXCEPTIONS 169 throw std::runtime_error("Table 'DrsCalib' has wrong column format (TFROM1)"); 170 170 #else 171 171 gLog << ___err___ << "ERROR - Table 'DrsCalib' has wrong column format (TFORM1)" << endl; … … 180 180 return; 181 181 182 clear(rdstate()| ios::badbit);183 184 #ifdef __EXCEPTIONS 185 throw runtime_error("Reading column 'OffsetCalibration' failed.");182 clear(rdstate()|std::ios::badbit); 183 184 #ifdef __EXCEPTIONS 185 throw std::runtime_error("Reading column 'OffsetCalibration' failed."); 186 186 #else 187 187 gLog << ___err___ << "ERROR - Reading column 'OffsetCalibration' failed." << endl; … … 190 190 } 191 191 192 vector<int16_t> fOffsetCalibration; ///< integer values of the drs calibration used for compression192 std::vector<int16_t> fOffsetCalibration; ///< integer values of the drs calibration used for compression 193 193 194 194 size_t fOffsetStartCellData; -
trunk/Mars/mcore/fits.h
r17260 r17274 23 23 #include <iomanip> 24 24 #include <iostream> 25 #define gLog cerr 25 #ifndef gLog 26 #define gLog std::cerr 26 27 #define ___err___ "" 27 28 #define ___warn___ "" 28 29 #define ___all___ "" 30 #endif 29 31 #else 30 32 #include "MLog.h" … … 44 46 45 47 #include "checksum.h" 46 47 #ifndef __MARS__48 namespace std49 {50 #endif51 48 52 49 class fits : public izstream … … 136 133 throw std::runtime_error(str.str()); 137 134 #else 138 gLog << ___err___ << "ERROR - " << str.str() << endl;135 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 139 136 return false; 140 137 #endif … … 148 145 throw std::runtime_error(str.str()); 149 146 #else 150 gLog << ___err___ << "ERROR - " << str.str() << endl;147 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 151 148 return false; 152 149 #endif … … 160 157 throw std::runtime_error(str.str()); 161 158 #else 162 gLog << ___err___ << "ERROR - " << str.str() << endl;159 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 163 160 return false; 164 161 #endif … … 319 316 throw std::runtime_error(str.str()); 320 317 #else 321 gLog << ___err___ << "ERROR - " << str.str() << endl;318 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 322 319 return; 323 320 #endif … … 337 334 throw std::runtime_error("Column size mismatch"); 338 335 #else 339 gLog << ___err___ << "ERROR - Column size mismatch" << endl;336 gLog << ___err___ << "ERROR - Column size mismatch" << std::endl; 340 337 return; 341 338 #endif … … 362 359 continue; 363 360 364 gLog << ___all___ << s etw(2) << it->second.type << '|' << it->first << '=' << it->second.value << '/' << it->second.comment << '|' <<endl;361 gLog << ___all___ << std::setw(2) << it->second.type << '|' << it->first << '=' << it->second.value << '/' << it->second.comment << '|' << std::endl; 365 362 }} 366 363 … … 376 373 for (Sorted::const_iterator it=sorted.cbegin(); it!=sorted.cend(); it++) 377 374 { 378 gLog << ___all___ << s etw(6) << it->second.offset << "| ";375 gLog << ___all___ << std::setw(6) << it->second.offset << "| "; 379 376 gLog << it->second.num << 'x'; 380 377 switch (it->second.type) … … 389 386 case 'D': gLog << "double(64)"; break; 390 387 } 391 gLog << ": " << it->first.second << " [" << it->second.unit << "]" << endl;388 gLog << ": " << it->first.second << " [" << it->second.unit << "]" << std::endl; 392 389 } 393 390 } … … 427 424 throw std::runtime_error(str.str()); 428 425 #else 429 gLog << ___err___ << "ERROR - " << str.str() << endl;426 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 430 427 return T(); 431 428 #endif … … 557 554 } 558 555 559 void Constructor(const st ring &fname, string fout, conststring& tableName, bool force, int tableNumber=-1)556 void Constructor(const std::string &fname, std::string fout, const std::string& tableName, bool force, int tableNumber=-1) 560 557 { 561 558 char simple[10]; … … 568 565 if (memcmp(simple, "SIMPLE = ", 10)) 569 566 { 570 clear(rdstate()| ios::badbit);567 clear(rdstate()|std::ios::badbit); 571 568 #ifdef __EXCEPTIONS 572 569 throw std::runtime_error("File is not a FITS file."); 573 570 #else 574 gLog << ___err___ << "ERROR - File is not a FITS file." << endl;571 gLog << ___err___ << "ERROR - File is not a FITS file." << std::endl; 575 572 return; 576 573 #endif … … 596 593 if (!good()) 597 594 { 598 clear(rdstate()| ios::badbit);595 clear(rdstate()|std::ios::badbit); 599 596 #ifdef __EXCEPTIONS 600 597 throw std::runtime_error("FITS file corrupted."); 601 598 #else 602 gLog << ___err___ << "ERROR - FITS file corrupted." << endl;599 gLog << ___err___ << "ERROR - FITS file corrupted." << std::endl; 603 600 return; 604 601 #endif … … 609 606 if (!rc && !force) 610 607 { 611 clear(rdstate()| ios::badbit);608 clear(rdstate()|std::ios::badbit); 612 609 #ifdef __EXCEPTIONS 613 610 throw std::runtime_error("END keyword missing in FITS header."); 614 611 #else 615 gLog << ___err___ << "ERROR - END keyword missing in FITS file... file might be corrupted." << endl;612 gLog << ___err___ << "ERROR - END keyword missing in FITS file... file might be corrupted." << std::endl; 616 613 return; 617 614 #endif … … 637 634 if (!fTable) 638 635 { 639 clear(rdstate()| ios::badbit);636 clear(rdstate()|std::ios::badbit); 640 637 return; 641 638 } … … 643 640 // Check for table name. Skip until eof or requested table are found. 644 641 // skip the current table? 645 if ((!tableName.empty() && tableName!=fTable.Get<st ring>("EXTNAME")) ||646 ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<st ring>("EXTNAME")) ||642 if ((!tableName.empty() && tableName!=fTable.Get<std::string>("EXTNAME")) || 643 ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<std::string>("EXTNAME")) || 647 644 (tableNumber != -1)) 648 645 { … … 655 652 } 656 653 const streamoff skip = fTable.GetTotalBytes(); 657 seekg(skip, ios_base::cur);654 seekg(skip, std::ios_base::cur); 658 655 659 656 fChkHeader.reset(); … … 682 679 if (!fCopy) 683 680 { 684 clear(rdstate()| ios::badbit);681 clear(rdstate()|std::ios::badbit); 685 682 #ifdef __EXCEPTIONS 686 683 throw std::runtime_error("Could not open output file."); 687 684 #else 688 gLog << ___err___ << "ERROR - Failed to open output file." << endl;685 gLog << ___err___ << "ERROR - Failed to open output file." << std::endl; 689 686 #endif 690 687 } … … 698 695 fCopy.write(buf.data(), p); 699 696 if (!fCopy) 700 clear(rdstate()| ios::badbit);697 clear(rdstate()|std::ios::badbit); 701 698 } 702 699 … … 711 708 throw std::runtime_error("You are trying to read a compressed fits with the base fits class. Please use factfits instead."); 712 709 #else 713 gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << endl;714 #endif 715 clear(rdstate()| ios::badbit);710 gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << std::endl; 711 #endif 712 clear(rdstate()|std::ios::badbit); 716 713 } 717 714 } … … 726 723 throw std::runtime_error("You are trying to read a compressed fits with the base fits class. Please use factfits instead."); 727 724 #else 728 gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << endl;729 #endif 730 clear(rdstate()| ios::badbit);725 gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << std::endl; 726 #endif 727 clear(rdstate()|std::ios::badbit); 731 728 } 732 729 } … … 762 759 fCopy.write(fBufferRow.data()+offset, fTable.bytes_per_row); 763 760 if (!fCopy) 764 clear(rdstate()| ios::badbit);761 clear(rdstate()|std::ios::badbit); 765 762 } 766 763 else 767 764 if (fCopy.is_open()) 768 clear(rdstate()| ios::badbit);765 clear(rdstate()|std::ios::badbit); 769 766 } 770 767 … … 804 801 const char *pend = src + num*N; 805 802 for (const char *ptr = src; ptr<pend; ptr+=N, dest+=N) 806 reverse_copy(ptr, ptr+N, dest);803 std::reverse_copy(ptr, ptr+N, dest); 807 804 } 808 805 … … 883 880 throw std::runtime_error(str.str()); 884 881 #else 885 gLog << ___err___ << "ERROR - " << str.str() << endl;882 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 886 883 return NULL; 887 884 #endif … … 912 909 throw std::runtime_error(str.str()); 913 910 #else 914 gLog << ___err___ << "ERROR - " << str.str() << endl;911 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 915 912 return false; 916 913 #endif … … 925 922 throw std::runtime_error(str.str()); 926 923 #else 927 gLog << ___err___ << "ERROR - " << str.str() << endl;924 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 928 925 return false; 929 926 #endif … … 938 935 throw std::runtime_error(str.str()); 939 936 #else 940 gLog << ___err___ << "ERROR - " << str.str() << endl;937 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 941 938 return false; 942 939 #endif … … 986 983 throw std::runtime_error(str.str()); 987 984 #else 988 gLog << ___err___ << "ERROR - " << str.str() << endl;985 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 989 986 return false; 990 987 #endif … … 999 996 throw std::runtime_error(str.str()); 1000 997 #else 1001 gLog << ___err___ << "ERROR - " << str.str() << endl;998 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 1002 999 return false; 1003 1000 #endif … … 1054 1051 }; 1055 1052 1056 #ifndef __MARS__ 1057 }; 1058 #endif 1059 #endif 1053 #endif -
trunk/Mars/mcore/ofits.h
r17264 r17274 18 18 19 19 #ifndef __MARS__ 20 #define gLog cerr 20 #ifndef gLog 21 #define gLog std::cerr 21 22 #define ___err___ "" 22 23 #define ___warn___ "" 23 24 #define ___all___ "" 25 #endif 24 26 #else 25 27 #include "MLog.h" -
trunk/Mars/mcore/zfits.h
r17261 r17274 14 14 #include "FITS.h" 15 15 16 #ifndef __MARS__17 namespace std18 {19 #endif20 21 16 class zfits : public fits 22 17 { … … 24 19 25 20 // Basic constructor 26 zfits(const st ring& fname, conststring& tableName="", bool force=false)21 zfits(const std::string& fname, const std::string& tableName="", bool force=false) 27 22 : fNumTiles(0), fNumRowsPerTile(0), fCurrentRow(-1), fHeapOff(0), fTileSize(0) 28 23 { … … 33 28 34 29 // Alternative contstructor 35 zfits(const st ring& fname, const string& fout, conststring& tableName, bool force=false)30 zfits(const std::string& fname, const std::string& fout, const std::string& tableName, bool force=false) 36 31 : fNumTiles(0), fNumRowsPerTile(0), fCurrentRow(-1), fHeapOff(0), fTileSize(0) 37 32 { … … 112 107 continue; 113 108 114 clear(rdstate()| ios::badbit);109 clear(rdstate()|std::ios::badbit); 115 110 #ifdef __EXCEPTIONS 116 throw runtime_error("Only the FACT compression scheme is handled by this reader.");111 throw std::runtime_error("Only the FACT compression scheme is handled by this reader."); 117 112 #else 118 113 gLog << ___err___ << "ERROR - Only the FACT compression scheme is handled by this reader." << endl; … … 161 156 streamoff fHeapFromDataStart; ///< offset from the beginning of the data table 162 157 163 std::vector<std::vector< pair<int64_t, int64_t>>> fCatalog; ///< Catalog, i.e. the main table that points to the compressed data.164 std::vector<size_t> fTileSize; ///< size in bytes of each compressed tile165 std::vector<std::vector<size_t>> fTileOffsets; ///< offset from start of tile of a given compressed column158 std::vector<std::vector<std::pair<int64_t, int64_t>>> fCatalog; ///< Catalog, i.e. the main table that points to the compressed data. 159 std::vector<size_t> fTileSize; ///< size in bytes of each compressed tile 160 std::vector<std::vector<size_t>> fTileOffsets; ///< offset from start of tile of a given compressed column 166 161 167 162 Checksum fRawsum; ///< Checksum of the uncompressed, raw data … … 212 207 if (tempValues[0] < 0 || tempValues[1] < 0) 213 208 { 214 clear(rdstate()| ios::badbit);209 clear(rdstate()|std::ios::badbit); 215 210 #ifdef __EXCEPTIONS 216 throw runtime_error("Negative value in the catalog");211 throw std::runtime_error("Negative value in the catalog"); 217 212 #else 218 213 gLog << ___err___ << "ERROR - negative value in the catalog" << endl; … … 266 261 fCopy.write(buf.data(), catSize); 267 262 if (!fCopy) 268 clear(rdstate()| ios::badbit);263 clear(rdstate()|std::ios::badbit); 269 264 } 270 265 … … 321 316 fCopy.write(fCompressedBuffer.data()+offset, sizeToRead); 322 317 if (!fCopy) 323 clear(rdstate()| ios::badbit);318 clear(rdstate()|std::ios::badbit); 324 319 } 325 320 else 326 321 if (fCopy.is_open()) 327 clear(rdstate()| ios::badbit);322 clear(rdstate()|std::ios::badbit); 328 323 329 324 const uint32_t thisRoundNumRows = (GetNumRows()<fCurrentRow + fNumRowsPerTile) ? GetNumRows()%fNumRowsPerTile : fNumRowsPerTile; … … 364 359 365 360 default: 366 clear(rdstate()| ios::badbit);361 clear(rdstate()|std::ios::badbit); 367 362 #ifdef __EXCEPTIONS 368 throw runtime_error("Unkown column ordering scheme found");363 throw std::runtime_error("Unkown column ordering scheme found"); 369 364 #else 370 365 gLog << ___err___ << "ERROR - unkown column ordering scheme" << endl; … … 473 468 474 469 default: 475 clear(rdstate()| ios::badbit);470 clear(rdstate()|std::ios::badbit); 476 471 477 472 std::ostringstream str; 478 473 str << "Unkown processing applied to data. Col " << i << " proc " << j << " out of " << (int)head->numProcs; 479 474 #ifdef __EXCEPTIONS 480 throw runtime_error(str.str());475 throw std::runtime_error(str.str()); 481 476 #else 482 477 gLog << ___err___ << "ERROR - Unknown processing applied to data. Aborting" << endl; … … 520 515 if (memcmp(tileHead.id, "TILE", 4)) 521 516 { 522 clear(rdstate()| ios::badbit);517 clear(rdstate()|std::ios::badbit); 523 518 break; 524 519 } … … 562 557 if (numRows != fTable.num_rows) 563 558 { 564 clear(rdstate()| ios::badbit);559 clear(rdstate()|std::ios::badbit); 565 560 std::ostringstream str; 566 561 str << "Heap data does not agree with header: " << numRows << " calculated vs " << fTable.num_rows << " from header."; 567 562 #ifdef __EXCEPTIONS 568 throw runtime_error(str.str());563 throw std::runtime_error(str.str()); 569 564 #else 570 565 gLog << ___err___ << "ERROR - " << str.str() << endl; … … 584 579 if (catalog.size() != fCatalog.size()) 585 580 { 586 clear(rdstate()| ios::badbit);581 clear(rdstate()|std::ios::badbit); 587 582 #ifdef __EXCEPTIONS 588 throw runtime_error("Heap data does not agree with header.");583 throw std::runtime_error("Heap data does not agree with header."); 589 584 #else 590 585 gLog << ___err___ << "ERROR - Heap data does not agree with header." << endl; … … 599 594 catalog[i][j].second != fCatalog[i][j].second) 600 595 { 601 clear(rdstate()| ios::badbit);596 clear(rdstate()|std::ios::badbit); 602 597 #ifdef __EXCEPTIONS 603 throw runtime_error("Heap data does not agree with header.");598 throw std::runtime_error("Heap data does not agree with header."); 604 599 #else 605 600 gLog << ___err___ << "ERROR - Heap data does not agree with header." << endl; … … 616 611 };//class zfits 617 612 618 #ifndef __MARS__619 }; //namespace std620 #endif621 622 613 #endif
Note:
See TracChangeset
for help on using the changeset viewer.