The SMETReader class enables to read a SMET formatted file. Data and header info can be extracted through this class.
#include <libsmet.h>
Public Member Functions | |
SMETReader (const std::string &in_fname) | |
A constructor that will immediately parse the header of the SMET file. More... | |
void | read (const std::string ×tamp_start, const std::string ×tamp_end, std::vector< std::string > &vec_timestamp, std::vector< double > &vec_data) |
Read the data in a SMET file for a given interval of time if no timestamp is present in the file, the whole file is read. More... | |
void | read (const double &julian_start, const double &julian_end, std::vector< double > &vec_data) |
Read the data in a SMET file for a given interval of time if no julian field is present in the file, the whole file is read. More... | |
void | read (std::vector< std::string > &vec_timestamp, std::vector< double > &vec_data) |
Read all the data in a SMET file, if a timestamp is present. More... | |
void | read (std::vector< double > &vec_data) |
Read all the data in a SMET file, if no timestamp is present. More... | |
std::string | get_header_value (const std::string &key) const |
Get a string value for a header key in a SMET file. More... | |
double | get_header_doublevalue (const std::string &key) const |
Get a double value for a header key in a SMET file. More... | |
int | get_header_intvalue (const std::string &key) const |
Get an int value for a header key in a SMET file. More... | |
bool | contains_timestamp () const |
Check whether timestamp is a part of the fields. More... | |
std::string | get_field_name (const size_t &nr_of_field) |
Get a name for a certain column in the SMET file. More... | |
bool | location_in_header (const LocationType &type) const |
Check whether location information is written in the header. More... | |
bool | location_in_data (const LocationType &type) const |
Check whether location information is written in the data section. More... | |
size_t | get_nr_of_fields () const |
Get number of fields (=columns) in SMET file (timestamp excluded) More... | |
void | get_units_conversion (std::vector< double > &offset, std::vector< double > &multiplier) const |
Get the unit conversion (offset and multiplier) that are used for this SMET object If the fields units_offset or units_multiplier are present in the header they are returned, otherwise the default conversion vectors for the offset (consisting of zeros) and for the multipliers (consisting of ones) are returned. More... | |
void | convert_to_MKSA (const bool &in_mksa) |
Set whether the values returned should be converted according to unit_offset and multiplier or whether the user should get the raw data returned. More... | |
std::string | get_filename () const |
Retrieve the filename that this reader operates upon. More... | |
Friends | |
class | SMETWriter |
smet::SMETReader::SMETReader | ( | const std::string & | in_fname | ) |
A constructor that will immediately parse the header of the SMET file.
[in] | in_fname | The filename of the SMET file |
bool smet::SMETReader::contains_timestamp | ( | ) | const |
Check whether timestamp is a part of the fields.
void smet::SMETReader::convert_to_MKSA | ( | const bool & | in_mksa | ) |
Set whether the values returned should be converted according to unit_offset and multiplier or whether the user should get the raw data returned.
[in] | in_mksa | True if the user wants MKSA values returned, false otherwise (default) |
std::string smet::SMETReader::get_field_name | ( | const size_t & | nr_of_field | ) |
Get a name for a certain column in the SMET file.
[in] | nr_of_field | Column index (the column 'timestamp' is not counted) |
std::string smet::SMETReader::get_filename | ( | ) | const |
Retrieve the filename that this reader operates upon.
double smet::SMETReader::get_header_doublevalue | ( | const std::string & | key | ) | const |
Get a double value for a header key in a SMET file.
[in] | key | A key in the header section of a SMET file |
int smet::SMETReader::get_header_intvalue | ( | const std::string & | key | ) | const |
Get an int value for a header key in a SMET file.
[in] | key | A key in the header section of a SMET file |
std::string smet::SMETReader::get_header_value | ( | const std::string & | key | ) | const |
Get a string value for a header key in a SMET file.
[in] | key | A key in the header section of a SMET file |
size_t smet::SMETReader::get_nr_of_fields | ( | ) | const |
Get number of fields (=columns) in SMET file (timestamp excluded)
void smet::SMETReader::get_units_conversion | ( | std::vector< double > & | offset, |
std::vector< double > & | multiplier | ||
) | const |
Get the unit conversion (offset and multiplier) that are used for this SMET object If the fields units_offset or units_multiplier are present in the header they are returned, otherwise the default conversion vectors for the offset (consisting of zeros) and for the multipliers (consisting of ones) are returned.
[out] | offset | A vector of doubles representing the offset for each column |
[out] | multiplier | A vector of doubles representing the multiplier for each column |
bool smet::SMETReader::location_in_data | ( | const LocationType & | type | ) | const |
Check whether location information is written in the data section.
[in] | type | Either smet::WGS84 or smet::EPSG |
bool smet::SMETReader::location_in_header | ( | const LocationType & | type | ) | const |
Check whether location information is written in the header.
[in] | type | Either smet::WGS84 or smet::EPSG |
void smet::SMETReader::read | ( | const double & | julian_start, |
const double & | julian_end, | ||
std::vector< double > & | vec_data | ||
) |
Read the data in a SMET file for a given interval of time if no julian field is present in the file, the whole file is read.
[in] | julian_start | beginning of interval (inclusive), julian day |
[in] | julian_end | end of interval (inclusive), julian day |
[out] | vec_data | A vector of double holding all double values of all lines sequentially |
void smet::SMETReader::read | ( | const std::string & | timestamp_start, |
const std::string & | timestamp_end, | ||
std::vector< std::string > & | vec_timestamp, | ||
std::vector< double > & | vec_data | ||
) |
Read the data in a SMET file for a given interval of time if no timestamp is present in the file, the whole file is read.
[in] | timestamp_start | ISO formatted string, beginning of interval (inclusive) |
[in] | timestamp_end | ISO formatted string, end of interval (inclusive) |
[out] | vec_timestamp | A vector of string to hold the timestamp of each line |
[out] | vec_data | A vector of double holding all double values of all lines sequentially |
void smet::SMETReader::read | ( | std::vector< double > & | vec_data | ) |
Read all the data in a SMET file, if no timestamp is present.
[out] | vec_data | A vector of double holding all double values of all lines sequentially |
void smet::SMETReader::read | ( | std::vector< std::string > & | vec_timestamp, |
std::vector< double > & | vec_data | ||
) |
Read all the data in a SMET file, if a timestamp is present.
[out] | vec_timestamp | A vector of string to hold the timestamp of each line |
[out] | vec_data | A vector of double holding all double values of all lines sequentially |
|
friend |