FACT++  1.0
int main ( int  argc,
const char **  argv 
)

Definition at line 1505 of file fitsCompressor.cc.

References Checksum::add(), CompressedFitsWriter::addColumn(), ofits::AddColumn(), BlockHeader(), buffer, izstream::close(), CompressedFitsWriter::close(), ofits::close(), count, Configuration::DoParse(), first, Configuration::Get(), ofits::GetChecksumData(), fits::GetColumns(), fits::GetKeys(), fits::GetNextRow(), zfits::GetNumRows(), fits::GetSortedColumns(), fits::GetStr(), fits::GetUInt(), Configuration::Has(), fits::HasKey(), i, fits::IsCompressedFITS(), zfits::IsFileOk(), FITS::kFactHuffman16, FITS::kFactRaw, FITS::kFactSmoothing, FITS::kOrderByRow, ofits::open(), CompressedFitsWriter::open(), printHelp(), printUsage(), second, CompressedFitsWriter::setDrsCalib(), CompressedFitsWriter::setHeaderKey(), ofits::SetKeyComment(), CompressedFitsWriter::setNumWorkingThreads(), Configuration::SetPrintUsage(), fits::SetPtrAddress(), setupConfiguration(), str, type, Checksum::val(), Configuration::Vec(), CompressedFitsWriter::writeBinaryRow(), ofits::WriteRow(), and ofits::WriteTableHeader().

1506 {
1507  Configuration conf(argv[0]);
1508  conf.SetPrintUsage(printUsage);
1509  setupConfiguration(conf);
1510 
1511  if (!conf.DoParse(argc, argv, printHelp))
1512  return -1;
1513 
1514  //initialize the file names to nothing.
1515  string fileNameIn = "";
1516  string fileNameOut = "";
1517  string drsFileName = "";
1518  uint32_t numRowsPerTile = 100;
1519  bool displayText=true;
1520 
1521  //parse configuration
1522  if (conf.Get<bool>("quiet")) displayText = false;
1523  const vector<string> inputFileNameVec = conf.Vec<string>("inputFile");
1524  if (inputFileNameVec.size() != 1)
1525  {
1526  cout << "Error: ";
1527  if (inputFileNameVec.size() == 0) cout << "no";
1528  else cout << inputFileNameVec.size();
1529  cout << " input file(s) given. Expected one. Aborting. Input:" << endl;;
1530  for (unsigned int i=0;i<inputFileNameVec.size(); i++)
1531  cout << inputFileNameVec[i] << endl;
1532  return -1;
1533  }
1534 
1535  //Assign the input filename
1536  fileNameIn = inputFileNameVec[0];
1537 
1538  //Check if we have a drs calib too
1539  if (conf.Has("drs")) drsFileName = conf.Get<string>("drs");
1540 
1541  //Should we verify the data ?
1542  bool verifyDataPlease = false;
1543  if (conf.Has("verify")) verifyDataPlease = conf.Get<bool>("verify");
1544 
1545 
1546  //should we use a specific output filename ?
1547  if (conf.Has("output"))
1548  fileNameOut = conf.Get<string>("output");
1549  else
1550  {
1551  size_t pos = fileNameIn.find(".fits");
1552  if (pos == string::npos)
1553  {
1554  cout << "ERROR: input file does not seems ot be fits. Aborting." << endl;
1555  return -1;
1556  }
1557  fileNameOut = fileNameIn + ".fz";
1558  }
1559 
1560 
1561  //should we use specific compression on some columns ?
1562  const vector<string> columnsCompression = conf.Vec<string>("compression");
1563 
1564  //split up values between column names and compression scheme
1565  vector<std::pair<string, string>> compressions;
1566  for (unsigned int i=0;i<columnsCompression.size();i++)
1567  {
1568  size_t pos = columnsCompression[i].find_first_of("=");
1569  if (pos == string::npos)
1570  {
1571  cout << "ERROR: Something wrong occured while parsing " << columnsCompression[i] << ". Aborting." << endl;
1572  return -1;
1573  }
1574  string comp = columnsCompression[i].substr(pos+1);
1575  if (comp != "UNCOMPRESSED" && comp != "AMPLITUDE" && comp != "HUFFMAN" &&
1576  comp != "SMOOTHMAN" && comp != "INT_WAVELET")
1577  {
1578  cout << "Unkown compression scheme requested (" << comp << "). Aborting." << endl;
1579  return -1;
1580  }
1581  compressions.push_back(make_pair(columnsCompression[i].substr(0, pos), comp));
1582  }
1583 
1584  //How many rows per tile should we use ?
1585  if (conf.Has("rowPerTile")) numRowsPerTile = conf.Get<unsigned int>("rowPerTile");
1586 
1587  /************************************************************************************
1588  * Done reading configuration. Open relevant files
1589  ************************************************************************************/
1590 
1591  //Open input's fits file
1592  factfits inFile(fileNameIn);
1593 
1594  if (inFile.IsCompressedFITS())
1595  {
1596  cout << "ERROR: input file is already a compressed fits. Cannot be compressed again: Aborting." << endl;
1597  return -1;
1598  }
1599 
1600  //decide how many tiles should be put in the compressed file
1601  uint32_t originalNumRows = inFile.GetNumRows();
1602  uint32_t numTiles = (originalNumRows%numRowsPerTile) ? (originalNumRows/numRowsPerTile)+1 : originalNumRows/numRowsPerTile;
1603  CompressedFitsWriter outFile(numTiles, numRowsPerTile);
1604 
1605  //should we use a specific number of threads for compressing ?
1606  unsigned int numThreads = 1;
1607  if (conf.Has("threads"))
1608  {
1609  numThreads = conf.Get<unsigned int>("threads");
1610  outFile.setNumWorkingThreads(numThreads);
1611  }
1612 
1613  if (!outFile.open(fileNameOut))
1614  {
1615  cout << "Error: could not open " << fileNameOut << " for writing" << endl;
1616  return -1;
1617  }
1618 
1619  //Because the file to open MUST be given by the constructor, I must use a pointer instead
1620  factfits* drsFile = NULL;
1621  //try to open the Drs file. If any.
1622  if (drsFileName != "")
1623  {
1624  try
1625  {
1626  drsFile = new factfits(drsFileName);
1627  }
1628  catch (...)
1629  {
1630  cout << "Error: could not open " << drsFileName << " for calibration" << endl;
1631  return -1;
1632  }
1633  }
1634 
1635  if (displayText)
1636  {
1637  cout << endl;
1638  cout << "**********************" << endl;
1639  cout << "Will compress from : " << fileNameIn << endl;
1640  cout << "to : " << fileNameOut << endl;
1641  if (drsFileName != "")
1642  cout << "while calibrating with: " << drsFileName << endl;
1643  cout << "Compression will use : " << numThreads << " worker threads" << endl;
1644  cout << "Data will be verified : ";
1645  if (verifyDataPlease)
1646  cout << "yes" << endl;
1647  else
1648  cout << "no (WARNING !)" << endl;
1649  cout << "**********************" << endl;
1650  cout << endl;
1651  }
1652 
1653  /************************************************************************************
1654  * Done opening input files. Allocate memory and configure output file
1655  ************************************************************************************/
1656 
1657  //allocate the buffer for temporary storage of each read/written row
1658  uint32_t rowWidth = inFile.GetUInt("NAXIS1");
1659  char* buffer = new char[rowWidth + 12];
1660  memset(buffer, 0, 4);
1661  buffer = buffer+4;
1662 
1663  //get the source columns
1664  const fits::Table::Columns& columns = inFile.GetColumns();
1665  const fits::Table::SortedColumns& sortedColumns = inFile.GetSortedColumns();
1666  if (displayText)
1667  cout << "Input file has " << columns.size() << " columns and " << inFile.GetNumRows() << " rows" << endl;
1668 
1669  //Add columns.
1670  uint32_t totalRowWidth = 0;
1671  for (uint32_t i=0;i<sortedColumns.size(); i++)
1672  {
1673  //get column name
1674  ostringstream str;
1675  str << "TTYPE" << i+1;
1676  string colName = inFile.GetStr(str.str());
1677  if (displayText)
1678  {
1679  cout << "Column " << colName;
1680  for (uint32_t j=colName.size();j<21;j++)
1681  cout << " ";
1682  cout << " -> ";
1683  }
1684 
1685  //get header structures
1686  BlockHeader rawHeader;
1687  BlockHeader smoothmanHeader(0, FITS::kOrderByRow, 2);
1688  vector<uint16_t> rawProcessings(1);
1689  rawProcessings[0] = FITS::kFactRaw;
1690  vector<uint16_t> smoothmanProcessings(2);
1691  smoothmanProcessings[0] = FITS::kFactSmoothing;
1692  smoothmanProcessings[1] = FITS::kFactHuffman16;
1693 // smoothmanProcessings[2] = FACT_RAW;
1694 
1695  totalRowWidth += sortedColumns[i].bytes;
1696 
1697  //first lets see if we do have an explicit request
1698  bool explicitRequest = false;
1699  for (unsigned int j=0;j<compressions.size();j++)
1700  {
1701  if (compressions[j].first == colName)
1702  {
1703  explicitRequest = true;
1704  if (displayText) cout << compressions[j].second << endl;
1705  if (compressions[j].second == "UNCOMPRESSED")
1706  outFile.addColumn(CompressedFitsFile::ColumnEntry(colName, sortedColumns[i].type, sortedColumns[i].num, rawHeader, rawProcessings));
1707  if (compressions[j].second == "SMOOTHMAN")
1708  outFile.addColumn(CompressedFitsFile::ColumnEntry(colName, sortedColumns[i].type, sortedColumns[i].num, smoothmanHeader, smoothmanProcessings));
1709  break;
1710  }
1711  }
1712 
1713  if (explicitRequest) continue;
1714 
1715  if (colName != "Data")
1716  {
1717  if (displayText) cout << "UNCOMPRESSED" << endl;
1718  outFile.addColumn(CompressedFitsFile::ColumnEntry(colName, sortedColumns[i].type, sortedColumns[i].num, rawHeader, rawProcessings));
1719  }
1720  else
1721  {
1722  if (displayText) cout << "SMOOTHMAN" << endl;
1723  outFile.addColumn(CompressedFitsFile::ColumnEntry(colName, sortedColumns[i].type, sortedColumns[i].num, smoothmanHeader, smoothmanProcessings));
1724  }
1725  }
1726 
1727  //translate original header entries to their Z-version
1728  const fits::Table::Keys& header = inFile.GetKeys();
1729  for (fits::Table::Keys::const_iterator i=header.begin(); i!= header.end(); i++)
1730  {
1731  string k = i->first;//header[i].key();
1732  if (k == "XTENSION" || k == "BITPIX" || k == "PCOUNT" || k == "GCOUNT" || k == "TFIELDS")
1733  continue;
1734  if (k == "CHECKSUM")
1735  {
1736  outFile.setHeaderKey(CompressedFitsFile::HeaderEntry("ZCHKSUM", i->second.value, i->second.comment));
1737  continue;
1738  }
1739  if (k == "DATASUM")
1740  {
1741  outFile.setHeaderKey(CompressedFitsFile::HeaderEntry("ZDTASUM", i->second.value, i->second.comment));
1742  continue;
1743  }
1744  k = k.substr(0,5);
1745  if (k == "TTYPE" || k == "TFORM")
1746  {
1747  string tmpKey = i->second.fitsString;
1748  tmpKey[0] = 'Z';
1749  outFile.setHeaderKey(tmpKey);
1750  continue;
1751  }
1752  if (k == "NAXIS")
1753  continue;
1754  outFile.setHeaderKey(i->second.fitsString);
1755 // cout << i->first << endl;
1756  }
1757 
1758  outFile.setHeaderKey(CompressedFitsFile::HeaderEntry("RAWSUM", " 0", "Checksum of raw littlen endian data"));
1759 
1760  //deal with the DRS calib
1761  int16_t* drsCalib16 = NULL;
1762 
1763  //load the drs calib. data
1764  int32_t startCellOffset = -1;
1765  if (drsFileName != "")
1766  {
1767  drsCalib16 = new int16_t[1440*1024];
1768  float* drsCalibFloat = NULL;
1769  try
1770  {
1771  drsCalibFloat = reinterpret_cast<float*>(drsFile->SetPtrAddress("BaselineMean"));
1772  }
1773  catch (...)
1774  {
1775  cout << "Could not find column BaselineMean in drs calibration file " << drsFileName << ". Aborting" << endl;
1776  return -1;
1777  }
1778 
1779  //read the calibration and calculate its integer value
1780  drsFile->GetNextRow();
1781  for (uint32_t i=0;i<1440*1024;i++)
1782  drsCalib16[i] = (int16_t)(drsCalibFloat[i]*4096.f/2000.f);
1783 
1784 
1785  //get the start cells offsets
1786  for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end(); it++)
1787  if (it->first == "StartCellData")
1788  {
1789  startCellOffset = it->second.offset;
1790  if (it->second.type != 'I')
1791  {
1792  cout << "Wrong type for the StartCellData Column: " << it->second.type << " instead of I expected"<< endl;
1793  return -1;
1794  }
1795  }
1796 
1797  if (startCellOffset == -1)
1798  {
1799  cout << "WARNING: Could not find StartCellData in input file " << fileNameIn << ". Doing it uncalibrated"<< endl;
1800  }
1801  else
1802  {
1803  //assign it to the ouput file
1804  outFile.setDrsCalib(drsCalib16);
1805  }
1806  }
1807 
1808  /************************************************************************************
1809  * Done configuring compression. Do the real job now !
1810  ************************************************************************************/
1811 
1812  if (displayText) cout << "Converting file..." << endl;
1813 
1814  int numSlices = -1;
1815  int32_t dataOffset = -1;
1816 
1817  //Get the pointer to the column that must be drs-calibrated
1818  for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end(); it++)
1819  if (it->first == "Data")
1820  {
1821  numSlices = it->second.num;
1822  dataOffset = it->second.offset;
1823  }
1824  if (numSlices % 1440 != 0)
1825  {
1826  cout << "seems like the number of samples is not a multiple of 1440. Aborting." << endl;
1827  return -1;
1828  }
1829  if (dataOffset == -1)
1830  {
1831  cout << "Could not find the column Data in the input file. Aborting." << endl;
1832  return -1;
1833  }
1834 
1835  numSlices /= 1440;
1836 
1837  //set pointers to the readout data to later be able to gather it to "buffer".
1838  vector<void*> readPointers;
1839  vector<int32_t> readOffsets;
1840  vector<int32_t> readElemSize;
1841  vector<int32_t> readNumElems;
1842  for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end(); it++)
1843  {
1844  readPointers.push_back(inFile.SetPtrAddress(it->first));
1845  readOffsets.push_back(it->second.offset);
1846  readElemSize.push_back(it->second.size);
1847  readNumElems.push_back(it->second.num);
1848  }
1849 
1850  Checksum rawsum;
1851  //Convert each row one after the other
1852  ostringstream wrongChannels;
1853  map<int, int> wrongChannelsMap;
1854  map<int, int> wrongChannelsLastValues;
1855  for (uint32_t i=0;i<1440;i++)
1856  {
1857  wrongChannelsMap[i] = 0;
1858  wrongChannelsLastValues[i] = 0;
1859  }
1860  for (uint32_t i=0;i<inFile.GetNumRows();i++)
1861  {
1862  if (displayText) cout << "\r Row " << i+1 << flush;
1863  if (!inFile.GetNextRow())
1864  {
1865  cout << "ERROR: file has less rows than advertized. aborting" << endl;
1866  exit(0);
1867  }
1868  //copy from inFile internal structures to buffer
1869  int32_t count=0;
1870  for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end();it++)
1871  {
1872  memcpy(&buffer[readOffsets[count]], readPointers[count], readElemSize[count]*readNumElems[count]);
1873  count++;
1874  }
1875 
1876  char* checkSumPointer = buffer;
1877  const int chkOffset = (i*totalRowWidth)%4;
1878  checkSumPointer -= chkOffset;
1879  uint32_t sizeToChecksum = totalRowWidth + chkOffset;
1880  if (sizeToChecksum%4 != 0)
1881  {
1882  int32_t extraBytes = 4 - (sizeToChecksum%4);
1883  memset(checkSumPointer+sizeToChecksum, 0, extraBytes);
1884  sizeToChecksum += extraBytes;
1885  }
1886  rawsum.add(checkSumPointer, sizeToChecksum, false);
1887 
1888  if (startCellOffset != -1)
1889  {//drs calibrate this data
1890  for (int j=0;j<1440;j++)
1891  {
1892  const int thisStartCell = reinterpret_cast<int16_t*>(&buffer[startCellOffset])[j];
1893  if (thisStartCell > 1023)
1894  {
1895  wrongChannelsMap[j]++;
1896  wrongChannelsLastValues[j] = thisStartCell;
1897  wrongChannels << j;
1898  }
1899  if (thisStartCell < 0) continue;
1900  for (int k=0;k<numSlices;k++)
1901  reinterpret_cast<int16_t*>(&buffer[dataOffset])[numSlices*j + k] -= drsCalib16[1024*j + (thisStartCell+k)%1024];
1902  }
1903  }
1904  outFile.writeBinaryRow(buffer);
1905  };
1906 
1907  if (wrongChannels.str() != "")
1908  {
1909  cout << "ERROR: Wrong channels: ";
1910  for (uint32_t i=0;i<1440;i++)
1911  {
1912  if (wrongChannelsMap[i] != 0)
1913  cout << i << "(" << wrongChannelsMap[i] << "|" << wrongChannelsLastValues[i] << ") ";
1914  }
1915  cout << endl;
1916  exit(-1);
1917  }
1918  ostringstream strSum;
1919  strSum << rawsum.val();
1920  outFile.setHeaderKey(CompressedFitsFile::HeaderEntry("RAWSUM", strSum.str(), "Checksum of raw littlen endian data"));
1921 
1922  //Get table name for later use in case the compressed file is to be verified
1923  string tableName = inFile.GetStr("EXTNAME");
1924 
1925  if (displayText) cout << endl << "Done. Flushing output file..." << endl;
1926 
1927  inFile.close();
1928  if (!outFile.close())
1929  {
1930  cout << "Something went wrong while writing the catalog: negative index" << endl;
1931  return false;
1932  }
1933 
1934  if (drsCalib16 != NULL)
1935  delete[] drsCalib16;
1936 
1937  if (displayText) cout << "Done." << endl;
1938 
1939  /************************************************************************************
1940  * Actual job done. Should we verify what we did ?
1941  ************************************************************************************/
1942 
1943  if (verifyDataPlease)
1944  {
1945  if (displayText) cout << "Now verify data..." << endl;
1946  }
1947  else
1948  return 0;
1949 
1950  //get a compressed reader
1951 //TEMP try to copy the file too
1952 // string copyName("/gpfs/scratch/fact/etienne/copyFile.fz");
1953 // string copyName(fileNameOut+".copy");
1954  string copyName("");
1955  factfits verifyFile(fileNameOut, copyName, tableName, false);
1956 
1957  //and the header of the compressed file
1958  const fits::Table::Keys& header2 = verifyFile.GetKeys();
1959 
1960  //get a non-compressed writer
1961  ofits reconstructedFile;
1962 
1963  //figure out its name: /dev/null unless otherwise specified
1964  string reconstructedName = fileNameOut+".recons";
1965  reconstructedName = "/dev/null";
1966  reconstructedFile.open(reconstructedName.c_str(), false);
1967 
1968  //reconstruct the original columns from the compressed file.
1969  string origChecksumStr;
1970  string origDatasum;
1971 
1972  //reset tablename value so that it is re-read from compressed table's header
1973  tableName = "";
1974 
1975  /************************************************************************************
1976  * Reconstruction setup done. Rebuild original header
1977  ************************************************************************************/
1978 
1979  //re-tranlate the keys
1980  for (fits::Table::Keys::const_iterator it=header2.begin(); it!= header2.end(); it++)
1981  {
1982  string k = it->first;
1983  if (k == "XTENSION" || k == "BITPIX" || k == "PCOUNT" || k == "GCOUNT" ||
1984  k == "TFIELDS" || k == "ZTABLE" || k == "ZNAXIS1" || k == "ZNAXIS2" ||
1985  k == "ZHEAPPTR" || k == "ZPCOUNT" || k == "ZTILELEN" || k == "THEAP" ||
1986  k == "CHECKSUM" || k == "DATASUM" || k == "FCTCPVER" || k == "ZHEAP")
1987  {
1988  continue;
1989  }
1990 
1991  if (k == "ZCHKSUM")
1992  {
1993  reconstructedFile.SetKeyComment("CHECKSUM", it->second.comment);
1994  origChecksumStr = it->second.value;
1995  continue;
1996  }
1997  if (k == "RAWSUM")
1998  {
1999  continue;
2000  }
2001 
2002  if (k == "ZDTASUM")
2003  {
2004  reconstructedFile.SetKeyComment("DATASUM", it->second.comment);
2005  origDatasum = it->second.value;
2006  continue;
2007  }
2008 
2009  if (k == "EXTNAME")
2010  {
2011  tableName = it->second.value;
2012  }
2013 
2014  k = k.substr(0,5);
2015 
2016  if (k == "TTYPE")
2017  {//we have an original column name here.
2018  //manually deal with these in order to preserve the ordering (easier than re-constructing yet another list on the fly)
2019  continue;
2020  }
2021 
2022  if (k == "TFORM" || k == "NAXIS" || k == "ZCTYP" )
2023  {
2024  continue;
2025  }
2026 
2027  if (k == "ZFORM" || k == "ZTYPE")
2028  {
2029  string tmpKey = it->second.fitsString;
2030  tmpKey[0] = 'T';
2031  reconstructedFile.SetKeyFromFitsString(tmpKey);
2032  continue;
2033  }
2034 
2035  reconstructedFile.SetKeyFromFitsString(it->second.fitsString);
2036  }
2037 
2038  if (tableName == "")
2039  {
2040  cout << "Error: table name from file " << fileNameOut << " could not be found. Aborting" << endl;
2041  return -1;
2042  }
2043 
2044  //Restore the original columns
2045  for (uint32_t numCol=1; numCol<10000; numCol++)
2046  {
2047  ostringstream str;
2048  str << numCol;
2049  if (!verifyFile.HasKey("TTYPE"+str.str())) break;
2050 
2051  string ttype = verifyFile.GetStr("TTYPE"+str.str());
2052  string tform = verifyFile.GetStr("ZFORM"+str.str());
2053  char type = tform[tform.size()-1];
2054  string number = tform.substr(0, tform.size()-1);
2055  int numElems = atoi(number.c_str());
2056 
2057  if (number == "") numElems=1;
2058 
2059  reconstructedFile.AddColumn(numElems, type, ttype, "", "", false);
2060  }
2061 
2062  reconstructedFile.WriteTableHeader(tableName.c_str());
2063 
2064  /************************************************************************************
2065  * Original header restored. Do the data
2066  ************************************************************************************/
2067 
2068  //set pointers to the readout data to later be able to gather it to "buffer".
2069  readPointers.clear();
2070  readOffsets.clear();
2071  readElemSize.clear();
2072  readNumElems.clear();
2073  for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end(); it++)
2074  {
2075  readPointers.push_back(verifyFile.SetPtrAddress(it->first));
2076  readOffsets.push_back(it->second.offset);
2077  readElemSize.push_back(it->second.size);
2078  readNumElems.push_back(it->second.num);
2079  }
2080 
2081  //do the actual reconstruction work
2082  uint32_t i=1;
2083  while (i<=verifyFile.GetNumRows() && verifyFile.GetNextRow())
2084  {
2085  int count=0;
2086  for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end();it++)
2087  {
2088  memcpy(&buffer[readOffsets[count]], readPointers[count], readElemSize[count]*readNumElems[count]);
2089  count++;
2090  }
2091  if (displayText) cout << "\r Row " << i << flush;
2092  reconstructedFile.WriteRow(buffer, rowWidth);
2093  i++;
2094  }
2095 
2096  if (displayText) cout << endl;
2097 
2098  //close reconstruction input and output
2099 // Do NOT close the verify file, otherwise data cannot be flushed to copy file
2100 // verifyFile.close();
2101  if (!verifyFile.IsFileOk())
2102  cout << "ERROR: file checksums seems wrong" << endl;
2103 
2104  if (!reconstructedFile.close())
2105  {
2106  cout << "ERROR: disk probably full..." << endl;
2107  return -1;
2108  }
2109 
2110  //get original and reconstructed checksum and datasum
2111  std::pair<string, int> origChecksum = make_pair(origChecksumStr, atoi(origDatasum.c_str()));
2112  std::pair<string, int> newChecksum = reconstructedFile.GetChecksumData();
2113 
2114  //verify that no mistake was made
2115  if (origChecksum.second != newChecksum.second)
2116  {
2117  cout << "ERROR: datasums are NOT identical: " << (uint32_t)(origChecksum.second) << " vs " << (uint32_t)(newChecksum.second) << endl;
2118  return -1;
2119  }
2120  if (origChecksum.first != newChecksum.first)
2121  {
2122  cout << "WARNING: checksums are NOT Identical: " << origChecksum.first << " vs " << newChecksum.first << endl;
2123  }
2124  else
2125  {
2126  if (true) cout << "Ok" << endl;
2127  }
2128 
2129  buffer = buffer-4;
2130  delete[] buffer;
2131  return 0;
2132 }
std::vector< Column > SortedColumns
Definition: fits.h:114
void * SetPtrAddress(const std::string &name)
Definition: fits.h:886
std::map< std::string, Column > Columns
Definition: fits.h:113
void printHelp()
std::pair< std::string, int > GetChecksumData()
Definition: ofits.h:1012
int i
Definition: db_dim_client.c:21
int64_t second
offset of this column in the tile, from the start of the heap area
Definition: zofits.h:27
char str[80]
Definition: test_client.c:7
bool SetKeyComment(const std::string &key, const std::string &comment)
Definition: ofits.h:430
virtual bool AddColumn(uint32_t cnt, char typechar, const std::string &name, const std::string &unit, const std::string &comment="", bool addHeaderKeys=true)
Definition: ofits.h:596
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
uint32_t val() const
Definition: checksum.h:20
BlockHeader(uint64_t s=0, char o=kOrderByRow, unsigned char n=1)
Definition: FITS.h:76
bool GetNextRow(bool check=true)
Definition: fits.h:851
virtual void open(const char *filename, bool addEXTNAMEKey=true)
Definition: ofits.h:390
Definition: ofits.h:29
int type
std::map< std::string, Entry > Keys
Definition: fits.h:112
virtual bool close()
Definition: ofits.h:984
Commandline parsing, resource file parsing and database access.
Definition: Configuration.h:9
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int count
Definition: db_dim_server.c:18
void printUsage()
void setupConfiguration(Configuration &conf)
virtual bool WriteTableHeader(const char *name="DATA")
Definition: ofits.h:844
bool add(const char *buf, size_t len, bool big_endian=true)
Definition: checksum.h:49
virtual bool WriteRow(const void *ptr, size_t cnt, bool byte_swap=true)
Definition: ofits.h:884

+ Here is the call graph for this function: