TECA
The Toolkit for Extreme Climate Analysis
teca_table_calendar.h
1 #ifndef teca_table_calendar_h
2 #define teca_table_calendar_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 
8 #include <string>
9 #include <vector>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_table_calendar)
12 
13 /** @brief
14  * An algorithm that transforms NetCDF CF-2 time
15  * variable into an absolute date.
16  *
17  * @details
18  * Transform NetCDF CF-2 time variable into an absolute
19  * date. By default the "time" column is used, but this
20  * can be over road by set_active_column methods. the
21  * table must have temporal metadata containing base date
22  * and calendar units following the CF-2 convention.
23  * the output table will contain year,month,day,hours,
24  * minutes columns.
25  *
26  * @note
27  * This should be used in serial, as the UDUNITS
28  * package loads an XML file in each instance. The
29  * CalCalcs package also has thread safety issues.
30  */
32 {
33 public:
34  TECA_ALGORITHM_STATIC_NEW(teca_table_calendar)
35  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_table_calendar)
36  TECA_ALGORITHM_CLASS_NAME(teca_table_calendar)
38 
39  // report/initialize to/from Boost program options
40  // objects.
41  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
42  TECA_SET_ALGORITHM_PROPERTIES()
43 
44  // set the name of the column to convert. If this is
45  // not set "time" is used.
46  TECA_ALGORITHM_PROPERTY(std::string, time_column)
47 
48  // set the CF-2 base date and units. If this is not
49  // set then the units are obtained from table metadata.
50  TECA_ALGORITHM_PROPERTY(std::string, units)
51 
52  // set the CF-2 calendar. if this is not set then
53  // the calendar is obtained from the table metadata.
54  TECA_ALGORITHM_PROPERTY(std::string, calendar)
55 
56  // set the names of the output columns. The defaults are
57  // "year", "month", "day", "hour", "minute", "second"
58  // setting any of these to the empty string "", will
59  // suppress their output.
60  TECA_ALGORITHM_PROPERTY(std::string, year_column)
61  TECA_ALGORITHM_PROPERTY(std::string, month_column)
62  TECA_ALGORITHM_PROPERTY(std::string, day_column)
63  TECA_ALGORITHM_PROPERTY(std::string, hour_column)
64  TECA_ALGORITHM_PROPERTY(std::string, minute_column)
65  TECA_ALGORITHM_PROPERTY(std::string, second_column)
66 
67  // set output prefix. the prefix (optional) is prepended
68  // to the column names.
69  TECA_ALGORITHM_PROPERTY(std::string, output_column_prefix)
70 
71 protected:
73 
74 private:
75  const_p_teca_dataset execute(
76  unsigned int port,
77  const std::vector<const_p_teca_dataset> &input_data,
78  const teca_metadata &request) override;
79 
80 private:
81  std::string units;
82  std::string calendar;
83  std::string time_column;
84  std::string year_column;
85  std::string month_column;
86  std::string day_column;
87  std::string hour_column;
88  std::string minute_column;
89  std::string second_column;
90  std::string output_column_prefix;
91 };
92 
93 #endif
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:244
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:22
An algorithm that transforms NetCDF CF-2 time variable into an absolute date.
Definition: teca_table_calendar.h:32
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.