MeteoIODoc 2.11.0
smet::SMETReader Class Reference

Detailed Description

The SMETReader class enables to read a SMET formatted file. Data and header info can be extracted through this class.

Author
Thomas Egger
Date
2011-07-18

#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 &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. 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
 

Constructor & Destructor Documentation

◆ SMETReader()

smet::SMETReader::SMETReader ( const std::string &  in_fname)

A constructor that will immediately parse the header of the SMET file.

Parameters
[in]in_fnameThe filename of the SMET file

Member Function Documentation

◆ contains_timestamp()

bool smet::SMETReader::contains_timestamp ( ) const

Check whether timestamp is a part of the fields.

Returns
true if timestamp is a column in the SMET file, false otherwise

◆ convert_to_MKSA()

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.

Parameters
[in]in_mksaTrue if the user wants MKSA values returned, false otherwise (default)

◆ get_field_name()

std::string smet::SMETReader::get_field_name ( const size_t &  nr_of_field)

Get a name for a certain column in the SMET file.

Parameters
[in]nr_of_fieldColumn index (the column 'timestamp' is not counted)
Returns
The string name of the column

◆ get_filename()

std::string smet::SMETReader::get_filename ( ) const

Retrieve the filename that this reader operates upon.

Returns
a std::string representing the filename

◆ get_header_doublevalue()

double smet::SMETReader::get_header_doublevalue ( const std::string &  key) const

Get a double value for a header key in a SMET file.

Parameters
[in]keyA key in the header section of a SMET file
Returns
The value for the key, if the key is not present return nodata

◆ get_header_intvalue()

int smet::SMETReader::get_header_intvalue ( const std::string &  key) const

Get an int value for a header key in a SMET file.

Parameters
[in]keyA key in the header section of a SMET file
Returns
The value for the key, if the key is not present return (int)nodata

◆ get_header_value()

std::string smet::SMETReader::get_header_value ( const std::string &  key) const

Get a string value for a header key in a SMET file.

Parameters
[in]keyA key in the header section of a SMET file
Returns
The value for the key, if the key is not present return ""

◆ get_nr_of_fields()

size_t smet::SMETReader::get_nr_of_fields ( ) const

Get number of fields (=columns) in SMET file (timestamp excluded)

Returns
A size_t value representing number of double valued columns

◆ get_units_conversion()

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.

Parameters
[out]offsetA vector of doubles representing the offset for each column
[out]multiplierA vector of doubles representing the multiplier for each column

◆ location_in_data()

bool smet::SMETReader::location_in_data ( const LocationType type) const

Check whether location information is written in the data section.

Parameters
[in]typeEither smet::WGS84 or smet::EPSG
Returns
true if type of location information is in data section, false otherwise

◆ location_in_header()

bool smet::SMETReader::location_in_header ( const LocationType type) const

Check whether location information is written in the header.

Parameters
[in]typeEither smet::WGS84 or smet::EPSG
Returns
true if type of location information is in header, false otherwise

◆ read() [1/4]

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.

Parameters
[in]julian_startbeginning of interval (inclusive), julian day
[in]julian_endend of interval (inclusive), julian day
[out]vec_dataA vector of double holding all double values of all lines sequentially

◆ read() [2/4]

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.

Parameters
[in]timestamp_startISO formatted string, beginning of interval (inclusive)
[in]timestamp_endISO formatted string, end of interval (inclusive)
[out]vec_timestampA vector of string to hold the timestamp of each line
[out]vec_dataA vector of double holding all double values of all lines sequentially

◆ read() [3/4]

void smet::SMETReader::read ( std::vector< double > &  vec_data)

Read all the data in a SMET file, if no timestamp is present.

Parameters
[out]vec_dataA vector of double holding all double values of all lines sequentially

◆ read() [4/4]

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.

Parameters
[out]vec_timestampA vector of string to hold the timestamp of each line
[out]vec_dataA vector of double holding all double values of all lines sequentially

Friends And Related Function Documentation

◆ SMETWriter

friend class SMETWriter
friend

The documentation for this class was generated from the following files: