TECA
teca_wrf_reader.h
1 #ifndef teca_wrf_reader_h
2 #define teca_wrf_reader_h
3 
4 #include "teca_algorithm.h"
5 #include "teca_metadata.h"
6 #include "teca_shared_object.h"
7 
8 #include <vector>
9 #include <string>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_wrf_reader)
12 
14 using p_teca_wrf_reader_internals = std::shared_ptr<teca_wrf_reader_internals>;
15 
17 
52 {
53 public:
54  TECA_ALGORITHM_STATIC_NEW(teca_wrf_reader)
55  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_wrf_reader)
56  TECA_ALGORITHM_CLASS_NAME(teca_wrf_reader)
57  ~teca_wrf_reader();
58 
59  // report/initialize to/from Boost program options
60  // objects.
61  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
62  TECA_SET_ALGORITHM_PROPERTIES()
63 
64  // list of file names to open. if this is set the files_regex
65  // is ignored.
66  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, file_name)
67 
68  // describe the set of files comprising the dataset. This
69  // should contain the full path and regex describing the
70  // file name pattern
71  TECA_ALGORITHM_PROPERTY(std::string, files_regex)
72 
73  // the directory where metadata should be cached. if this is not specified
74  // metadata is cached either with the data, in the CWD, or in the user's
75  // home dir, which ever location succeeds first.
76  TECA_ALGORITHM_PROPERTY(std::string, metadata_cache_dir)
77 
78  // set if the dataset has periodic boundary conditions
79  TECA_ALGORITHM_PROPERTY(int, periodic_in_x)
80  TECA_ALGORITHM_PROPERTY(int, periodic_in_y)
81  TECA_ALGORITHM_PROPERTY(int, periodic_in_z)
82 
83  // time calendar and time unit if the user wants to
84  // specify them
85  TECA_ALGORITHM_PROPERTY(std::string, t_calendar)
86  TECA_ALGORITHM_PROPERTY(std::string, t_units)
87 
88  // a way to infer time from the filename if the time axis is not
89  // stored in the file itself. strftime format codes are used.
90  // For example for the files:
91  //
92  // my_file_20170516_00.nc
93  // my_file_20170516_03.nc
94  // ...
95  //
96  // the template would be
97  //
98  // my_file_%Y%m%d_%H.nc
99  TECA_ALGORITHM_PROPERTY(std::string, filename_time_template)
100 
101  // time values to use instead if time variable doesn't
102  // exist.
103  TECA_ALGORITHM_VECTOR_PROPERTY(double, t_value)
104 
105  // set/get the number of threads in the pool. setting
106  // to less than 1 results in 1 - the number of cores.
107  // the default is 1.
108  TECA_ALGORITHM_PROPERTY(int, thread_pool_size)
109 
110 protected:
111  teca_wrf_reader();
112  void clear_cached_metadata();
113 
114 private:
115  teca_metadata get_output_metadata(
116  unsigned int port,
117  const std::vector<teca_metadata> &input_md) override;
118 
119  const_p_teca_dataset execute(
120  unsigned int port,
121  const std::vector<const_p_teca_dataset> &input_data,
122  const teca_metadata &request) override;
123 
124  virtual void set_modified() override;
125 
126 private:
127  std::vector<std::string> file_names;
128  std::string files_regex;
129  std::string metadata_cache_dir;
130  std::string m_x_axis_variable;
131  std::string m_y_axis_variable;
132  std::string u_x_axis_variable;
133  std::string u_y_axis_variable;
134  std::string v_x_axis_variable;
135  std::string v_y_axis_variable;
136  std::string m_z_axis_variable;
137  std::string w_z_axis_variable;
138  std::string t_axis_variable;
139  std::string t_calendar;
140  std::string t_units;
141  std::string filename_time_template;
142  std::vector<double> t_values;
143  int periodic_in_x;
144  int periodic_in_y;
145  int periodic_in_z;
146  int thread_pool_size;
147  p_teca_wrf_reader_internals internals;
148 };
149 
150 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_wrf_reader_internals
Definition: teca_wrf_reader.cxx:40
teca_wrf_reader
a reader for data stored in WRF ARW format
Definition: teca_wrf_reader.h:52
teca_algorithm
Definition: teca_algorithm.h:25