rhythm.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 1999 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/rhythm/rhythm.h
10 
11 // //////////////////////////////////////////////////////////////////////////
12 //
13 // Rhythm
14 //
15 // A Graphical User Interface to Tempo
16 //
17 // //////////////////////////////////////////////////////////////////////////
18 
19 #ifndef __RHYTHM_H
20 #define __RHYTHM_H
21 
22 #include <vector>
23 
24 #include <qapplication.h>
25 #include <qmainwindow.h>
26 #include <qlistbox.h>
27 #include <qhbox.h>
28 #include <qvbox.h>
29 #include <qlabel.h>
30 #include <qpixmap.h>
31 #include <qbuttongroup.h>
32 #include <qradiobutton.h>
33 #include <qinputdialog.h>
34 #include <qtabwidget.h>
35 #include <qprogressdialog.h>
36 #include <qfiledialog.h>
37 #include <qcheckbox.h>
38 #include <qlistview.h>
39 #include <qtabwidget.h>
40 
41 #include "psrephem.h"
42 using Legacy::psrephem;
43 
44 #include "ephio.h"
45 #include "toaPlot.h"
46 #include "toa.h"
47 #include "residual.h"
48 
49 #include "sky_coord.h"
50 #include "coord.h"
51 #include "MJD.h"
52 
53 #include "Options.h"
54 
55 #include "Pulsar/Archive.h"
56 #include "Pulsar/Profile.h"
57 
58 #include "Pulsar/StandardSNR.h"
59 
60 class qt_editParams;
61 
62 class AxisSelector : public QHBox
63 {
64  Q_OBJECT
65 
66  public:
67 
68  AxisSelector (QWidget* parent);
69 
70  protected:
71 
72  QButtonGroup* Xgrp;
73  QButtonGroup* Ygrp;
74 
75  QRadioButton* X1;
76  QRadioButton* X2;
77  QRadioButton* X3;
78  QRadioButton* X4;
79  QRadioButton* X5;
80  QRadioButton* X6;
81  QRadioButton* X7;
82  QRadioButton* X8;
83  QRadioButton* X9;
84  QRadioButton* X10;
85  QRadioButton* X11;
86  QRadioButton* X12;
87  QRadioButton* X13;
88  QCheckBox* Xlog;
89 
90  QRadioButton* Y1;
91  QRadioButton* Y2;
92  QRadioButton* Y3;
93  QRadioButton* Y4;
94  QRadioButton* Y5;
95  QRadioButton* Y6;
96  QRadioButton* Y7;
97  QRadioButton* Y8;
98  QRadioButton* Y9;
99  QRadioButton* Y10;
100  QRadioButton* Y11;
101  QRadioButton* Y12;
102  QRadioButton* Y13;
103  QCheckBox* Ylog;
104 
105  public slots:
106 
107  void Xuseful(int);
108  void Yuseful(int);
109 
110  bool isLogX();
111  bool isLogY();
112 
113  signals:
114 
115  void XChange (toaPlot::AxisQuantity);
116  void YChange (toaPlot::AxisQuantity);
117 };
118 
119 class Rhythm : public QMainWindow
120 {
121  Q_OBJECT
122 
123  public:
124  static bool verbose;
125  static bool vverbose;
126 
127  Rhythm (QApplication* master, QWidget* parent, int argc, char** argv);
128  ~Rhythm ();
129 
130  // fits the loaded toas using TEMPO with the given psrephem, 'eph'.
131  // if 'load_new' is true, loads the new epehemeris into the display
132  void fit (const psrephem& eph, bool load_new);
133 
134  // fits the selected toas using TEMPO with the given psrephem, 'eph'.
135  // if 'load_new' is true, loads the new epehemeris into the display
136  void fit_selected (const psrephem& eph, bool load_new);
137 
138  // set the verbosity flag for a number of the classes on which
139  // this application is based
140  void setClassVerbose (bool verbose);
141 
142  protected:
143 
144  QApplication* myapp;
145  QTabWidget* tabs;
146 
147  RhythmOptions opts;
148 
149  // The array of toas
150  std::vector<Tempo::toa> toas;
151 
152  // A parallel vector of QListViewItem pointers
153  bool show_list;
154  std::vector<QListViewItem*> ltoas;
155  QListView* lister;
156 
157  // The file from which they were read
158  std::string toa_filename;
159 
160  void load_toas (const char* fname);
161  void add_toas (std::vector<Tempo::toa>);
162  void save_toas (const char* fname);
163 
164  void update_mode ();
165 
166  // /////////////////////////////////////////////////////////////////////////
167  // Main Plotting Window(s)
168  toaPlot* plot_window;
169  AxisSelector* chooser;
170  toaPlot::AxisQuantity xq;
171  toaPlot::AxisQuantity yq;
172 
173  QVBox* leftpanel;
174  QHBox* bottompanel;
175  QVBox* controls;
176  QLabel* header;
177  QLabel* footer;
178  QButtonGroup* modechanger;
179  QRadioButton* zoom;
180  QRadioButton* sel;
181 
182  QPushButton* cut;
183 
184  QPushButton* xrange;
185  QPushButton* yrange;
186  QPushButton* point;
187  QPushButton* box;
188 
189  QPushButton* clearsel;
190  QPushButton* undel;
191  QPushButton* autoscl;
192  QPushButton* autobin;
193  QPushButton* freqs;
194  QPushButton* show_button;
195 
196  QPushButton* colour;
197  QPushButton* dotify;
198 
199  std::string dataPath;
200 
201  int mode;
202 
203  // /////////////////////////////////////////////////////////////////////////
204  // Fit parameters Menu Widget
205  qt_editParams* fitpopup;
206 
207  // /////////////////////////////////////////////////////////////////////////
208  // ToolBar and its constructor
209  void toolbarConstruct ();
210 
211  // /////////////////////////////////////////////////////////////////////////
212  // main menubar and its constructor
213  void menubarConstruct (); // construct the menubar along the top
214 
215  // The TEMPO popup menu and IDs of its individual options
216  QPopupMenu* tempo; // pointer to the Tempo popup menu
217  int dispID; // ID of the 'Display Parameters' menu item
218  int fitID; // ID of the 'Fit' menu item
219  int fitSelID; // ID of the 'Fit Selected' menu item
220  int autofitID; // ID of the 'Autofit' menu item
221  int temsysID;
222  int ddkID;
223  int stdID;
224  int weightsID; // ID of the 'Weights' menu item
225  int trackID; // ID of the 'Track' menu item
226  int saveParmsID;
227  int strideFitID; // ID of the 'Stride Fit' menu item
228  int advanceT0ID; // ID of the 'Advance T0' menu item
229  int advancePEPOCHID; // ID of the 'Advance PEPOCH' menu item
230 
231  bool autofit; // fit whenever TOAs or TEMPO Parameters are loaded
232  bool weights; // use TEMPO mode 1
233  bool track; // Attempt to track phase wraps
234  bool ignore_one_eph; // ignore the newParams signal from qt_editeph ONCE
235  bool toas_modified; // the toas have been modified since loaded
236 
237  // The OPTIONS popup menu and IDs of its individual options
238  QPopupMenu* options;
239  int quietID;
240  int mediumID;
241  int noisyID;
242 
243  // /////////////////////////////////////////////////////////////////////////
244  // Command line parsing and exit routines
245  void exit (int value);
246  void command_line_help ();
247  void command_line_parse (int argc, char** argv);
248 
249  // /////////////////////////////////////////////////////////////////////////
250  // Data extraction routines
251  std::vector<double> give_me_data (toaPlot::AxisQuantity);
252  std::vector<double> give_me_errs (toaPlot::AxisQuantity);
253 
254  std::vector<Pulsar::Profile*> the_stds;
255 
256  public slots:
257 
258  void scan_selected ();
259  void plot_current ();
260  void show_me ();
261  void request_update ();
262 
263  void save_all ();
264 
265  // File menu callbacks
266  void load_toas ();
267  void close_toas ();
268  int prompt_save_toas ();
269  void save_toas ();
270  void chc ();
271  void hc ();
272  void all_done ();
273 
274  // Tempo menu callbacks
275  void fit();
276  void fit_selected();
277  void togledit();
278  void toglauto();
279  void toglweights();
280  void togltrack();
281  void temposys();
282  void set_ddk();
283  void set_std_tempo();
284  void stride_fit();
285  void advanceT0();
286  void advancePEPOCH();
287 
288  // Options->Verbosity menu callback
289  void setVerbosity (int id);
290  // Options->Preferences
291  void showOptions () { opts.show(); };
292 
293  void undo() {fprintf (stderr, "Not implemented\n");};
294  void redo() {fprintf (stderr, "Not implemented\n");};
295 
296  // Help menu callbacks
297  void about();
298  void aboutQt();
299 
300  // callback connected to qt_editParams::newParams
301  void set_Params (const psrephem&);
302 
303  // plot selection slots
304  void XChange (toaPlot::AxisQuantity);
305  void YChange (toaPlot::AxisQuantity);
306  void goplot ();
307 
308  void change_mode (int);
309 
310  void xrange_slot ();
311  void yrange_slot ();
312  void point_slot ();
313  void box_slot ();
314 
315  void select (int);
316  void select (std::vector<int>);
317  void deselect (int);
318  void deselect (std::vector<int>);
319 
320  void clearselection ();
321  void deleteselection ();
322 
323  void colour_selector ();
324  void symbol_selector ();
325 
326  void setselcol (int);
327  void setseldot (int);
328 
329  void undeleteall ();
330 
331  void freqsort ();
332  void autobin_ask ();
333 
334  void setDataPath ();
335  void profileMovie ();
336 
337  void simulateModel ();
338 };
339 
340 #endif
341 
342 
343 
344 
345 
346 
347 
348 
void fit(const Pulsar::Parameters *model, std::vector< toa > &data, Pulsar::Parameters *postfit=NULL, bool track=false, Tempo::toa::State min_state=Tempo::toa::Normal)
float get_snr(const Profile *profile)
Return the signal to noise ratio based on the shift.
Definition: StandardSNR.C:17
double get_parallactic_angle() const
void set_observatory_latitude(double latitude)
void set_source_coordinates(const sky_coord &coords)
Angle get_longitude() const
Get the longitude of the antenna.
Definition: Telescope.h:106
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
static Archive * load(const std::string &name)
Factory returns a new instance loaded from filename.
Definition: Archive_load.C:28
Type * get() const
Plots a single pulse profile.
Definition: ProfilePlot.h:26
void set_observatory_longitude(double longitude)
void set_epoch(const MJD &epoch)
Contains information about the telescope used for the observation.
Definition: Telescope.h:26
bool verbose
Definition: timer++.C:25
Print a label with three rows above the plot frame.
Definition: InfoLabel.h:28
Angle get_latitude() const
Get the latitude of the antenna.
Definition: Telescope.h:101
void set_standard(const Profile *profile)
Set the standard against which the S/N will be calculated.
Definition: StandardSNR.C:11
virtual void plot(const Calibrator *calibrator)
Plot the Pulsar::Calibrator.
Definition: CalibratorPlotter.C:37
const Profile * get_Profile(const Archive *data, Index subint, Index pol, Index chan)
Return the requested profile, cloning and integrating when needed.
Definition: Index.C:24
void tempo(const std::string &arguments, const std::string &input)
Calculates the signal-to-noise ratio by fitting against a standard.
Definition: StandardSNR.h:27

Generated using doxygen 1.8.17