HOPS
HOPS class reference
MHO_BasicPlotVisitor.hh
Go to the documentation of this file.
1 #ifndef MHO_BasicPlotVisitor_HH__
2 #define MHO_BasicPlotVisitor_HH__
3 
7 
8 #include <algorithm>
9 #include <cmath>
10 #include <iomanip>
11 #include <matplot/matplot.h>
12 #include <numeric>
13 #include <sstream>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 namespace hops
19 {
20 
22 {
23  public:
25  virtual ~MHO_BasicPlotVisitor();
26 
31  virtual void Plot(MHO_FringeData* data) override;
32 
33  protected:
34  private:
35  class subplot_parameters
36  {
37  public:
38  subplot_parameters(): total_rows(0), total_cols(0), start_row(0), start_col(0), rowspan(0), colspan(0){};
39 
40  subplot_parameters(int a, int b, int c, int d, int e, int f)
41  : total_rows(a), total_cols(b), start_row(c), start_col(d), rowspan(e), colspan(f){};
42 
43  virtual ~subplot_parameters(){};
44 
45  //data
46  int total_rows;
47  int total_cols;
48  int start_row;
49  int start_col;
50  int rowspan;
51  int colspan;
52  };
53 
54  std::map< std::string, subplot_parameters > fSubplotConfig;
55 
56  void ConfigureSubplots();
57 
58  void ConstructXTitle(const subplot_parameters& params, std::string title, std::string font_color, int font_size,
59  double x_coord, double y_coord, bool center = false);
60  void ConstructYTitle(const subplot_parameters& params, std::string title, std::string font_color, int font_size,
61  bool is_y2 = false); // double x_coord, double y_coord, bool center)
62 
63  void ConstructPlot(const mho_json& plot_data);
64  void DirectSavePlot(std::string filename);
65 
70  void make_dr_mbd_plot(const mho_json& plot_dict);
71 
76  void make_sbd_dtec_plot(const mho_json& plot_dict);
77 
82  void make_xpower_plot(const mho_json& plot_dict);
83 
88  void make_channel_segment_plots(const mho_json& plot_dict);
89 
94  void make_channel_segment_validity_plots(const mho_json& plot_dict);
95 
100  void make_pcal_plots(const mho_json& plot_dict);
101 
106  void make_top_info_text(const mho_json& plot_dict);
107 
112  void make_basic_info_text(const mho_json& plot_dict);
113 
118  void make_model_resid_info_text(const mho_json& plot_dict);
119 
124  void make_rms_table(const mho_json& plot_dict);
125 
130  void make_coord_text(const mho_json& plot_dict);
131 
136  void make_amplitude_table(const mho_json& plot_dict);
137 
142  void make_window_table(const mho_json& plot_dict);
143 
148  void make_data_stats_text(const mho_json& plot_dict);
149 
154  void make_channel_info_table(const mho_json& plot_dict);
155 
159  void setup_figure_layout();
160 
161  double determine_desired_tick_spacing(int n_ticks, double lower_limit, double upper_limit,
162  const std::vector< double >& desired_intervals)
163  {
164  // Calculate tick marks based on span and desired spacing intervals
165  double span = std::fabs(upper_limit - lower_limit);
166  double target = span / (double)n_ticks;
167  //example target spacing:
168  //std::vector<double> tspace = {0.1, 0.5, 1, 5, 10, 25, 50, 100, 200, 500};
169  int idx = 0;
170  double tmin = 1e3 * upper_limit;
171  for(std::size_t i = 0; i < desired_intervals.size(); i++)
172  {
173  double delta = std::fabs(target - desired_intervals[i]);
174  if(delta < tmin)
175  {
176  tmin = delta;
177  idx = i;
178  }
179  }
180  double tick_spacing = desired_intervals[idx];
181  return tick_spacing;
182  }
183 
192  matplot::axes_handle subplot2grid(const std::pair< int, int >& shape, const std::pair< int, int >& loc, int rowspan = 1,
193  int colspan = 1, float left_margin = 0.0, float right_margin = 0.0);
194 
195  matplot::axes_handle subplot2grid_wrapper(const subplot_parameters sp, double left_margin = 0.0,
196  double right_margin = 0.0);
197 
198  // Member variables for plot state
199  matplot::figure_handle fCurrentFigure;
200  bool fShowPlot;
201  std::string fFilename;
202  mho_json fPlotData;
203 
204  //place to stash all the axes so they stay part of the figure
205  std::vector< matplot::axes_handle > fAxes;
206  matplot::axes_handle fLastAxis;
207 
208  int fPageWidth;
209  int fPageHeight;
210  float fLeftMargin;
211  float fRightMargin;
212  int fNRows;
213  int fNCols;
214 };
215 
216 } // namespace hops
217 
218 #endif /* end of include guard: MHO_BasicPlotVisitor_HH__ */
nlohmann::json mho_json
Definition: MHO_JSONHeaderWrapper.hh:5
Definition: MHO_BasicPlotVisitor.hh:22
MHO_BasicPlotVisitor()
Definition: MHO_BasicPlotVisitor.cc:62
virtual void Plot(MHO_FringeData *data) override
Main plotting function - creates the complete fourfit plot.
Definition: MHO_BasicPlotVisitor.cc:234
virtual ~MHO_BasicPlotVisitor()
Definition: MHO_BasicPlotVisitor.cc:73
Class MHO_FringeData.
Definition: MHO_FringeData.hh:30
Class MHO_FringePlotVisitor.
Definition: MHO_FringePlotVisitor.hh:13
Definition: fit_gsl.h:54
Definition: MHO_AdhocFlagging.hh:18