TECA
teca_dataset_diff.h
1 #ifndef teca_dataset_diff_h
2 #define teca_dataset_diff_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 #include "teca_table.h"
8 #include "teca_mesh.h"
9 #include "teca_cartesian_mesh.h"
10 #include "teca_curvilinear_mesh.h"
11 #include "teca_arakawa_c_grid.h"
12 #include "teca_array_collection.h"
13 
14 #include <vector>
15 #include <string>
16 
17 TECA_SHARED_OBJECT_FORWARD_DECL(teca_dataset_diff)
18 
19 
33 {
34 public:
35  TECA_ALGORITHM_STATIC_NEW(teca_dataset_diff)
36  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_dataset_diff)
37  TECA_ALGORITHM_CLASS_NAME(teca_dataset_diff)
39 
40  // report/initialize to/from Boost program options objects.
41  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
42  TECA_SET_ALGORITHM_PROPERTIES()
43 
44  // Relative tolerance below which two floating-point numbers a and b are
45  // considered equal. if |a - b| <= max(|a|,|b|)*tol then a is equal to b.
46  // the relative tolerance is used with numbers not close to zero.
47  TECA_ALGORITHM_PROPERTY(double, relative_tolerance)
48 
49  // The absolute tolerance below which two floating point numbers a and b are
50  // considered equal. if |a - b| <= tol then a is equal to b. The absolute
51  // tolerance is used with numbers close to zero.
52  TECA_ALGORITHM_PROPERTY(double, absolute_tolerance)
53 
54  // if set infromation about the test progress is displayed during
55  // the test.
56  TECA_ALGORITHM_PROPERTY(int, verbose)
57 protected:
59 
60  // Comparison methods.
61  int compare_tables(const_p_teca_table table1, const_p_teca_table table2);
62 
63  int compare_meshes(
64  const_p_teca_mesh reference_mesh,
65  const_p_teca_mesh data_mesh);
66 
67  int compare_cartesian_meshes(
68  const_p_teca_cartesian_mesh reference_mesh,
69  const_p_teca_cartesian_mesh data_mesh);
70 
71  int compare_curvilinear_meshes(
72  const_p_teca_curvilinear_mesh reference_mesh,
73  const_p_teca_curvilinear_mesh data_mesh);
74 
75  int compare_arakawa_c_grids(
76  const_p_teca_arakawa_c_grid reference_mesh,
77  const_p_teca_arakawa_c_grid data_mesh);
78 
79  int compare_array_collections(
80  const_p_teca_array_collection reference_arrays,
81  const_p_teca_array_collection data_arrays);
82 
83  int compare_arrays(const_p_teca_variant_array array1,
84  const_p_teca_variant_array array2, double absTol, double relTol);
85 
86  // Reporting methods.
87 
88  // Call this with contextual information when datasets differ. You can use
89  // printf formatting.
90  void datasets_differ(const char* info, ...);
91 
92 private:
93  teca_metadata get_output_metadata(unsigned int port,
94  const std::vector<teca_metadata> &input_md) override;
95 
96  std::vector<teca_metadata> get_upstream_request(
97  unsigned int port, const std::vector<teca_metadata> &input_md,
98  const teca_metadata &request) override;
99 
100  const_p_teca_dataset execute(unsigned int port,
101  const std::vector<const_p_teca_dataset> &input_data,
102  const teca_metadata &request) override;
103 
104  double get_abs_tol() const;
105  double get_rel_tol() const;
106 
107 private:
108  double relative_tolerance;
109  double absolute_tolerance;
110  int verbose;
111 };
112 
113 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_dataset_diff
compute the element wise difference between to datasets
Definition: teca_dataset_diff.h:33
teca_algorithm
Definition: teca_algorithm.h:25