|
MeteoIODoc 20251210.a703fe45
Environmental timeseries pre-processing
|
The SMETWriter class that enables to write a SMET formatted file. The user constructs a SMETWriter class and fills in the header values Finally the user may call write(...) and pass the data to be written.
#include <libsmet.h>
Public Member Functions | |
| SMETWriter (const std::string &in_filename, const SMETType &in_type=ASCII) | |
| The constructor allows to set the filename, the type and whether the file should be gzipped. | |
| SMETWriter (const std::string &in_filename, const std::string &in_fields, const double &in_nodata) | |
| The constructor allows to append data to an existing file. | |
| void | set_header_value (const std::string &key, const std::string &value) |
| Set a key, value pair in the SMET header (both strings) | |
| void | set_header_value (const std::string &key, const double &value) |
| Set a double value for a string key in a SMET header. | |
| void | write (const std::vector< std::string > &vec_timestamp, const std::vector< double > &data, const mio::ACDD &acdd) |
| Write a SMET file, providing ASCII ISO formatted timestamps and data. | |
| void | write (const std::vector< double > &data, const mio::ACDD &acdd) |
| Write a SMET file, providing a vector of doubles. | |
| void | set_precision (const std::vector< int > &vec_precision) |
| Set precision for each field (except timestamp), otherwise a default precision of 3 is used for each column. | |
| void | set_width (const std::vector< int > &vec_width) |
| Set width for each field (except timestamp), otherwise a default width of 8 is used for each column. | |
| void | set_separator (const char &i_separator) |
| For some special cases (import into DB), the white space separator should be replaced by another one (typically, comma). In this case, each field will be delimited by a single separator but the headers will remain space-delimited. | |
| void | set_commented_headers (const bool &flag) |
| For some special cases (import into DB), the headers should be commented out (please note that this breaks SMET conformance) | |
| const std::string | toString () const |
The constructor allows to set the filename, the type and whether the file should be gzipped.
| [in] | in_filename | The filename of the SMET file to be written |
| [in] | in_type | The type of the SMET file, i.e. smet::ASCII or smet::BINARY (default: ASCII) |
| smet::SMETWriter::SMETWriter | ( | const std::string & | in_filename, |
| const std::string & | in_fields, | ||
| const double & | in_nodata | ||
| ) |
The constructor allows to append data to an existing file.
| [in] | in_filename | The filename of the SMET file to be written |
| [in] | in_fields | The fields that should be written in order to check that we write the same data at the same place. |
| [in] | in_nodata | Value representing nodata |
|
inline |
For some special cases (import into DB), the headers should be commented out (please note that this breaks SMET conformance)
| [in] | flag | should headers be commented out? |
| void smet::SMETWriter::set_header_value | ( | const std::string & | key, |
| const double & | value | ||
| ) |
Set a double value for a string key in a SMET header.
| [in] | key | A string key to set in the header (overwritten if already present) |
| [in] | value | A double value to be converted into a string and stored in the header |
| void smet::SMETWriter::set_header_value | ( | const std::string & | key, |
| const std::string & | value | ||
| ) |
Set a key, value pair in the SMET header (both strings)
| [in] | key | A string key to set in the header (overwritten if already present) |
| [in] | value | A string value associated with the key |
| void smet::SMETWriter::set_precision | ( | const std::vector< int > & | vec_precision | ) |
Set precision for each field (except timestamp), otherwise a default precision of 3 is used for each column.
| [in] | vec_precision | Set the precision for every column to be written (timestamp is not counted if present) |
| void smet::SMETWriter::set_separator | ( | const char & | i_separator | ) |
For some special cases (import into DB), the white space separator should be replaced by another one (typically, comma). In this case, each field will be delimited by a single separator but the headers will remain space-delimited.
| [in] | i_separator | field separator to use instead of spaces |
| void smet::SMETWriter::set_width | ( | const std::vector< int > & | vec_width | ) |
Set width for each field (except timestamp), otherwise a default width of 8 is used for each column.
| [in] | vec_width | Set the width for every column to be written (timestamp is not counted if present) |
| const std::string smet::SMETWriter::toString | ( | ) | const |
| void smet::SMETWriter::write | ( | const std::vector< double > & | data, |
| const mio::ACDD & | acdd | ||
| ) |
Write a SMET file, providing a vector of doubles.
| [in] | data | All the data to be written sequentially into the columns, the data is aligned sequentially, not per line; |
| [in] | acdd | ACDD object that contains acdd metadata |
| void smet::SMETWriter::write | ( | const std::vector< std::string > & | vec_timestamp, |
| const std::vector< double > & | data, | ||
| const mio::ACDD & | acdd | ||
| ) |
Write a SMET file, providing ASCII ISO formatted timestamps and data.
| [in] | vec_timestamp | A vector with one ASCII date/time combined string for each line |
| [in] | data | All the data to be written sequentially into the columns, the data is aligned sequentially, not per line; Total size of the vector: Total size of the vector: vec_timestamp.size() * nr_of_fields (timestamp is not counted as field) |
| [in] | acdd | ACDD object that contains acdd metadata |