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.
- Author
- Thomas Egger
- Date
- 2011-07-14
#include <libsmet.h>
|
| 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. More...
|
|
| 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. More...
|
|
void | set_header_value (const std::string &key, const std::string &value) |
| Set a key, value pair in the SMET header (both strings) More...
|
|
void | set_header_value (const std::string &key, const double &value) |
| Set a double value for a string key in a SMET header. More...
|
|
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. More...
|
|
void | write (const std::vector< double > &data, const mio::ACDD &acdd) |
| Write a SMET file, providing a vector of doubles. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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) More...
|
|
const std::string | toString () const |
|
◆ SMETWriter() [1/2]
smet::SMETWriter::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.
- Parameters
-
[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) |
◆ SMETWriter() [2/2]
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.
- Parameters
-
[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 |
◆ set_commented_headers()
void smet::SMETWriter::set_commented_headers |
( |
const bool & |
flag | ) |
|
|
inline |
For some special cases (import into DB), the headers should be commented out (please note that this breaks SMET conformance)
- Parameters
-
[in] | flag | should headers be commented out? |
◆ set_header_value() [1/2]
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.
- Parameters
-
[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 |
◆ set_header_value() [2/2]
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)
- Parameters
-
[in] | key | A string key to set in the header (overwritten if already present) |
[in] | value | A string value associated with the key |
◆ set_precision()
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.
- Parameters
-
[in] | vec_precision | Set the precision for every column to be written (timestamp is not counted if present) |
◆ set_separator()
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.
- Parameters
-
[in] | i_separator | field separator to use instead of spaces |
◆ set_width()
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.
- Parameters
-
[in] | vec_width | Set the width for every column to be written (timestamp is not counted if present) |
◆ toString()
const std::string smet::SMETWriter::toString |
( |
| ) |
const |
◆ write() [1/2]
void smet::SMETWriter::write |
( |
const std::vector< double > & |
data, |
|
|
const mio::ACDD & |
acdd |
|
) |
| |
Write a SMET file, providing a vector of doubles.
- Parameters
-
[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 |
◆ write() [2/2]
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.
- Parameters
-
[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 |
The documentation for this class was generated from the following files: