Alexandria  2.14.1
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Functions | Variables
Euclid::Table Namespace Reference

Classes

class  StreamRewinder
 This class gets a stream as argument during construction and when it is deleted it sets the position of the stream back to where it was during the constructor call. More...
 
class  AsciiReader
 TableReader implementation for reading ASCII tables from streams. More...
 
class  AsciiWriter
 TableWriter implementation for writing ASCII tables to streams. More...
 
class  CastVisitor
 
class  CastVisitor< std::string >
 
class  CastVisitor< double >
 
class  CastVisitor< float >
 
class  CastVisitor< int64_t >
 
class  CastVisitor< int32_t >
 
class  CastVisitor< std::vector< VectorType > >
 
class  ColumnDescription
 Contains the description of a specific column of a Table. More...
 
class  ColumnInfo
 Provides information about the columns of a Table. More...
 
class  FitsReader
 TableReader implementation for reading FITS tables. More...
 
class  FitsWriter
 TableWriter implementation for writing tables in FITS format. More...
 
class  Row
 Represents one row of a Table. More...
 
class  Table
 Represents a table. More...
 
class  TableReader
 Interface for classes reading tables. More...
 
class  TableWriter
 Interface for classes writing tables. More...
 

Functions

static std::string _peekLine (std::istream &in)
 
size_t countColumns (std::istream &in, const std::string &comment)
 Returns the number of whitespace separated tokens of the first non commented line. More...
 
std::type_index keywordToType (const std::string &keyword)
 
std::map< std::string,
ColumnDescription
autoDetectColumnDescriptions (std::istream &in, const std::string &comment)
 Reads the column descriptions of the given stream. More...
 
std::vector< std::stringautoDetectColumnNames (std::istream &in, const std::string &comment, size_t columns_number)
 Reads the column names of the given stream. More...
 
Row::cell_type convertToCellType (const std::string &value, std::type_index type)
 Converts the given value to a Row::cell_type of the given type. More...
 
bool hasNextRow (std::istream &in, const std::string &comment)
 
std::size_t countRemainingRows (std::istream &in, const std::string &comment)
 
std::string typeToKeyword (std::type_index type)
 Converts a type to its string representation. More...
 
std::vector< size_t > calculateColumnLengths (const Table &table)
 Calculates the sizes in characters each column of the table needs. More...
 
static CCfits::HDU & _readKeys (CCfits::HDU &hdu)
 
std::vector< std::stringautoDetectColumnNames (const CCfits::Table &table_hdu)
 Reads the column names of the given table HDU. More...
 
std::type_index asciiFormatToType (const std::string &format)
 
std::type_index binaryFormatToType (const std::string &format, const std::vector< size_t > &shape)
 
std::vector< size_t > parseTDIM (const std::string &tdim)
 
std::vector< std::type_indexautoDetectColumnTypes (const CCfits::Table &table_hdu)
 Reads the column types of the given table HDU. More...
 
std::vector< std::stringautoDetectColumnUnits (const CCfits::Table &table_hdu)
 Reads the column units based on the TUNITn keyword. More...
 
std::vector< std::stringautoDetectColumnDescriptions (const CCfits::Table &table_hdu)
 Reads the column descriptions based on the TDESCn keyword. More...
 
template<typename T >
std::vector< Row::cell_typeconvertScalarColumn (CCfits::Column &column, long first, long last)
 
template<typename T >
std::vector< Row::cell_typeconvertVectorColumn (CCfits::Column &column, long first, long last)
 
template<typename T >
std::vector< Row::cell_typeconvertNdArrayColumn (CCfits::Column &column, long first, long last)
 
std::vector< Row::cell_typetranslateColumn (CCfits::Column &column, std::type_index type)
 Returns a vector representing the given FITS table column data, converted to the requested type. More...
 
std::vector< Row::cell_typetranslateColumn (CCfits::Column &column, std::type_index type, long first, long last)
 
template<typename T >
std::string scientificFormat (T value)
 
size_t maxWidth (const Table &table, size_t column_index)
 
size_t maxWidthScientific (const Table &table, size_t column_index)
 
std::vector< std::stringgetAsciiFormatList (const Table &table)
 Returns a vector with strings representing the FITS ASCII table formats for the given table. More...
 
template<typename T >
size_t vectorSize (const Table &table, size_t column_index)
 
template<typename T >
size_t ndArraySize (const Table &table, size_t column_index)
 
std::vector< std::stringgetBinaryFormatList (const Table &table)
 Returns a vector with strings representing the FITS binary table formats for the given table. More...
 
template<typename T >
std::vector< T > createColumnData (const Euclid::Table::Table &table, size_t column_index)
 
template<typename T >
std::vector< std::valarray< T > > createVectorColumnData (const Euclid::Table::Table &table, size_t column_index)
 
template<typename T >
std::vector< T > createSingleValueVectorColumnData (const Euclid::Table::Table &table, size_t column_index)
 
template<typename T >
std::vector< std::valarray< T > > createNdArrayColumnData (const Euclid::Table::Table &table, size_t column_index)
 
template<typename T >
std::vector< T > createSingleNdArrayVectorColumnData (const Euclid::Table::Table &table, size_t column_index)
 
template<typename T >
void populateVectorColumn (const Table &table, size_t column_index, CCfits::ExtHDU &table_hdu, long first_row)
 
template<typename T >
void populateNdArrayColumn (const Table &table, size_t column_index, CCfits::ExtHDU &table_hdu, long first_row)
 
std::string getTDIM (const Table &table, size_t column_index)
 
void populateColumn (const Table &table, size_t column_index, CCfits::ExtHDU &table_hdu, long first_row)
 
std::shared_ptr< ColumnInfocreateColumnInfo (const std::vector< std::string > &names, const std::vector< std::type_index > &types, const std::vector< std::string > &units, const std::vector< std::string > &descriptions)
 Creates a ColumnInfo object from the given names and types. More...
 

Variables

static Elements::Logging logger = Elements::Logging::getLogger("AsciiReader")
 

Function Documentation

static std::string Euclid::Table::_peekLine ( std::istream in)
static

Definition at line 175 of file AsciiReader.cpp.

References std::istream::seekg(), and std::istream::tellg().

Referenced by Euclid::Table::AsciiReader::getComment().

Here is the call graph for this function:

static CCfits::HDU& Euclid::Table::_readKeys ( CCfits::HDU &  hdu)
static

Definition at line 45 of file FitsReader.cpp.

std::type_index Euclid::Table::asciiFormatToType ( const std::string format)

Definition at line 48 of file FitsReaderHelper.cpp.

Referenced by autoDetectColumnTypes().

ELEMENTS_API std::map< std::string, ColumnDescription > Euclid::Table::autoDetectColumnDescriptions ( std::istream in,
const std::string comment 
)

Reads the column descriptions of the given stream.

For more information about the auto-detection rules see the constructor of AsciiReader. When the method returns, the given stream is positioned at the same position like before the method was called.

Parameters
inThe stream to read the column names from
commentThe comment pattern
Returns
The column descriptions from the stream comments
Exceptions
Elements::Exceptionif there are duplicate column names
Elements::Exceptionif any of the types is not one of the valid keywords

Definition at line 111 of file AsciiReaderHelper.cpp.

References std::string::begin(), std::map< K, T >::count(), std::map< K, T >::emplace(), std::string::empty(), std::string::end(), std::string::erase(), std::forward_as_tuple(), keywordToType(), and std::stringstream::str().

Referenced by Euclid::Table::FitsReader::readColumnInfo(), and Euclid::Table::AsciiReader::readColumnInfo().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::string > Euclid::Table::autoDetectColumnDescriptions ( const CCfits::Table &  table_hdu)

Reads the column descriptions based on the TDESCn keyword.

Definition at line 152 of file FitsReaderHelper.cpp.

References std::string::find(), and std::to_string().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::string > Euclid::Table::autoDetectColumnNames ( const CCfits::Table &  table_hdu)

Reads the column names of the given table HDU.

For more information about the column naming see the constructor of FitsReader.

Parameters
table_hduThe HDU to read the columns from
Returns
the column names

Definition at line 36 of file FitsReaderHelper.cpp.

References std::string::empty(), std::move(), and std::to_string().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::string > Euclid::Table::autoDetectColumnNames ( std::istream in,
const std::string comment,
size_t  columns_number 
)

Reads the column names of the given stream.

For more information about the auto-detection rules see the constructor of AsciiReader. When the method returns, the given stream is positioned at the same position like before the method was called.

Parameters
inThe stream to read the column names from
commentThe comment pattern
columns_numberThe number of columns
Returns
The auto-detected names of the columns
Exceptions
Elements::Exceptionif there are duplicate column names

Definition at line 178 of file AsciiReaderHelper.cpp.

References std::string::empty(), std::string::erase(), std::string::find(), logger, std::move(), std::string::substr(), std::to_string(), and Elements::Logging::warn().

Referenced by Euclid::Table::FitsReader::readColumnInfo(), and Euclid::Table::AsciiReader::readColumnInfo().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::type_index > Euclid::Table::autoDetectColumnTypes ( const CCfits::Table &  table_hdu)

Reads the column types of the given table HDU.

For more information about the supported types and the type conversion see the FitsReader::read() method.

Parameters
table_hduThe HDU to read the types from
Returns
the column types
Exceptions
Elements::Exceptionif a column type is not supported

Definition at line 129 of file FitsReaderHelper.cpp.

References asciiFormatToType(), binaryFormatToType(), parseTDIM(), and std::vector< T >::push_back().

Referenced by Euclid::Table::FitsReader::readColumnInfo().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::string > Euclid::Table::autoDetectColumnUnits ( const CCfits::Table &  table_hdu)

Reads the column units based on the TUNITn keyword.

Definition at line 144 of file FitsReaderHelper.cpp.

References std::vector< T >::push_back().

Referenced by Euclid::Table::FitsReader::readColumnInfo().

Here is the call graph for this function:

std::type_index Euclid::Table::binaryFormatToType ( const std::string format,
const std::vector< size_t > &  shape 
)

Definition at line 64 of file FitsReaderHelper.cpp.

References std::string::back(), and std::vector< T >::empty().

Referenced by autoDetectColumnTypes().

Here is the call graph for this function:

ELEMENTS_API std::vector< size_t > Euclid::Table::calculateColumnLengths ( const Table &  table)

Calculates the sizes in characters each column of the table needs.

The size is calculated as the size of the longest column entry (including type and name) plus one to ensure separation of the values.

Parameters
tableThe table
Returns
the sizes of the columns

Definition at line 73 of file AsciiWriterHelper.cpp.

References std::max(), and s.

Referenced by Euclid::Table::AsciiWriter::append(), and Euclid::Table::AsciiWriter::init().

Here is the call graph for this function:

template<typename T >
std::vector<Row::cell_type> Euclid::Table::convertNdArrayColumn ( CCfits::Column &  column,
long  first,
long  last 
)

Definition at line 188 of file FitsReaderHelper.cpp.

References std::begin(), std::end(), std::move(), parseTDIM(), and std::vector< T >::push_back().

Here is the call graph for this function:

template<typename T >
std::vector<Row::cell_type> Euclid::Table::convertScalarColumn ( CCfits::Column &  column,
long  first,
long  last 
)

Definition at line 166 of file FitsReaderHelper.cpp.

References std::vector< T >::push_back().

Here is the call graph for this function:

ELEMENTS_API Row::cell_type Euclid::Table::convertToCellType ( const std::string value,
std::type_index  type 
)

Converts the given value to a Row::cell_type of the given type.

For more information of the supported types see the documentation of the Euclid::Table::AsciiReader constructor.

Parameters
valueThe value to convert
typeThe type of the cell
Returns
The Row::cell_type representing the value
Exceptions
Elements::Exceptionif the conversion fails

Definition at line 292 of file AsciiReaderHelper.cpp.

References std::type_index::name().

Referenced by Euclid::Table::AsciiReader::readImpl().

Here is the call graph for this function:

template<typename T >
std::vector<Row::cell_type> Euclid::Table::convertVectorColumn ( CCfits::Column &  column,
long  first,
long  last 
)

Definition at line 177 of file FitsReaderHelper.cpp.

References std::begin(), std::end(), and std::vector< T >::push_back().

Here is the call graph for this function:

ELEMENTS_API size_t Euclid::Table::countColumns ( std::istream in,
const std::string comment 
)

Returns the number of whitespace separated tokens of the first non commented line.

When the method returns the given stream is positioned at the same position like before the method was called.

Parameters
inThe string to read from
commentThe comment pattern
Returns
The number of columns
Exceptions
Elements::Exceptionif there is no uncommented, non-empty line

Definition at line 45 of file AsciiReaderHelper.cpp.

References std::string::begin(), std::string::empty(), std::string::end(), std::string::find(), and std::string::substr().

Referenced by Euclid::Table::AsciiReader::readColumnInfo().

Here is the call graph for this function:

ELEMENTS_API std::size_t Euclid::Table::countRemainingRows ( std::istream in,
const std::string comment 
)

Definition at line 355 of file AsciiReaderHelper.cpp.

References std::string::empty(), std::string::find(), and std::string::substr().

Referenced by Euclid::Table::AsciiReader::rowsLeft().

Here is the call graph for this function:

template<typename T >
std::vector<T> Euclid::Table::createColumnData ( const Euclid::Table::Table table,
size_t  column_index 
)

Definition at line 166 of file FitsWriterHelper.cpp.

References std::vector< T >::push_back().

Here is the call graph for this function:

std::shared_ptr< ColumnInfo > Euclid::Table::createColumnInfo ( const std::vector< std::string > &  names,
const std::vector< std::type_index > &  types,
const std::vector< std::string > &  units,
const std::vector< std::string > &  descriptions 
)

Creates a ColumnInfo object from the given names and types.

Definition at line 30 of file ReaderHelper.cpp.

References std::move(), std::vector< T >::push_back(), and std::vector< T >::size().

Referenced by Euclid::Table::FitsReader::readColumnInfo(), and Euclid::Table::AsciiReader::readColumnInfo().

Here is the call graph for this function:

template<typename T >
std::vector<std::valarray<T> > Euclid::Table::createNdArrayColumnData ( const Euclid::Table::Table table,
size_t  column_index 
)

Definition at line 195 of file FitsWriterHelper.cpp.

References std::vector< T >::emplace_back().

Here is the call graph for this function:

template<typename T >
std::vector<T> Euclid::Table::createSingleNdArrayVectorColumnData ( const Euclid::Table::Table table,
size_t  column_index 
)

Definition at line 205 of file FitsWriterHelper.cpp.

References std::vector< T >::push_back().

Here is the call graph for this function:

template<typename T >
std::vector<T> Euclid::Table::createSingleValueVectorColumnData ( const Euclid::Table::Table table,
size_t  column_index 
)

Definition at line 185 of file FitsWriterHelper.cpp.

References std::vector< T >::push_back().

Here is the call graph for this function:

template<typename T >
std::vector<std::valarray<T> > Euclid::Table::createVectorColumnData ( const Euclid::Table::Table table,
size_t  column_index 
)

Definition at line 175 of file FitsWriterHelper.cpp.

References std::vector< T >::emplace_back().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::string > Euclid::Table::getAsciiFormatList ( const Table &  table)

Returns a vector with strings representing the FITS ASCII table formats for the given table.

For more details on the conversions between the table formats and the FITS ASCII formats see the documentation of the FitsWriter::write() method.

Parameters
tableThe table
Returns
The list of FITS ASCII table formats

Definition at line 63 of file FitsWriterHelper.cpp.

References maxWidth(), maxWidthScientific(), and std::vector< T >::push_back().

Referenced by Euclid::Table::FitsWriter::init().

Here is the call graph for this function:

ELEMENTS_API std::vector< std::string > Euclid::Table::getBinaryFormatList ( const Table &  table)

Returns a vector with strings representing the FITS binary table formats for the given table.

For more details on the conversions between the table formats and the FITS binary formats see the documentation of the FitsWriter::write() method.

Parameters
tableThe table
Returns
The list of FITS binary table formats

Definition at line 110 of file FitsWriterHelper.cpp.

References maxWidth(), std::vector< T >::push_back(), and std::string::push_back().

Referenced by Euclid::Table::FitsWriter::init().

Here is the call graph for this function:

ELEMENTS_API std::string Euclid::Table::getTDIM ( const Table &  table,
size_t  column_index 
)

Serializes the shape of the column, if it is a multidimensional array. Otherwise, returns an empty string

Parameters
table
column_index
Returns
A string directly usable with TDIM (i.e. (3,2))

Definition at line 238 of file FitsWriterHelper.cpp.

References std::stringstream::str().

Referenced by Euclid::Table::FitsWriter::init().

Here is the call graph for this function:

ELEMENTS_API bool Euclid::Table::hasNextRow ( std::istream in,
const std::string comment 
)

Definition at line 338 of file AsciiReaderHelper.cpp.

References std::string::empty(), std::string::find(), and std::string::substr().

Referenced by Euclid::Table::AsciiReader::hasMoreRows().

Here is the call graph for this function:

std::type_index Euclid::Table::keywordToType ( const std::string keyword)

Definition at line 74 of file AsciiReaderHelper.cpp.

Referenced by autoDetectColumnDescriptions().

size_t Euclid::Table::maxWidth ( const Table &  table,
size_t  column_index 
)

Definition at line 47 of file FitsWriterHelper.cpp.

References std::max().

Referenced by getAsciiFormatList(), and getBinaryFormatList().

Here is the call graph for this function:

size_t Euclid::Table::maxWidthScientific ( const Table &  table,
size_t  column_index 
)

Definition at line 55 of file FitsWriterHelper.cpp.

References std::max(), and scientificFormat().

Referenced by getAsciiFormatList().

Here is the call graph for this function:

template<typename T >
size_t Euclid::Table::ndArraySize ( const Table &  table,
size_t  column_index 
)

Definition at line 98 of file FitsWriterHelper.cpp.

std::vector<size_t> Euclid::Table::parseTDIM ( const std::string tdim)

Definition at line 114 of file FitsReaderHelper.cpp.

References std::string::back(), std::string::empty(), std::string::front(), std::reverse(), s, std::string::size(), and std::string::substr().

Referenced by autoDetectColumnTypes(), and convertNdArrayColumn().

Here is the call graph for this function:

void Euclid::Table::populateColumn ( const Table &  table,
size_t  column_index,
CCfits::ExtHDU &  table_hdu,
long  first_row 
)

Definition at line 278 of file FitsWriterHelper.cpp.

Referenced by Euclid::Table::FitsWriter::append().

template<typename T >
void Euclid::Table::populateNdArrayColumn ( const Table &  table,
size_t  column_index,
CCfits::ExtHDU &  table_hdu,
long  first_row 
)

Definition at line 228 of file FitsWriterHelper.cpp.

template<typename T >
void Euclid::Table::populateVectorColumn ( const Table &  table,
size_t  column_index,
CCfits::ExtHDU &  table_hdu,
long  first_row 
)

Definition at line 218 of file FitsWriterHelper.cpp.

template<typename T >
std::string Euclid::Table::scientificFormat ( value)

Definition at line 41 of file FitsWriterHelper.cpp.

References std::scientific(), and std::ostringstream::str().

Referenced by maxWidthScientific().

Here is the call graph for this function:

ELEMENTS_API std::vector< Row::cell_type > Euclid::Table::translateColumn ( CCfits::Column &  column,
std::type_index  type 
)

Returns a vector representing the given FITS table column data, converted to the requested type.

Note that the column CCfits::Column does not provide const versions of the read methods, so the column argument cannot be const.

Parameters
columnThe column to convert
typeThe type of the column
Returns
The data in Row::cell_type format

Definition at line 200 of file FitsReaderHelper.cpp.

Referenced by Euclid::Table::FitsReader::readImpl().

ELEMENTS_API std::vector< Row::cell_type > Euclid::Table::translateColumn ( CCfits::Column &  column,
std::type_index  type,
long  first,
long  last 
)

Definition at line 204 of file FitsReaderHelper.cpp.

References std::type_index::name().

Here is the call graph for this function:

ELEMENTS_API std::string Euclid::Table::typeToKeyword ( std::type_index  type)

Converts a type to its string representation.

Parameters
typeThe type to convert
Returns
The string representation
Exceptions
Elements::Exceptionif the given type is not supported

Definition at line 35 of file AsciiWriterHelper.cpp.

References std::type_index::name().

Referenced by Euclid::Table::AsciiWriter::init().

Here is the call graph for this function:

template<typename T >
size_t Euclid::Table::vectorSize ( const Table &  table,
size_t  column_index 
)

Definition at line 87 of file FitsWriterHelper.cpp.

Variable Documentation

Elements::Logging Euclid::Table::logger = Elements::Logging::getLogger("AsciiReader")
static

Definition at line 43 of file AsciiReaderHelper.cpp.

Referenced by autoDetectColumnNames().