198 const uint32_t catalog_size =
sizeof(int64_t)*2;
201 c.
SetStr(
"XTENSION",
"BINTABLE" ,
"binary table extension");
202 c.
SetInt(
"BITPIX" , 8 ,
"8-bit bytes");
203 c.
SetInt(
"NAXIS" , 2 ,
"2-dimensional binary table");
204 c.
SetInt(
"NAXIS1" , catalog_size ,
"width of table in bytes");
205 c.
SetInt(
"NAXIS2" , 1 ,
"number of rows in table");
206 c.
SetInt(
"PCOUNT" , 0 ,
"size of special data area");
207 c.
SetInt(
"GCOUNT" , 1 ,
"one data group (required keyword)");
208 c.
SetInt(
"TFIELDS" , 1 ,
"number of fields in each row");
209 c.
SetStr(
"CHECKSUM",
"0000000000000000" ,
"Checksum for the whole HDU");
210 c.
SetStr(
"DATASUM" ,
" 0" ,
"Checksum for the data block");
211 c.
SetStr(
"EXTNAME" ,
"ZDrsCellOffsets" ,
"name of this binary table extension");
212 c.
SetStr(
"TTYPE1" ,
"OffsetCalibration" ,
"label for field 1");
213 c.
SetStr(
"ZFORM1" ,
"1474560I" ,
"data format of field: 2-byte INTEGER");
214 c.
SetStr(
"TFORM1" ,
"1QB" ,
"data format of variable length bytes");
215 c.
SetStr(
"ZCTYP1" ,
"FACT" ,
"Compression type FACT");
217 c.
SetBool(
"ZTABLE",
true,
"Table is compressed");
218 c.
SetInt(
"ZNAXIS1", 1024*1440*2,
"Width of uncompressed rows");
219 c.
SetInt(
"ZNAXIS2", 1,
"Number of uncompressed rows");
220 c.
SetInt(
"ZPCOUNT", 0,
"");
221 c.
SetInt(
"ZHEAPPTR", catalog_size,
"");
222 c.
SetInt(
"ZTILELEN", 1,
"Number of rows per tile");
223 c.
SetInt(
"THEAP", catalog_size,
"");
224 c.
SetStr(
"RAWSUM",
" 0",
"Checksum of raw little endian data");
225 c.
SetFloat(
"ZRATIO", 0,
"Compression ratio");
227 c.
SetInt(
"ZSHRINK", 1,
"Catalog shrink factor");
232 const off_t here_I_am = tellp();
235 seekp(here_I_am + catalog_size);
240 #if GCC_VERSION < 40603 241 c.
SetStr(
"RAWSUM", std::to_string((
long long unsigned int)(rawsum.
val())));
243 c.
SetStr(
"RAWSUM", std::to_string(rawsum.
val()));
248 std::vector<char> compressed_calib(1024*1440*2 + compressed_header_size + 8);
249 char* data_start = compressed_calib.data() + compressed_header_size;
251 compressed_size += compressed_header_size;
258 th.size = compressed_size;
265 memset(compressed_calib.data()+compressed_size, 0, 8-compressed_size%8);
266 datasum.
add(compressed_calib.data(), compressed_size + 8-compressed_size%8);
271 std::vector<uint64_t> catalog(2,0);
275 std::vector<char> swappedCatalog(catalog_size);
276 revcpy<sizeof(int64_t)>(swappedCatalog.data(), (
char*)(catalog.data()), 2);
277 datasum.
add(swappedCatalog.data(), catalog_size);
279 write(swappedCatalog.data(), catalog_size);
282 c.
SetFloat(
"ZRATIO", (
float)(1024*1440*2)/(
float)(compressed_size));
283 c.
SetInt(
"PCOUNT", compressed_size);
289 #if GCC_VERSION < 40603 290 c.
SetStr(
"DATASUM", std::to_string((
long long unsigned int)(datasum.
val())));
292 c.
SetStr(
"DATASUM", std::to_string(datasum.
val()));
302 seekp(here_I_am + catalog_size);
303 write(compressed_calib.data(), compressed_size);
bool SetInt(const std::string &key, int64_t i, const std::string &comment="")
uint32_t compressHUFFMAN16(char *dest, const char *src, uint32_t numRows, uint32_t sizeOfElems, uint32_t numRowElems)
bool SetBool(const std::string &key, bool b, const std::string &comment="")
bool SetStr(const std::string &key, std::string s, const std::string &comment="")
std::string str(bool complm=true) const
std::vector< int16_t > fOffsetCalibration
The calibration itself.
bool SetFloat(const std::string &key, double f, int p, const std::string &comment="")
virtual bool IsOffsetCalibration()
whether or not a calibration was given to the file writer
bool add(const char *buf, size_t len, bool big_endian=true)
Checksum WriteHeader(std::ostream &fout)