MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smet::SMETWriter Class Reference

Detailed Description

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>

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. 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)
 Write a SMET file, providing ASCII ISO formatted timestamps and data. More...
 
void write (const std::vector< double > &data)
 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...
 
const std::string toString () const
 

Constructor & Destructor Documentation

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_filenameThe filename of the SMET file to be written
[in]in_typeThe 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.

Parameters
[in]in_filenameThe filename of the SMET file to be written
[in]in_fieldsThe fields that should be written in order to check that we write the same data at the same place.
[in]in_nodataValue representing nodata

Member Function Documentation

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]keyA string key to set in the header (overwritten if already present)
[in]valueA string value associated with the key
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]keyA string key to set in the header (overwritten if already present)
[in]valueA double value to be converted into a string and stored in the header
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_precisionSet the precision for every column to be written (timestamp is not counted if present)
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_widthSet 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< std::string > &  vec_timestamp,
const std::vector< double > &  data 
)

Write a SMET file, providing ASCII ISO formatted timestamps and data.

Parameters
[in]vec_timestampA vector with one ASCII date/time combined string for each line
[in]dataAll 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)
void smet::SMETWriter::write ( const std::vector< double > &  data)

Write a SMET file, providing a vector of doubles.

Parameters
[in]dataAll the data to be written sequentially into the columns, the data is aligned sequentially, not per line;

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