ReceptionModelAxisPlotter.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/Polarimetry/Pulsar/ReceptionModelAxisPlotter.h
10 
11 #ifndef __Calibration_ReceptionModelAxisPlotter_H
12 #define __Calibration_ReceptionModelAxisPlotter_H
13 
14 #include "Pulsar/ReceptionModelPlotter.h"
15 #include "MEAL/Axis.h"
16 #include "Pauli.h"
17 
18 #include <cpgplot.h>
19 
20 namespace Calibration {
21 
23  template<class Type>
24  class ReceptionModelAxisPlotter : public ReceptionModelPlotter
25  {
26 
27  public:
28 
29  ReceptionModelAxisPlotter () { axis = 0; npt = 100; }
30 
32  void set_axis (MEAL::Axis<Type>* _axis) { axis = _axis; }
33 
35  void set_npt (unsigned _npt) { npt = _npt; }
36 
38  void set_min (Type _min) { min = _min; }
39 
41  void set_max (Type _max) { max = _max; }
42 
44  void plot_model ();
45 
46  protected:
47 
50 
52  unsigned npt;
53 
55  Type min;
56 
58  Type max;
59 
60  };
61 
62 }
63 
64 template<typename T>
65 float cast_to_float (T t)
66 {
67  return (float) t;
68 }
69 
70 float cast_to_float (const MJD& t)
71 {
72  return t.in_days();
73 }
74 
76 template<class Type>
78 {
79  Type step = (max - min) / (npt - 1);
80 
81  model->set_transformation_index (ipath);
82  model->set_input_index (isource);
83 
84  for (unsigned ipt=0; ipt<npt; ipt++) try
85  {
86  Type index = min + step * ipt;
87  float val = cast_to_float (index);
88 
89  axis->set_value (index);
90 
91  Stokes<double> stokes = coherency( model->evaluate () );
92 
93  if (ipt == 0)
94  cpgmove (val, stokes[ipol]);
95  else
96  cpgdraw (val, stokes[ipol]);
97 
98  }
99  catch (Error& error)
100  {
101 #ifdef _DEBUG
102  std::cerr << "Calibration::ReceptionModelAxisPlotter<Type>::plot_model "
103  "ipt=" << ipt << " " << error.get_message() << std::endl;
104 #endif
105  }
106 }
107 
108 
109 #endif
110 
Plots model Stokes parameters as a function of time.
Definition: ReceptionModelAxisPlotter.h:29
void plot_model()
Plot the model in the current configuration.
Definition: ReceptionModelAxisPlotter.h:77
void set_min(Type _min)
Set the minimum value on the axis.
Definition: ReceptionModelAxisPlotter.h:48
unsigned npt
The number of points in the plot.
Definition: ReceptionModelAxisPlotter.h:62
void set_axis(MEAL::Axis< Type > *_axis)
Set the Axis<Type> to which the epoch is connected.
Definition: ReceptionModelAxisPlotter.h:42
void set_npt(unsigned _npt)
Set the number of points in the plot.
Definition: ReceptionModelAxisPlotter.h:45
Type max
The maximum value on the axis.
Definition: ReceptionModelAxisPlotter.h:68
MEAL::Axis< Type > * axis
The Axis<Type> to which the epoch is connected.
Definition: ReceptionModelAxisPlotter.h:59
Type min
The minimum value on the axis.
Definition: ReceptionModelAxisPlotter.h:65
const std::string get_message() const
void set_max(Type _max)
Set the maximum value on the axis.
Definition: ReceptionModelAxisPlotter.h:51

Generated using doxygen 1.8.17