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
20namespace 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
64template<typename T>
65float cast_to_float (T t)
66{
67 return (float) t;
68}
69
70float cast_to_float (const MJD& t)
71{
72 return t.in_days();
73}
74
76template<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
Type min
The minimum value on the axis.
Definition ReceptionModelAxisPlotter.h:55
void set_axis(MEAL::Axis< Type > *_axis)
Set the Axis<Type> to which the epoch is connected.
Definition ReceptionModelAxisPlotter.h:32
unsigned npt
The number of points in the plot.
Definition ReceptionModelAxisPlotter.h:52
MEAL::Axis< Type > * axis
The Axis<Type> to which the epoch is connected.
Definition ReceptionModelAxisPlotter.h:49
void set_min(Type _min)
Set the minimum value on the axis.
Definition ReceptionModelAxisPlotter.h:38
Type max
The maximum value on the axis.
Definition ReceptionModelAxisPlotter.h:58
void set_npt(unsigned _npt)
Set the number of points in the plot.
Definition ReceptionModelAxisPlotter.h:35
void set_max(Type _max)
Set the maximum value on the axis.
Definition ReceptionModelAxisPlotter.h:41
void plot_model()
Plot the model in the current configuration.
Definition ReceptionModelAxisPlotter.h:77
unsigned isource
The index of the source to be plotted.
Definition ReceptionModelPlotter.h:79
ReceptionModelPlotter()
Default constructor.
Definition ReceptionModelPlotter.C:21
Reference::To< ReceptionModel > model
The model from which plot data will be taken.
Definition ReceptionModelPlotter.h:70
unsigned ipath
The index of the signal path.
Definition ReceptionModelPlotter.h:82
unsigned ipol
The index of the Stokes parameter to be plotted.
Definition ReceptionModelPlotter.h:76
const std::string get_message() const

Generated using doxygen 1.14.0