202 string fileNameToLoad =
"test.fits";
203 string tableNameToLoad =
"FACT-TIME_ETIENNE";
205 vector<string> columnsToDump;
206 columnsToDump.push_back(
"Data0");
207 columnsToDump.push_back(
"Data1");
209 string outputFile =
"output.txt";
212 CCfits::FITS* file = NULL;
215 file =
new CCfits::FITS(fileNameToLoad);
217 catch (CCfits::FitsException e)
219 cout <<
"Could not open FITS file " << fileNameToLoad <<
" reason: " << e.message() << endl;
223 CCfits::Table* table;
224 const multimap< string, CCfits::ExtHDU * > extMap = file->extension();
225 if (extMap.find(tableNameToLoad) == extMap.end())
227 cout <<
"Could not open table " << tableNameToLoad <<
". Tables in file are: " << endl;
228 for (std::multimap<string, CCfits::ExtHDU*>::const_iterator it=extMap.begin(); it != extMap.end(); it++)
229 cout << it->first <<
" ";
235 table =
dynamic_cast<CCfits::Table*
>(extMap.find(tableNameToLoad)->second);
238 map<string, CCfits::Column*> colMap = table->column();
239 if (columnsToDump.size() != 0)
241 for (vector<string>::iterator it=columnsToDump.begin(); it!= columnsToDump.end(); it++)
243 if (colMap.find(*it) == colMap.end())
245 cout <<
"Config-given dump list contains invalid entry " << *it << endl;
252 table->makeThisCurrent();
254 int size = offsets[offsets.size()-1];
256 unsigned char* fitsBuffer =
new unsigned char[
size];
258 ofstream targetFile(outputFile.c_str());
261 for (
int i=1;
i<=table->rows();
i++)
263 fits_read_tblbytes(file->fitsPointer(),
i, 1,
size, fitsBuffer, &status);
266 cout <<
"An error occurred while reading fits row #" <<
i <<
" error code: " << status << endl;
267 for (
unsigned int j=0;j<offsets.size(); j++)
268 cout << offsets[j] <<
" ";
vector< int > CalculateBufferSize(map< string, CCfits::Column * > &colMap)
void writeValuesFromFits(vector< int > &offsets, ofstream &targetFile, unsigned char *fitsBuffer, vector< string > dumpList, map< string, CCfits::Column * > &colMap)