Write the drs calibration to disk, if any.
746 uint64_t whereDidIStart =
_file.tellp();
747 vector<HeaderEntry> header;
748 header.push_back(HeaderEntry(
"XTENSION",
"'BINTABLE' ",
"binary table extension"));
749 header.push_back(HeaderEntry(
"BITPIX" , 8 ,
"8-bit bytes"));
750 header.push_back(HeaderEntry(
"NAXIS" , 2 ,
"2-dimensional binary table"));
751 header.push_back(HeaderEntry(
"NAXIS1" , 1024*1440*2 ,
"width of table in bytes"));
752 header.push_back(HeaderEntry(
"NAXIS2" , 1 ,
"number of rows in table"));
753 header.push_back(HeaderEntry(
"PCOUNT" , 0 ,
"size of special data area"));
754 header.push_back(HeaderEntry(
"GCOUNT" , 1 ,
"one data group (required keyword)"));
755 header.push_back(HeaderEntry(
"TFIELDS" , 1 ,
"number of fields in each row"));
756 header.push_back(HeaderEntry(
"CHECKSUM",
"'0000000000000000' ",
"Checksum for the whole HDU"));
757 header.push_back(HeaderEntry(
"DATASUM" ,
" 0" ,
"Checksum for the data block"));
758 header.push_back(HeaderEntry(
"EXTNAME" ,
"'ZDrsCellOffsets' ",
"name of this binary table extension"));
759 header.push_back(HeaderEntry(
"TTYPE1" ,
"'OffsetCalibration' ",
"label for field 1"));
760 header.push_back(HeaderEntry(
"TFORM1" ,
"'1474560I' ",
"data format of field: 2-byte INTEGER"));
762 for (uint32_t
i=0;
i<header.size();
i++)
763 _file.write(header[
i].fitsString().c_str(), 80);
765 _file.write(
"END ", 80);
766 long here =
_file.tellp();
770 int16_t* swappedBytes =
new int16_t[1024];
772 for (int32_t
i=0;
i<1440;
i++)
775 for (int32_t j=0;j<2048;j+=2)
778 inter =
reinterpret_cast<int8_t*
>(swappedBytes)[j];
779 reinterpret_cast<int8_t*
>(swappedBytes)[j] = reinterpret_cast<int8_t*>(swappedBytes)[j+1];
780 reinterpret_cast<int8_t*
>(swappedBytes)[j+1] = inter;
782 _file.write(reinterpret_cast<char*>(swappedBytes), 2048);
783 checksum.
add(reinterpret_cast<char*>(swappedBytes), 2048);
785 uint64_t whereDidIStop =
_file.tellp();
786 delete[] swappedBytes;
791 str << checksum.
val();
792 header[9] = HeaderEntry(
"DATASUM", str.str(),
"Checksum for the data block");
793 for (vector<HeaderEntry>::iterator it=header.begin();it!=header.end(); it++)
794 checksum.
add(it->fitsString().c_str(), 80);
797 checksum.
add(
end.c_str(), 80);
798 int headerRowsLeft = 36 - (header.size() + 1)%36;
799 for (
int i=0;
i<headerRowsLeft;
i++)
800 checksum.
add(space.c_str(), 80);
802 header[8] = HeaderEntry(
"CHECKSUM", checksum.
str(),
"Checksum for the whole HDU");
804 _file.seekp(whereDidIStart);
805 for (uint32_t
i=0;
i<header.size();
i++)
806 _file.write(header[
i].fitsString().c_str(), 80);
807 _file.seekp(whereDidIStop);
int16_t * _drsCalibData
array of the Drs baseline mean
static string _emptyBlock
an empty block to be apened at the end of a file so that its length is a multiple of 2880 ...
fstream _file
The actual file streamer for accessing disk data.
std::string str(bool complm=true) const
bool add(const char *buf, size_t len, bool big_endian=true)