Changeset 13987 for trunk/Mars
- Timestamp:
- 05/30/12 16:36:39 (12 years ago)
- Location:
- trunk/Mars/mcore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/checksum.h
r12995 r13987 69 69 uint32_t *hilo = reinterpret_cast<uint32_t*>(&buffer); 70 70 71 for (size_t ii = 0; ii < len/2; ii++) 72 hilo[(ii+1)%2] += sbuf[ii]; 73 71 for (size_t i = 0; i < len/2; i++) 72 { 73 //swap the bytes of the 32 bits value. but... 74 //the hi and lo values are stored in fits-like order. do not swap them 75 hilo[i%2] += (sbuf[i]&0xff00)>>8 | (sbuf[i]&0x00ff)<<8; 76 } 74 77 HandleCarryBits(); 75 78 … … 92 95 }; 93 96 94 constuint32_t value = complm ? ~val() : val(); // complement each bit of the value95 /* 97 uint32_t value = complm ? ~val() : val(); // complement each bit of the value 98 96 99 for (int ii = 0; ii < 4; ii++) 97 100 { 98 101 uint8_t byte = (value >> (24 - (8 * ii))); 99 102 100 const uint8_t quotient = byte / 4 + offset;103 const uint8_t quotient = byte / 4 + '0'; 101 104 const uint8_t remainder = byte % 4; 102 105 … … 128 131 } 129 132 133 char lastChar = rc[15]; 134 for (int i=15;i>0;i--) 135 rc[i] = rc[i-1]; 136 rc[0] = lastChar; 130 137 return rc; 131 */ 132 const uint8_t *p = reinterpret_cast<const uint8_t*>(&value); 138 /* 139 uint8_t *p = reinterpret_cast<uint8_t*>(&value); 140 //swap the bytes of the value 141 uint8_t temp; 142 temp = p[0]; 143 p[0] = p[3]; 144 p[3] = temp; 145 temp = p[1]; 146 p[1] = p[2]; 147 p[2] = temp; 133 148 134 149 for (int i=0; i<4; i++) … … 160 175 161 176 return rc; 162 } 177 */ 178 } 163 179 }; 164 180 } -
trunk/Mars/mcore/ofits.h
r13115 r13987 326 326 SetInt("TFIELDS", 0, "number of fields in each row"); 327 327 SetStr("EXTNAME", "", "name of extension table"); 328 SetStr("CHECKSUM", " {0000000000000000}", "Checksum for the whole file");329 Set Int("DATASUM", 0, "Checksum for the data block");328 SetStr("CHECKSUM", "0000000000000000", "Checksum for the whole HDU"); 329 SetStr("DATASUM", " 0", "Checksum for the data block"); 330 330 331 331 ofstream::open(filename); … … 608 608 h.SetInt ("NAXIS", 0, "number of data axes"); 609 609 h.SetBool("EXTEND", true, "FITS dataset may contain extensions"); 610 610 h.SetStr ("CHECKSUM","4AcB48bA4AbA45bA", "Checksum for the whole HDU"); 611 h.SetStr ("DATASUM", " 0", "Checksum for the data block"); 611 612 h.AddComment("FITS (Flexible Image Transport System) format is defined in 'Astronomy"); 612 613 h.AddComment("and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H"); … … 733 734 if (tellp()%(80*36)>0) 734 735 { 735 //cout << "fill" << endl;736 736 const vector<char> filler(80*36-tellp()%(80*36)); 737 737 write(filler.data(), filler.size()); 738 738 } 739 739 740 // We don't hav eto jump back to the end of the file740 // We don't have to jump back to the end of the file 741 741 SetInt("NAXIS2", fTable.num_rows); 742 SetInt("DATASUM", fDataSum.val()); 742 743 ostringstream dataSumStr; 744 dataSumStr << fDataSum.val(); 745 SetStr("DATASUM", dataSumStr.str()); 743 746 744 747 const Checksum sum = WriteHeader(); 748 745 749 //sum += headersum; 746 750 747 SetStr("CHECKSUM", "{"+(sum+fDataSum).str()+"}");751 SetStr("CHECKSUM", (sum+fDataSum).str()); 748 752 749 753 const Checksum chk = WriteHeader();
Note:
See TracChangeset
for help on using the changeset viewer.