Luiza
v03-01
|
Class for reading and processing fits tables in Luiza. More...
#include <GloriaFitsTable.h>
Public Member Functions | |
GloriaFitsTable () | |
Default constructor. More... | |
GloriaFitsTable (string FitsFileName) | |
Constructor based on reading fits file. | |
GloriaFitsTable (const GloriaFitsTable &sourceFitsTable) | |
Copy constructor. | |
virtual | ~GloriaFitsTable () |
Destructor. | |
GloriaFitsTable & | operator= (const GloriaFitsTable &tab) |
Assignment operator. | |
void | ReadFitsFile (string FitsFileName) |
Read fits table from file. More... | |
void | ReadTextFile (string TextFileName) |
Read table from text file. More... | |
void | WriteFitsFile (string FitsFileName, bool binary_tbl=true) |
Write table to fits file. More... | |
void | WriteTextFile (string TextFileName, int colWidth=10, char ColumnSeparator= ' ') |
Write table to text file. More... | |
void | WriteTextStream (std::ostream &outF, int colWidth=10, char ColumnSeparator= ' ') |
Write table to output text stream. More... | |
int | GetColumnNumber () |
Returns number of defined columns. | |
int | GetRowNumber () |
Returns number of filled rows. | |
string | GetColumnName (int iCol) |
Returns name of column. | |
int | GetColumnId (string name) |
Returns column Id. | |
TableColumnType | GetColumnType (int iCol) |
Returns type of column. | |
TableColumnType | GetColumnType (string name) |
Returns type for given column name. | |
bool | ColumnExists (string name) |
Check if given column exists. | |
GloriaTableColumn * | GetColumn (int iCol) |
Returns base class pointer for given column index. | |
GloriaTableColumn * | GetColumn (string name) |
Returns base class pointer for named column stored in the table. | |
template<class T > | |
GloriaTableColumnOf< T > * | GetColumnOf (int iCol) |
Returns pointer to the column of given type, for given column index. | |
template<class T > | |
GloriaTableColumnOf< T > * | GetColumnOf (string name) |
Returns pointer to the column of given type, for given column name. | |
template<class T > | |
vector< T > & | GetVectorOf (int iCol) |
Returns data vector of given type, from given column index. | |
template<class T > | |
vector< T > & | GetVectorOf (string name) |
Returns data vector of given type, from given column name. | |
template<class T > | |
T & | GetValueOf (int iCol, int iRow) |
Returns value of given type, from given column index and row. | |
template<class T > | |
T & | GetValueOf (string name, int iRow) |
Returns value of given type, from given column name and row. | |
void | AddColumn (string Name, TableColumnType Type, string Unit="", string Comment="") |
Add column of given type to the table. More... | |
template<class T > | |
void | AddColumn (string Name, T empty, string Unit="", string Comment="") |
Add column to the table. Type recognized by type of empty cell given. More... | |
void | InsertColumn (GloriaTableColumn *source) |
Insert column in the table. More... | |
void | InsertColumn (string NewName, GloriaTableColumn *source) |
Insert column in the table. More... | |
void | AddRow () |
Add new row in the table. More... | |
template<class T > | |
void | AddRow (T val) |
Add new row and set value to the first column. More... | |
template<class T0 , class T1 > | |
void | AddRow (T0 val0, T1 val1) |
Add new row and set value to the first two columns. More... | |
template<class T0 , class T1 , class T2 > | |
void | AddRow (T0 val0, T1 val1, T2 val2) |
Add new row and set value to the first three columns. More... | |
template<class T0 , class T1 , class T2 , class T3 > | |
void | AddRow (T0 val0, T1 val1, T2 val2, T3 val3) |
Add new row and set value to the first four columns. More... | |
template<class T0 , class T1 , class T2 , class T3 , class T4 > | |
void | AddRow (T0 val0, T1 val1, T2 val2, T3 val3, T4 val4) |
Add new row and set value to the first five columns. More... | |
template<class T > | |
void | SetValue (string Name, int iRow, T val) |
Set value of given cell. | |
template<class T > | |
void | SetValue (int iCol, int iRow, T val) |
Set value of given cell. | |
template<class T > | |
void | SetLast (int iCol, T val) |
Set value of last cell in given column. | |
template<class T > | |
void | SetLast (string Name, T val) |
Set value of last cell in given column. | |
template<class T > | |
void | GetValue (string Name, int iRow, T *val) |
Get value of given cell. | |
template<class T > | |
void | GetValue (int iCol, int iRow, T *val) |
Get value of given cell. | |
void | CopyTableRow (GloriaFitsTable *source, int isource, int itarget=-1) |
Copy row elements from other table (assuming types match!) More... | |
GloriaFitsTable * | EmptyClone () |
Copy table structure and header information. Data is not copied. | |
void | AdjustColumns () |
Checks sizes of columns and adjust to the longest one if needed. | |
bool | CheckTable () |
Checks consistency of table structure. | |
long * | CreateSortIndex (int iCol, bool reverse=false) |
Create an index array for accessing table rows in order of increasing column values. | |
long * | CreateSortIndex (string name, bool reverse=false) |
Create an index array for accessing table rows in order of increasing column values. | |
void | SortTable (int iCol, bool reverse=false) |
Sort table rows in order of increasing values of selected column. | |
void | SortTable (string name, bool reverse=false) |
Sort table rows in order of increasing values of selected column. | |
bool | IsSorted () |
Check if table is sorted. | |
bool | IsSortedBy (string name) |
Check if table is sorted by given column. | |
string | SortName () |
Return name of the column used for table sorting. | |
int | SortColumn () |
Return name of the column used for table sorting. | |
void | DeleteRow (int iRow) |
Delete given row. | |
GloriaTableColumn * | RemoveColumn (int iCol) |
Return column pointer and remove it from the table structure. | |
GloriaTableColumn * | RemoveColumn (string name) |
Return column pointer and remove it from the table structure. | |
void | DeleteColumn (int iCol) |
Delete given column. | |
void | DeleteColumn (string name) |
Delete given column. | |
void | ClearTable () |
Clear the table (delete all rows, keep column definitions) | |
void | EmptyTable () |
Delete all columns in the table and clear table header. | |
void | Print (std::ostream &os, int colWidth=10) |
Print table content to the stream. | |
Public Member Functions inherited from gloria::GloriaFitsHeader | |
GloriaFitsHeader () | |
Constructor. | |
virtual | ~GloriaFitsHeader () |
Destructor. | |
void | ReadFitsHeader (fitsfile *fp) |
Read fits header from file. More... | |
void | WriteFitsHeader (fitsfile *fp) |
Write header to fits file. More... | |
int | GetKeywordNumber () |
Number of records defined in the header. | |
HeaderRecord & | GetRecordAt (const int ikey) |
Access header record by record index. | |
std::string & | GetKeywordAt (const int ikey) |
Access header keyword by record index. | |
std::string & | GetValueAt (const int ikey) |
Access header value (string) by record index. | |
std::string & | GetCommentAt (const int ikey) |
Access header comment by record index. | |
bool | IsKeywordSet (const char *keyword) |
Check if given keyword is set in the header. | |
HeaderRecord & | GetKeywordRecord (const char *keyword) |
Access header record by record index. | |
std::string & | GetKeywordValue (const char *keyword) |
Access header value (string) by keyword. | |
long | GetKeywordValueInt (const char *keyword) |
Access header value (long int) by keyword. | |
double | GetKeywordValueDouble (const char *keyword) |
Access header value (double) by keyword. | |
void | AddKeyword (const char *keyword, std::string value, std::string comment) |
Add new keyword to the fits header. | |
void | AddKeywordDouble (const char *keyword, double value, std::string comment) |
Add new keyword to the fits header, as double. | |
void | AddKeywordInt (const char *keyword, int value, std::string comment) |
Add new keyword to the fits header, as int. | |
void | AddKeyword (HeaderRecord record) |
Add new keyword record to the fits header. | |
void | SetKeyword (const char *keyword, std::string value, std::string comment) |
Set new value for the existing keyword. Add it if not present. | |
void | SetKeywordDouble (const char *keyword, double value, std::string comment) |
Set new value for the existing keyword as double. Add it if not present. | |
void | SetKeywordInt (const char *keyword, int value, std::string comment) |
Set new value for the existing keyword as int. Add it if not present. | |
void | AddComment (std::string comment) |
Add comment to the header. | |
void | AddHistory (std::string history) |
Add history to the header. | |
void | RemoveKeyword (const char *keyword) |
Remove given keyword from header. More... | |
void | RemoveKeywords (const char *keyword) |
Remove given keyword from header. More... | |
void | CopyHeader (GloriaFitsHeader *source) |
Copy full header from given data object (table or image);. | |
void | PrintHeader (std::ostream &os, int maxRec=100) |
Print FITS header to output stream. Use maxRec=0 to print all records. | |
bool | OK () |
Method returning true if processing was successful. | |
bool | Error () |
Method returning true if there was an error in data processing. | |
std::string | ErrorMessage () |
Returns error message string. | |
void | ClearError () |
Method returning true if there was an error in data processing. | |
std::string | InputFileName () |
void | SetInputFileName (string name) |
std::string | OutputFileName () |
Protected Attributes | |
int | _nRow |
Table size. | |
vector< GloriaTableColumn * > | _columns |
Column vector. | |
multimap< string, int > | _nameMap |
Column name map. Name is not always unique! | |
int | _nSorted |
Number of sorted rows. | |
string | _sortName |
Name of column used for sorting. | |
int | _sortColumn |
ID of column used for sorting. | |
Class for reading and processing fits tables in Luiza.
This class allows to read the fits table from file and store it in memory. Tables can be also created to store different kind of data or analysis results.
gloria::GloriaFitsTable::GloriaFitsTable | ( | ) |
Default constructor.
Default constructor cretes empty table
void gloria::GloriaFitsTable::AddColumn | ( | string | Name, |
TableColumnType | Type, | ||
string | Unit = "" , |
||
string | Comment = "" |
||
) |
Add column of given type to the table.
If any rows are already put in the table, new column is initialized to the current number of rows (with empty string or vector, or zero values, depending on type). Unit field is optional.
Referenced by luiza::FitsTableWriter::concludeAnalysis(), luiza::TableTextWriter::concludeAnalysis(), gloria::GloriaValueMap::GetTable(), gloria::GloriaObjectList::GloriaObjectList(), gloria::GloriaSkyCatalog::GloriaSkyCatalog(), luiza::TableTextReader::init(), luiza::SelectNewObjects::init(), luiza::PiTableReader::processData(), luiza::SociSelect::processData(), luiza::CalculateGausPSF::processData(), luiza::FastAperturePhotometry::processData(), luiza::SelectNewObjects::processData(), luiza::Astrometry::processData(), luiza::PixelClusterFinder::processData(), luiza::WeightedAperturePhotometry::processData(), luiza::CalibrateFrameObjects::processData(), luiza::FindLineTrajectory::processData(), luiza::TestProcessor::startAnalysis(), luiza::ExampleProcessor::startAnalysis(), and luiza::SatelliteSearching::startAnalysis().
void gloria::GloriaFitsTable::AddColumn | ( | string | Name, |
T | empty, | ||
string | Unit = "" , |
||
string | Comment = "" |
||
) |
Add column to the table. Type recognized by type of empty cell given.
If any rows are already put in the table, new column is initialized to the current number of rows (with empty string or vector, or zero values, depending on type). Unit field is optional.
References gloria::GetValueType().
void gloria::GloriaFitsTable::AddRow | ( | ) |
Add new row in the table.
Adding a row means increasing length of all columns by 1 String values are set to empty string, numerical to zero, vectors to empty vectors.
References AddRow().
Referenced by AddRow(), gloria::GloriaValueMap::GetTable(), luiza::TestProcessor::processData(), luiza::ExampleProcessor::processData(), luiza::PiTableReader::processData(), luiza::SociSelect::processData(), luiza::CalculateGausPSF::processData(), luiza::ObjectLightCurve::processData(), and luiza::FindLineTrajectory::processData().
|
inline |
|
inline |
|
inline |
|
inline |
Add new row and set value to the first four columns.
Be careful to respect column order and types. Otherwise value will not be added.
|
inline |
Add new row and set value to the first five columns.
Be careful to respect column order and types. Otherwise value will not be added.
void gloria::GloriaFitsTable::CopyTableRow | ( | GloriaFitsTable * | source, |
int | isource, | ||
int | itarget = -1 |
||
) |
Copy row elements from other table (assuming types match!)
New row is added if itarget is negative or beyond table length
References GetColumn(), GetColumnNumber(), and GetRowNumber().
Referenced by luiza::SelectTableData::processData(), luiza::SelectNewObjects::processData(), and luiza::FindLineTrajectory::processData().
void gloria::GloriaFitsTable::InsertColumn | ( | GloriaTableColumn * | source | ) |
Insert column in the table.
Source column is inserted as a new column in the table. Pointer to the column is stored so the data is not copied. GloriaTableColumn::Clone() method should be used to avoid problems.
References gloria::GloriaTableColumn::Name().
Referenced by luiza::FitsTableWriter::concludeAnalysis(), luiza::TableTextWriter::concludeAnalysis(), gloria::GloriaSkyCatalog::MatchObjectTable(), gloria::GloriaSkyCatalog::MatchObjectVector(), luiza::SelectTableData::processData(), and luiza::SelectNewObjects::processData().
void gloria::GloriaFitsTable::InsertColumn | ( | string | NewName, |
GloriaTableColumn * | source | ||
) |
Insert column in the table.
Source column is inserted as a new column in the table, with new name (!). Pointer to the column is stored so the data is not copied. GloriaTableColumn::Clone() method should be used to avoid problems.
References gloria::GloriaTableColumn::Name().
void gloria::GloriaFitsTable::ReadFitsFile | ( | string | FitsFileName | ) |
Read fits table from file.
Header and content are read from file and put into existing table. Old header and all data are lost.
Referenced by luiza::FitsTableReader::processData().
void gloria::GloriaFitsTable::ReadTextFile | ( | string | TextFileName | ) |
Read table from text file.
Content is read from text file and put into existing table. Header remains unchanged.
Referenced by luiza::TableTextReader::processData().
void gloria::GloriaFitsTable::WriteFitsFile | ( | string | FitsFileName, |
bool | binary_tbl = true |
||
) |
Write table to fits file.
Header compliant to with FITS standard is created
Referenced by luiza::FitsTableWriter::concludeAnalysis().
void gloria::GloriaFitsTable::WriteTextFile | ( | string | TextFileName, |
int | colWidth = 10 , |
||
char | ColumnSeparator = ' ' |
||
) |
Write table to text file.
Can be used to store data for direct analysis
Referenced by luiza::ExampleProcessor::concludeAnalysis(), and luiza::SatelliteSearching::concludeAnalysis().
void gloria::GloriaFitsTable::WriteTextStream | ( | std::ostream & | outF, |
int | colWidth = 10 , |
||
char | ColumnSeparator = ' ' |
||
) |
Write table to output text stream.
Can be used to store multiple tables to one stream
Referenced by luiza::TableTextWriter::concludeAnalysis().