This looks for a suitable table in the fits file, i.e. that corresponds to the name and column names. (no format check yet)
210 Error(
"FitsFile::OpenNewTable - No file open.");
216 Error(
"FitsFile::OpenNewTable - Table already open.");
221 fFile->read(vector<string>(1, tableName));
224 const multimap<string, CCfits::ExtHDU *> &extMap =
fFile->extension();
226 for (
int i=0;
i<maxtry;
i++)
236 const string tname = str.str();
238 const multimap<string,CCfits::ExtHDU*>::const_iterator it = extMap.find(tname);
241 if (it == extMap.end())
251 CCfits::Table *table =
dynamic_cast<CCfits::Table*
>(it->second);
256 Error(
"HDU '"+tname+
"' found in file, but it is not a proper CCfits::Table.");
262 table->makeThisCurrent();
284 CCfits::BinTable* bTable =
dynamic_cast<CCfits::BinTable*
>(table);
287 Error(
"Table '"+tableName+
"' found in '"+
fFile->name()+
"' is not a binary table.");
292 vector<string> colName;
293 bTable->readData(
true, colName);
297 const map<string,CCfits::Column*> &cMap = table->column();
300 for (map<string, CCfits::Column*>::const_iterator mapIt = cMap.begin(); mapIt != cMap.end(); mapIt++)
303 for (
unsigned int ii=0;ii<
fColNames.size();ii++)
308 if (mapIt->second->format() !=
fColTypes[ii])
317 Error(
"Column "+mapIt->first+
" only exist in written file");
322 for (
unsigned int ii=0;ii<
fColNames.size();ii++)
325 for (map<string, CCfits::Column*>::const_iterator mapIt = cMap.begin(); mapIt != cMap.end(); mapIt++)
330 if (
fColTypes[ii] != mapIt->second->format())
339 Error(
"Column "+
fColNames[ii]+
" only exist in requested description");
344 for (map<string,CCfits::Column*>::const_iterator cMapIt = cMap.begin();
345 cMapIt != cMap.end(); cMapIt++)
347 if (!cMapIt->second->isRead())
349 Error(
"Reading column '"+cMapIt->first+
"' back from '"+
fFile->name()+
"' failed.");
362 str <<
"FitsFile::OpenNewTable failed - more than " << maxtry <<
" tables tried." << endl;
size_t fNumRows
The pointer to the CCfits binary table.
CCfits::Table * fTable
The pointer to the CCfits FITS file.
int Error(const std::string &str)
std::vector< std::string > fColTypes
bool OpenTable(const string &tablename)
std::vector< std::string > fColNames