CARMA C++
VisIo.h
Go to the documentation of this file.
1 // $Id: VisIo.h,v 1.1 2010/12/13 21:06:33 eml Exp $
2 
3 #ifndef SZA_UTIL_VISIO_H
4 #define SZA_UTIL_VISIO_H
5 
15 #include "carma/szautil/Angle.h"
16 #include "carma/szautil/DecAngle.h"
17 #include "carma/szautil/Frequency.h"
18 #include "carma/szautil/HourAngle.h"
19 #include "carma/szautil/Length.h"
20 #include "carma/szautil/Temperature.h"
21 #include "carma/szautil/Pressure.h"
22 
23 #include <vector>
24 
25 namespace sza {
26  namespace util {
27 
28  class VisIo {
29  public:
30 
34  VisIo();
35 
39  virtual ~VisIo();
40 
41  //------------------------------------------------------------
42  // A struct for managing UV parameters
43  //------------------------------------------------------------
44 
45  struct UvPar {
46  bool isSet_;
47  bool hasChangedSinceLastWrite_;
48 
49  UvPar() {
50  isSet_ = false;
51  hasChangedSinceLastWrite_ = false;
52  }
53 
54  bool isSet() {
55  return isSet_;
56  }
57 
58  bool changed() {
59  return hasChangedSinceLastWrite_;
60  }
61 
62  void initialize() {
63  isSet_ = false;
64  hasChangedSinceLastWrite_ = false;
65  };
66 
67  void update() {
68  isSet_ = true;
69  hasChangedSinceLastWrite_ = true;
70  };
71 
72  void markAsWritten() {
73  hasChangedSinceLastWrite_ = false;
74  };
75 
76  };
77 
78  //------------------------------------------------------------
79  // Methods to set information needed to write the FITS file
80  //------------------------------------------------------------
81 
82  void setSourceName(std::string srcName);
83  void setRa(HourAngle ra);
84  void setDec(DecAngle dec);
85  void setRaApp(HourAngle ra);
86  void setDecApp(DecAngle dec);
87  void setRaRef(HourAngle ra);
88  void setDecRef(DecAngle dec);
89  void setDRaApp(HourAngle ra);
90  void setDDecApp(DecAngle dec);
91 
92  //------------------------------------------------------------
93  // Methods to set information about the array
94  //------------------------------------------------------------
95 
96  void setInstrument(std::string instrument);
97  void setTelescopeName(std::string telescope);
98  void setLatitude(Angle& lat);
99  void setLongitude(Angle& longitude);
100 
101  //------------------------------------------------------------
102  // Methods to set information about the telescopes
103  //------------------------------------------------------------
104 
105  void setNumberOfTelescopes(unsigned nTel);
106  void setFirstTelescopeNum(unsigned iTel);
107 
108  // A method to check consistency with the current number of
109  // telescopes
110 
111  void checkNumberOfTelescopes(unsigned nTel);
112  unsigned getNumberOfTelescopes() {
113  return nTelescope_;
114  }
115 
116  // Install a set of telescope locations
117 
118  void setTelescopeLocations(std::vector<std::vector<Length> >& locations);
119 
120  // Set the telescope diameters
121 
122  void setTelescopeDiameters(std::vector<Length>& diameters);
123  void setTelescopeDiameter(Length& diameter);
124 
125  void setTelescopeAzimuth(std::vector<Angle>& az);
126  void setTelescopeElevation(std::vector<Angle>& el);
127 
128  // Set the telescope aperture efficiencies
129 
130  void setTelescopeApertureEfficiencies(std::vector<float>& apeffs);
131  void setTelescopeApertureEfficiency(float apeff);
132 
133  // Set the integration time
134 
135  void setIntTime(Time& time);
136 
137  //------------------------------------------------------------
138  // Frequency information
139  //------------------------------------------------------------
140 
141  // Install a set of IF frequencies
142 
143  void setNumberOfIfs(unsigned nIf);
144  void setIfFrequencies(std::vector<Frequency>& frequencies);
145  void setDeltaIfFrequencies(std::vector<Frequency>& frequencies);
146 
147  // An alternate method for specifying IF frequencies is to use a
148  // starting frequency and a delta
149 
150  void setStartingIfFrequency(Frequency frequency);
151  void setDeltaIfFrequency(Frequency& frequency);
152 
153  void setNumberOfChannelsPerIf(unsigned nChan);
154  void setDeltaChannelFrequency(Frequency frequency);
155 
156  //------------------------------------------------------------
157  // Methods to set weather information
158  //------------------------------------------------------------
159 
160  void setAirTemperature(Temperature& temp);
161  void setWindDirection(Angle& windDirection);
162  void setWindSpeed(Speed& windSpeed);
163  void setPressure(Pressure& pressure);
164  void setRelativeHumidity(double relativeHumidity);
165 
166  //------------------------------------------------------------
167  // Methods to set visibility data
168  //------------------------------------------------------------
169 
170  void setUvw(double* uvw);
171  void setVisWide(double* re, double* im);
172  void setVisSpec(double* re, double* im);
173  void setVisFlags(bool* visFlags);
174  void setRms(double* rms);
175  void setMjd(double* mjd);
176  void setLst(double* lst);
177 
178  //-----------------------------------------------------------------------
179  // Internal bookkeeping
180  //-----------------------------------------------------------------------
181 
182  void setNumberOfFrames(unsigned nFrame) {
183  nFrame_ = nFrame;
184  }
185 
186  void setNumberOfBaselines(unsigned nBaseline) {
187  nBaseline_ = nBaseline;
188  }
189 
190  unsigned getNumberOfBaselines() {
191  return nBaseline_;
192  }
193 
194  void setBaselines(unsigned *baselines) {
195  // Optional list of baseline numbers for
196  // data sets that do not include a full set.
197  baselines_ = baselines;
198  baselinesPar_.update();
199  }
200 
201  void setNumberOfStokesParameters(unsigned nStokes) {
202  nStokes_ = nStokes;
203  }
204 
205  //------------------------------------------------------------
206  // Methods to write the file
207  //------------------------------------------------------------
208 
209  virtual void checkParameters();
210  virtual void openFile(std::string fileName) {};
211  virtual void closeFile() {};
212 
213  void setPurpose(char purpose);
214 
215  //------------------------------------------------------------
216  // Utility methods
217  //------------------------------------------------------------
218 
219  // Return the antenna indices associated with a given visibility
220  // index.
221 
222  void getTelescopeIndices(unsigned baslineIndex,
223  unsigned* iRow, unsigned* iCol,
224  unsigned nTel);
225 
226  float jyPerK(Length& diameter, float apeff);
227  float jyPerK();
228 
229  void conjugateBaselines(bool conj);
230 
231  protected:
232 
233  bool doConj_;
234  float jyPerK_;
235 
236  Time intTime_;
237  UvPar intTimePar_;
238 
239  //------------------------------------------------------------
240  // Information about the array
241  //------------------------------------------------------------
242 
243  Angle latitude_;
244  Angle longitude_;
245  std::string telescope_;
246  std::string instrument_;
247  std::string date_;
248 
249  UvPar latitudePar_;
250  UvPar longitudePar_;
251  UvPar telescopePar_;
252  UvPar instrumentPar_;
253 
254  //------------------------------------------------------------
255  // Information about the source
256  //------------------------------------------------------------
257 
258  std::string srcName_;
259 
260  // J2000 mean
261 
262  HourAngle ra_;
263  DecAngle dec_;
264 
265  // Apparent
266 
267  HourAngle raApp_;
268  DecAngle decApp_;
269 
270  // Offsets
271 
272  HourAngle dRaApp_;
273  DecAngle dDecApp_;
274 
275  HourAngle raRef_;
276  DecAngle decRef_;
277 
278  UvPar srcNamePar_;
279 
280  UvPar raPar_;
281  UvPar decPar_;
282 
283  UvPar raAppPar_;
284  UvPar decAppPar_;
285 
286  UvPar raRefPar_;
287  UvPar decRefPar_;
288 
289  UvPar dRaAppPar_;
290  UvPar dDecAppPar_;
291 
292  //------------------------------------------------------------
293  // Information about the frequency
294  //------------------------------------------------------------
295 
296  // The number of IFs
297 
298  unsigned nIf_;
299  Frequency startingIfFrequency_;
300  Frequency deltaIfFrequency_;
301  std::vector<Frequency> ifFrequencies_;
302  std::vector<Frequency> deltaIfFrequencies_;
303  Frequency ifCenterFrequency_;
304 
305  UvPar nIfPar_;
306  UvPar ifFreqPar_;
307  UvPar deltaIfFreqPar_;
308 
309  // The number of channels per IF
310 
311  unsigned nChannel_;
312  Frequency startingFrequency_;
313  Frequency deltaChannelFrequency_;
314 
315  UvPar nChannelPar_;
316  UvPar deltaChannelFrequencyPar_;
317 
318  //------------------------------------------------------------
319  // Information about telescopes
320  //------------------------------------------------------------
321 
322  // The number of telescopes in our antenna table
323 
324  unsigned nTelescope_;
325  UvPar nTelescopePar_;
326 
327  std::vector<std::vector<Length> > locations_;
328 
329  std::vector<Angle> az_;
330  std::vector<Angle> el_;
331 
332  Length diameter_;
333  std::vector<Length> diameters_;
334 
335  float apeff_;
336  std::vector<float> apeffs_;
337 
338  UvPar locationsPar_;
339  UvPar azPar_;
340  UvPar elPar_;
341  UvPar diameterPar_;
342  UvPar apEffPar_;
343 
344  //------------------------------------------------------------
345  // Weather information
346  //------------------------------------------------------------
347 
348  Temperature airTemperature_;
349  Angle windDirection_;
350  Speed windSpeed_;
351  float relativeHumidity_;
352  Pressure pressure_;
353 
354  UvPar airTemperaturePar_;
355  UvPar windDirectionPar_;
356  UvPar windSpeedPar_;
357  UvPar relativeHumidityPar_;
358  UvPar pressurePar_;
359 
360  //------------------------------------------------------------
361  // Visibility data
362  //------------------------------------------------------------
363 
364  double* uvw_;
365  double* visWideRe_;
366  double* visWideIm_;
367  double* visSpecRe_;
368  double* visSpecIm_;
369  double* rms_;
370  double* mjd_;
371  double* lst_;
372  bool* visFlags_;
373 
374  UvPar uvwPar_;
375  UvPar visWidePar_;
376  UvPar visSpecPar_;
377  UvPar rmsPar_;
378  UvPar mjdPar_;
379  UvPar lstPar_;
380  UvPar visFlagsPar_;
381 
382  //------------------------------------------------------------
383  // Information about the observation
384  //------------------------------------------------------------
385 
386  char purpose_;
387  UvPar purposePar_;
388 
389  //------------------------------------------------------------
390  // Internal bookkeeping
391  //------------------------------------------------------------
392 
393  // The number of frames
394 
395  unsigned nFrame_;
396 
397  // The number of baselines
398 
399  unsigned nBaseline_;
400 
401  unsigned* baselines_;
402  UvPar baselinesPar_;
403  unsigned firstTelescopeNum_;
404 
405  // The number of Stokes parameters
406 
407  unsigned nStokes_;
408 
409 
410  }; // End class VisIo
411 
412  } // End namespace util
413 } // End namespace sza
414 
415 
416 
417 #endif // End #ifndef SZA_UTIL_VISIO_H