My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
StarPlot.h
Go to the documentation of this file.
1 // $Id: StarPlot.h,v 1.1.1.1 2009/07/06 23:57:23 eml Exp $
2 
3 #ifndef GCP_UTIL_STARPLOT_H
4 #define GCP_UTIL_STARPLOT_H
5 
15 #include <string>
16 #include <vector>
17 #include <iostream>
18 
19 #include "gcp/util/common/Angle.h"
20 #include "gcp/util/common/Flux.h"
21 #include "gcp/util/common/FirstFitsReader.h"
22 #include "gcp/util/common/NvssReader.h"
23 #include "gcp/util/common/NedReader.h"
24 #include "gcp/util/common/SzaCalReader.h"
25 
26 namespace gcp {
27  namespace util {
28 
29  class StarPlot {
30  public:
31 
32  enum {
33  UNKNOWN = 0x0,
34  SOLAR = 0x2,
35  OPTICAL = 0x4,
36  RADIO = 0x8,
37 
38  SRCLIST = 0x10,
39  NVSS = 0x20,
40  FIRST = 0x40,
41  GCPCAL = 0x80,
42  NED = 0x100,
43  };
44 
45  struct Object {
46 
47  std::string name_;
48  std::string survey_;
49  double ra_;
50  double dec_;
51  double mag_;
52  double az_;
53  double el_;
54  double x_;
55  double y_;
56  Flux flux_;
57  double specInd_;
58  Angle diam_;
59  Angle maj_;
60  Angle majerr_;
61  Angle min_;
62  Angle minerr_;
63  int vis_;
64  int mark_;
65  Angle dist_;
66  Angle angle_;
67 
68  unsigned type_;
69  unsigned nedFlags_;
70 
71  float size();
72  unsigned sym();
73  unsigned color();
74 
75  Object();
76 
77  Object(const Object& obj) {
78  *this = (Object&)obj;
79  };
80 
81  Object(Object& obj) {
82  *this = obj;
83  };
84 
86 
87  void operator=(const Object& obj) {
88  *this = (Object&)obj;
89  };
90 
91  void operator=(Object& obj) {
92 
93  name_ = obj.name_;
94  survey_ = obj.survey_;
95  ra_ = obj.ra_;
96  dec_ = obj.dec_;
97  mag_ = obj.mag_;
98  flux_ = obj.flux_;
99  az_ = obj.az_;
100  el_ = obj.el_;
101  x_ = obj.x_;
102  y_ = obj.y_;
103  diam_ = obj.diam_;
104  vis_ = obj.vis_;
105  mark_ = obj.mark_;
106  type_ = obj.type_;
107  nedFlags_ = obj.type_;
108  specInd_ = obj.specInd_;
109  dist_ = obj.dist_;
110  angle_ = obj.angle_;
111  };
112 
113  static bool isLessThan(StarPlot::Object& obj1, StarPlot::Object& obj2)
114  {
115  return (obj1.survey_ < obj2.survey_) || (obj1.survey_ == obj2.survey_ && obj1.name_ <= obj2.name_);
116  }
117 
118  static bool isEqualTo(StarPlot::Object& obj1, StarPlot::Object& obj2)
119  {
120  return (obj1.survey_ == obj2.survey_ && obj1.name_ == obj2.name_);
121  }
122 
123  // Format where this source came from
124 
125  std::string origin();
126 
127  friend std::ostream& operator<<(std::ostream& os, Object& obj);
128  };
129 
130  struct Rect {
131  double x1;
132  double x2;
133  double y1;
134  double y2;
135  };
136 
137  struct Mark {
138  int mark;
139  int id;
140  };
141 
142  struct Site {
143  std::string name_;
144  Angle latitude_;
145  Angle longitude_;
146  };
147 
151  StarPlot();
152 
156  virtual ~StarPlot();
157 
158  void initCatalog();
159 
160  void setCatalog(std::string catalog);
161  void readCatalog(std::string catalog);
162  void readCatalog();
163 
164  void readCal(std::string catalog);
165 
166  void setLatitude(Angle latitude);
167  void setLongitude(Angle longitude);
168  void setElevationLimit(Angle el);
169 
170  void plotPolar();
171  void plotPolar(double mjd);
172 
173  void openDevice(char* device);
174  void setSiteName(std::string name);
175 
176  void setMagLim(double maglim);
177  void setFluxLim(Flux flux);
178 
179  void setSunDist(double dist);
180  void setMoonDist(double dist);
181 
182  void setSite(std::string site);
183  void setSite(std::string site, Angle& lat, Angle& lng);
184 
185  void redraw();
186 
187  void removeDuplicates();
188 
189  StarPlot::Object mark(double x, double y);
190  void clearMarks();
191  void showMarkedStars();
192  PtSrcReader* ptSrcReader(std::string survey);
193 
194  void readPtSrc(std::string survey, Flux& fmin, Flux& fmax);
195  void readPtSrc(std::string survey, Flux& fmin, Flux& fmax, Angle& radius, Angle& lng, Angle& lat);
196  void readPtSrc(std::string survey, Angle& radius, Angle& lng, Angle& lat);
197 
198  unsigned addFlags(std::string survey);
199 
200  void setDisplayLst(HourAngle lst);
201  void clearDisplayLst();
202 
203  void setDisplayMjd(TimeVal mjd);
204  void clearDisplayMjd();
205 
206  void setRange(double xa, double xb, double ya, double yb);
207  void setRange(Angle& lat, Angle& lng, Angle& el);
208  void setRange();
209 
210  void searchNed(double xa, double xb, double ya, double yb);
211  void setSunDist(Angle& angle);
212  void setMoonDist(Angle& angle);
213 
214  private:
215 
216  Angle distance(Angle& ra1, Angle& dec1, Angle& ra2, Angle& dec2);
217 
218  double parseSexagesimal(char *string);
219  double zeap(double theta);
220 
221  void projectZea(double az, double el, double *x, double *y);
222  void deprojectZea(double x, double y, Angle& az, Angle& el);
223 
224  int identify(double x, double y);
225  void greekify(char *input, char *output);
226  void initBox(Rect& box);
227  double getTime(void);
228  void setRadioVis(int radio_vis);
229  void drawMoon(double phase, int bg, int fg);
230  static int markCmp(const Mark* a, const Mark* b);
231  void markStarsFromFile(char* file);
232  void mjdToDate(double mjd, char* date_string, int size);
233  void listMarkedStars();
234  double getMjd();
235 
236  public:
237  void drawCircle(double az, double el, Angle& radius, unsigned npt);
238 
239  // Return the az, el of a circle of npts at an angular
240  // separation of radius from the fiducial az, el
241 
242  void getAzElCircle(Angle& az, Angle& el, Angle& radius, unsigned npt,
243  std::vector<double>& azs, std::vector<double>& els);
244 
245  std::string catalogFile_;
246  std::vector<Object> starlist_;
247  double magLim_;
248  bool magLimIsSet_;
249 
250  Flux fluxLim_;
251  bool fluxLimIsSet_;
252 
253  unsigned markCounter_;
254  double maxmag_;
255  unsigned max_;
256 
257  // The site and elevation limit
258 
259  gcp::util::Angle latitude_;
260  gcp::util::Angle longitude_;
261  gcp::util::Angle elLimit_;
262 
263  // The site and elevation limit to display
264 
265  bool isZoomed_;
266  gcp::util::Angle dispLatitude_;
267  gcp::util::Angle dispLongitude_;
268  gcp::util::Angle dispElLimit_;
269 
270  gcp::util::HourAngle displayLst_;
271  bool lstIsSet_;
272 
273  gcp::util::TimeVal displayMjd_;
274  bool mjdIsSet_;
275 
276  int pgplotId_;
277 
278  std::string siteName_;
279  std::vector<Site> knownSites_;
280 
281  NvssReader nvss_;
282  FirstFitsReader first_;
283  SzaCalReader gcpCal_;
284  NedReader ned_;
285 
286  }; // End class StarPlot
287 
288  } // End namespace util
289 } // End namespace gcp
290 
291 
292 #endif // End #ifndef GCP_UTIL_STARPLOT_H
Definition: NvssReader.h:22
Definition: NedReader.h:28
void setMagLim(double maglim)
Definition: StarPlot.cc:937
StarPlot()
Definition: StarPlot.cc:42
Definition: StarPlot.h:29
Definition: StarPlot.h:142
void plotPolar()
Definition: StarPlot.cc:329
Definition: SzaCalReader.h:21
Definition: FirstFitsReader.h:30
Definition: Flux.h:25
Definition: HourAngle.h:17
Definition: StarPlot.h:130
Definition: Angle.h:20
Definition: TimeVal.h:55
virtual ~StarPlot()
Definition: StarPlot.cc:97
Definition: PtSrcReader.h:35
Definition: StarPlot.h:137
void readCatalog()
Definition: StarPlot.cc:156
void setFluxLim(Flux flux)
Definition: StarPlot.cc:954
Definition: StarPlot.h:45
void initCatalog()
Definition: StarPlot.cc:126
void getAzElCircle(Angle &az, Angle &el, Angle &radius, unsigned npt, std::vector< double > &azs, std::vector< double > &els)
Definition: StarPlot.cc:1677
Definition: PtSrcReader.h:29
void readCal(std::string catalog)
Definition: StarPlot.cc:164
void showMarkedStars()
Definition: StarPlot.cc:1357